28 #ifndef SPLA_CPU_V_MAP_HPP
29 #define SPLA_CPU_V_MAP_HPP
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]);
Status of library operation execution.
Definition: cpu_v_map.hpp:45
~Algo_v_map_cpu() override=default
Status execute(const DispatchContext &ctx) override
Definition: cpu_v_map.hpp:57
std::string get_description() override
Definition: cpu_v_map.hpp:53
std::string get_name() override
Definition: cpu_v_map.hpp:49
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
void cpu_coo_vec_resize(const uint n_values, CpuCooVec< T > &vec)
Definition: cpu_format_coo_vec.hpp:61
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