55 return "reduce matrix on cpu sequentially";
59 auto t = ctx.
task.template cast_safe<ScheduleTask_m_reduce>();
60 auto M = t->M.template cast_safe<TMatrix<T>>();
63 return execute_csr(ctx);
66 return execute_lil(ctx);
69 return execute_dok(ctx);
72 return execute_csr(ctx);
79 auto t = ctx.
task.template cast_safe<ScheduleTask_m_reduce>();
88 const CpuDok<T>* p_dok_M = M->template get<CpuDok<T>>();
89 auto& func_reduce = op_reduce->function;
91 T result = s->get_value();
93 for (
const auto& entry : p_dok_M->
Ax) {
94 result = func_reduce(result, entry.second);
97 r->get_value() = result;
102 Status execute_lil(
const DispatchContext& ctx) {
105 auto t = ctx.task.template cast_safe<ScheduleTask_m_reduce>();
107 ref_ptr<TScalar<T>> r = t->r.template cast_safe<TScalar<T>>();
108 ref_ptr<TScalar<T>> s = t->s.template cast_safe<TScalar<T>>();
109 ref_ptr<TMatrix<T>> M = t->M.template cast_safe<TMatrix<T>>();
110 ref_ptr<TOpBinary<T, T, T>> op_reduce = t->op_reduce.template cast_safe<TOpBinary<T, T, T>>();
114 const CpuLil<T>* p_lil_M = M->template get<CpuLil<T>>();
115 auto& func_reduce = op_reduce->function;
117 T result = s->get_value();
119 for (
const auto& row : p_lil_M->Ar) {
120 for (
const auto& entry : row) {
121 result = func_reduce(result, entry.second);
125 r->get_value() = result;
130 Status execute_csr(
const DispatchContext& ctx) {
133 auto t = ctx.task.template cast_safe<ScheduleTask_m_reduce>();
135 ref_ptr<TScalar<T>> r = t->r.template cast_safe<TScalar<T>>();
136 ref_ptr<TScalar<T>> s = t->s.template cast_safe<TScalar<T>>();
137 ref_ptr<TMatrix<T>> M = t->M.template cast_safe<TMatrix<T>>();
138 ref_ptr<TOpBinary<T, T, T>> op_reduce = t->op_reduce.template cast_safe<TOpBinary<T, T, T>>();
142 const CpuCsr<T>* p_csr_M = M->template get<CpuCsr<T>>();
143 auto& func_reduce = op_reduce->function;
145 T result = s->get_value();
147 for (
const auto v : p_csr_M->Ax) {
148 result = func_reduce(result, v);
151 r->get_value() = result;
Execution context of a single task.
Definition dispatcher.hpp:46
ref_ptr< ScheduleTask > task
Definition dispatcher.hpp:48