54 return "sequential vector map on cpu";
58 auto t = ctx.
task.template cast_safe<ScheduleTask_v_map>();
62 return execute_sp(ctx);
65 return execute_dn(ctx);
68 return execute_sp(ctx);
75 auto t = ctx.
task.template cast_safe<ScheduleTask_v_map>();
77 auto r = t->r.template cast_safe<TVector<T>>();
78 auto v = t->v.template cast_safe<TVector<T>>();
79 auto op = t->op.template cast_safe<TOpUnary<T, T>>();
83 auto* p_sparse_r = r->template get<CpuCooVec<T>>();
84 const auto* p_sparse_v = v->template get<CpuCooVec<T>>();
85 const auto& function = op->function;
87 const uint N = p_sparse_v->values;
91 std::memcpy(p_sparse_r->Ai.data(), p_sparse_v->Ai.data(),
sizeof(
uint) * N);
93 for (
uint i = 0; i < N; i += 1) {
94 p_sparse_r->Ax[i] = function(p_sparse_v->Ax[i]);
101 Status execute_dn(
const DispatchContext& ctx) {
104 auto t = ctx.task.template cast_safe<ScheduleTask_v_map>();
106 auto r = t->r.template cast_safe<TVector<T>>();
107 auto v = t->v.template cast_safe<TVector<T>>();
108 auto op = t->op.template cast_safe<TOpUnary<T, T>>();
112 auto* p_dense_r = r->template get<CpuDenseVec<T>>();
113 const auto* p_dense_v = v->template get<CpuDenseVec<T>>();
114 const auto& function = op->function;
116 const uint N = r->get_n_rows();
118 for (
uint i = 0; i < N; i += 1) {
119 p_dense_r->Ax[i] = function(p_dense_v->Ax[i]);
Execution context of a single task.
Definition dispatcher.hpp:46
ref_ptr< ScheduleTask > task
Definition dispatcher.hpp:48