28 #ifndef SPLA_CPU_MXM_HPP
29 #define SPLA_CPU_MXM_HPP
55 return "sequential sparse matrix sparse matrix product on cpu";
61 auto t = ctx.
task.template cast_safe<ScheduleTask_mxm>();
63 auto R = t->R.template cast_safe<TMatrix<T>>();
64 auto A = t->A.template cast_safe<TMatrix<T>>();
65 auto B = t->B.template cast_safe<TMatrix<T>>();
66 auto op_multiply = t->op_multiply.template cast_safe<TOpBinary<T, T, T>>();
67 auto op_add = t->op_add.template cast_safe<TOpBinary<T, T, T>>();
68 auto init = t->init.template cast_safe<TScalar<T>>();
74 CpuLil<T>* p_lil_R = R->template get<CpuLil<T>>();
75 const CpuLil<T>* p_lil_A = A->template get<CpuLil<T>>();
76 const CpuLil<T>* p_lil_B = B->template get<CpuLil<T>>();
78 auto& func_multiply = op_multiply->function;
79 auto& func_add = op_add->function;
81 auto DM = R->get_n_rows();
82 auto DN = R->get_n_cols();
83 auto I = init->get_value();
85 std::vector<T> R_tmp(DN, I);
87 for (
uint row_R = 0; row_R < DM; row_R++) {
88 const auto& A_lst = p_lil_A->Ar[row_R];
89 auto& R_lst = p_lil_R->
Ar[row_R];
91 assert(R_lst.empty());
93 std::fill(R_tmp.begin(), R_tmp.end(), I);
96 const uint i = entry_A.first;
97 const T value_A = entry_A.second;
99 const auto& B_lst = p_lil_B->Ar[i];
102 const uint j = entry_B.first;
103 const T value_B = entry_B.second;
105 R_tmp[j] = func_add(R_tmp[j], func_multiply(value_A, value_B));
109 for (
uint col_R = 0; col_R < DN; col_R++) {
110 if (R_tmp[col_R] != I) {
111 R_lst.emplace_back(col_R, R_tmp[col_R]);
Status of library operation execution.
Definition: cpu_mxm.hpp:46
~Algo_mxm_cpu() override=default
std::string get_name() override
Definition: cpu_mxm.hpp:50
Status execute(const DispatchContext &ctx) override
Definition: cpu_mxm.hpp:58
std::string get_description() override
Definition: cpu_mxm.hpp:54
CPU list-of-list matrix format for fast incremental build.
Definition: cpu_formats.hpp:107
std::pair< uint, T > Entry
Definition: cpu_formats.hpp:113
std::vector< Row > Ar
Definition: cpu_formats.hpp:117
Algorithm suitable to process schedule task based on task string key.
Definition: registry.hpp:66
std::uint32_t uint
Library index and size type.
Definition: config.hpp:56
Definition: algorithm.hpp:37
Execution context of a single task.
Definition: dispatcher.hpp:46
ref_ptr< ScheduleTask > task
Definition: dispatcher.hpp:48
#define TIME_PROFILE_SCOPE(name)
Definition: time_profiler.hpp:92