28 #ifndef SPLA_CPU_V_REDUCE_HPP
29 #define SPLA_CPU_V_REDUCE_HPP
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;
Status of library operation execution.
Definition: cpu_v_reduce.hpp:43
std::string get_description() override
Definition: cpu_v_reduce.hpp:51
std::string get_name() override
Definition: cpu_v_reduce.hpp:47
Status execute(const DispatchContext &ctx) override
Definition: cpu_v_reduce.hpp:55
~Algo_v_reduce_cpu() override=default
Algorithm suitable to process schedule task based on task string key.
Definition: registry.hpp:66
Automates reference counting and behaves as shared smart pointer.
Definition: ref.hpp:117
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