51 return "m_reduce_by_column";
55 return "reduce matrix by column on cpu sequentially";
59 auto t = ctx.
task.template cast_safe<ScheduleTask_m_reduce_by_column>();
60 auto M = t->M.template cast_safe<TMatrix<T>>();
63 return execute_lil(ctx);
66 return execute_dok(ctx);
69 return execute_dok(ctx);
74 auto t = ctx.
task.template cast_safe<ScheduleTask_m_reduce_by_column>();
75 auto r = t->r.template cast_safe<TVector<T>>();
76 auto M = t->M.template cast_safe<TMatrix<T>>();
77 auto op_reduce = t->op_reduce.template cast_safe<TOpBinary<T, T, T>>();
78 auto init = t->init.template cast_safe<TScalar<T>>();
84 const CpuDok<T>* p_dok_M = M->template get<CpuDok<T>>();
86 std::fill(p_dense_r->
Ax.begin(), p_dense_r->
Ax.end(), init->get_value());
88 auto& func_reduce = op_reduce->function;
90 for (
const auto& entry : p_dok_M->Ax) {
91 const uint j = entry.first.second;
92 const T x = entry.second;
94 p_dense_r->
Ax[j] = func_reduce(p_dense_r->
Ax[j], x);
99 Status execute_lil(
const DispatchContext& ctx) {
100 auto t = ctx.task.template cast_safe<ScheduleTask_m_reduce_by_column>();
101 auto r = t->r.template cast_safe<TVector<T>>();
102 auto M = t->M.template cast_safe<TMatrix<T>>();
103 auto op_reduce = t->op_reduce.template cast_safe<TOpBinary<T, T, T>>();
104 auto init = t->init.template cast_safe<TScalar<T>>();
109 CpuDenseVec<T>* p_dense_r = r->template get<CpuDenseVec<T>>();
110 const CpuLil<T>* p_lil_M = M->template get<CpuLil<T>>();
112 std::fill(p_dense_r->Ax.begin(), p_dense_r->Ax.end(), init->get_value());
114 auto& func_reduce = op_reduce->function;
116 for (std::size_t i = 0; i < p_lil_M->Ar.size(); i++) {
117 for (
const auto& entry : p_lil_M->Ar[i]) {
118 const uint j = entry.first;
119 const T x = entry.second;
121 p_dense_r->Ax[j] = func_reduce(p_dense_r->Ax[j], x);
Execution context of a single task.
Definition dispatcher.hpp:46
ref_ptr< ScheduleTask > task
Definition dispatcher.hpp:48