28 #ifndef SPLA_CPU_V_ASSIGN_HPP
29 #define SPLA_CPU_V_ASSIGN_HPP
48 return "v_assign_masked";
52 return "sequential masked vector assignment";
56 auto t = ctx.
task.template cast_safe<ScheduleTask_v_assign_masked>();
60 return execute_sp2dn(ctx);
62 return execute_dn2dn(ctx);
64 return execute_sp2dn(ctx);
71 auto t = ctx.
task.template cast_safe<ScheduleTask_v_assign_masked>();
73 auto r = t->r.template cast_safe<TVector<T>>();
74 auto mask = t->mask.template cast_safe<TVector<T>>();
75 auto value = t->value.template cast_safe<TScalar<T>>();
76 auto op_assign = t->op_assign.template cast_safe<TOpBinary<T, T, T>>();
77 auto op_select = t->op_select.template cast_safe<TOpSelect<T>>();
79 auto assign_value = value->get_value();
84 auto* p_r_dense = r->template get<CpuDenseVec<T>>();
85 const auto* p_mask_sparse = mask->template get<CpuCooVec<T>>();
86 const auto& func_assign = op_assign->function;
87 const auto& func_select = op_select->function;
89 uint N = p_mask_sparse->values;
91 for (
uint idx = 0; idx < N; ++idx) {
92 uint i = p_mask_sparse->Ai[idx];
93 auto x = p_mask_sparse->Ax[idx];
95 p_r_dense->Ax[i] = func_assign(p_r_dense->Ax[i], assign_value);
102 Status execute_dn2dn(
const DispatchContext& ctx) {
105 auto t = ctx.task.template cast_safe<ScheduleTask_v_assign_masked>();
107 auto r = t->r.template cast_safe<TVector<T>>();
108 auto mask = t->mask.template cast_safe<TVector<T>>();
109 auto value = t->value.template cast_safe<TScalar<T>>();
110 auto op_assign = t->op_assign.template cast_safe<TOpBinary<T, T, T>>();
111 auto op_select = t->op_select.template cast_safe<TOpSelect<T>>();
113 auto assign_value = value->get_value();
118 auto* p_r_dense = r->template get<CpuDenseVec<T>>();
119 const auto* p_mask_dense = mask->template get<CpuDenseVec<T>>();
120 const auto& func_assign = op_assign->function;
121 const auto& func_select = op_select->function;
123 uint N = r->get_n_rows();
125 for (
uint i = 0; i < N; ++i) {
126 if (func_select(p_mask_dense->Ax[i])) {
127 p_r_dense->Ax[i] = func_assign(p_r_dense->Ax[i], assign_value);
Status of library operation execution.
Definition: cpu_v_assign.hpp:43
std::string get_name() override
Definition: cpu_v_assign.hpp:47
~Algo_v_assign_masked_cpu() override=default
Status execute(const DispatchContext &ctx) override
Definition: cpu_v_assign.hpp:55
std::string get_description() override
Definition: cpu_v_assign.hpp:51
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
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