52 return "sequential vector reduction on cpu";
56 auto t = ctx.
task.template cast_safe<ScheduleTask_v_reduce>();
60 return execute_sp(ctx);
63 return execute_dn(ctx);
66 return execute_sp(ctx);
73 auto t = ctx.
task.template cast_safe<ScheduleTask_v_reduce>();
75 auto r = t->r.template cast_safe<TScalar<T>>();
76 auto s = t->s.template cast_safe<TScalar<T>>();
77 auto v = t->v.template cast_safe<TVector<T>>();
78 auto op_reduce = t->op_reduce.template cast_safe<TOpBinary<T, T, T>>();
80 T sum = s->get_value();
83 const auto* p_sparse = v->template get<CpuCooVec<T>>();
84 const auto& function = op_reduce->function;
86 for (
const auto& value : p_sparse->Ax) {
87 sum = function(sum, value);
95 Status execute_dn(
const DispatchContext& ctx) {
98 auto t = ctx.task.template cast_safe<ScheduleTask_v_reduce>();
100 auto r = t->r.template cast_safe<TScalar<T>>();
101 auto s = t->s.template cast_safe<TScalar<T>>();
102 auto v = t->v.template cast_safe<TVector<T>>();
103 auto op_reduce = t->op_reduce.template cast_safe<TOpBinary<T, T, T>>();
105 T sum = s->get_value();
108 const auto* p_dense = v->template get<CpuDenseVec<T>>();
109 const auto& function = op_reduce->function;
111 for (
const auto& value : p_dense->Ax) {
112 sum = function(sum, value);
115 r->get_value() = sum;
Execution context of a single task.
Definition dispatcher.hpp:46
ref_ptr< ScheduleTask > task
Definition dispatcher.hpp:48