28 #ifndef SPLA_CPU_MXMT_MASKED_HPP
29 #define SPLA_CPU_MXMT_MASKED_HPP
53 return "sequential masked matrix matrix-transposed product on cpu";
59 auto t = ctx.
task.template cast_safe<ScheduleTask_mxmT_masked>();
61 auto R = t->R.template cast_safe<TMatrix<T>>();
62 auto mask = t->mask.template cast_safe<TMatrix<T>>();
63 auto A = t->A.template cast_safe<TMatrix<T>>();
64 auto B = t->B.template cast_safe<TMatrix<T>>();
65 auto op_multiply = t->op_multiply.template cast_safe<TOpBinary<T, T, T>>();
66 auto op_add = t->op_add.template cast_safe<TOpBinary<T, T, T>>();
67 auto op_select = t->op_select.template cast_safe<TOpSelect<T>>();
68 auto init = t->init.template cast_safe<TScalar<T>>();
75 CpuLil<T>* p_lil_R = R->template get<CpuLil<T>>();
76 const CpuLil<T>* p_lil_A = A->template get<CpuLil<T>>();
77 const CpuLil<T>* p_lil_B = B->template get<CpuLil<T>>();
78 const CpuLil<T>* p_lil_mask = mask->template get<CpuLil<T>>();
80 auto& func_multiply = op_multiply->function;
81 auto& func_add = op_add->function;
82 auto& func_select = op_select->function;
84 auto DM = R->get_n_rows();
85 auto I = init->get_value();
87 for (
uint row_R = 0; row_R < DM; row_R++) {
88 const auto& mask_lst = p_lil_mask->
Ar[row_R];
89 const auto& A_lst = p_lil_A->Ar[row_R];
90 auto& R_lst = p_lil_R->
Ar[row_R];
92 assert(R_lst.empty());
95 const uint mask_i = entry_mask.first;
96 const T mask_x = entry_mask.second;
100 if (func_select(mask_x)) {
101 const auto& B_lst = p_lil_B->Ar[mask_i];
103 auto A_it = A_lst.begin();
104 auto B_it = B_lst.begin();
105 const auto A_end = A_lst.end();
106 const auto B_end = B_lst.end();
108 while (A_it != A_end && B_it != B_end) {
109 if (A_it->first == B_it->first) {
110 r = func_add(r, func_multiply(A_it->second, B_it->second));
113 }
else if (A_it->first < B_it->first) {
122 R_lst.emplace_back(mask_i, r);
Status of library operation execution.
Definition: cpu_mxmT_masked.hpp:44
~Algo_mxmT_masked_cpu() override=default
std::string get_name() override
Definition: cpu_mxmT_masked.hpp:48
std::string get_description() override
Definition: cpu_mxmT_masked.hpp:52
Status execute(const DispatchContext &ctx) override
Definition: cpu_mxmT_masked.hpp:56
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