28 #ifndef SPLA_CL_FORMAT_COO_VEC_HPP
29 #define SPLA_CL_FORMAT_COO_VEC_HPP
53 storage.
Ai = cl::Buffer();
54 storage.
Ax = cl::Buffer();
58 const std::size_t buffer_size_Ai = n_values *
sizeof(
uint);
59 const std::size_t buffer_size_Ax = n_values *
sizeof(T);
60 const auto flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS | CL_MEM_COPY_HOST_PTR;
62 cl::Buffer buffer_Ai(get_acc_cl()->get_context(), flags, buffer_size_Ai, (
void*) Ai);
63 cl::Buffer buffer_Ax(get_acc_cl()->get_context(), flags, buffer_size_Ax, (
void*) Ax);
65 storage.
Ai = std::move(buffer_Ai);
66 storage.
Ax = std::move(buffer_Ax);
78 storage.
Ai = cl::Buffer();
79 storage.
Ax = cl::Buffer();
83 const std::size_t buffer_size_Ai = n_values *
sizeof(
uint);
84 const std::size_t buffer_size_Ax = n_values *
sizeof(T);
85 const auto flags = CL_MEM_READ_WRITE | CL_MEM_HOST_NO_ACCESS;
87 cl::Buffer buffer_Ai(get_acc_cl()->get_context(), flags, buffer_size_Ai);
88 cl::Buffer buffer_Ax(get_acc_cl()->get_context(), flags, buffer_size_Ax);
90 storage.
Ai = std::move(buffer_Ai);
91 storage.
Ax = std::move(buffer_Ax);
97 storage.
Ai = cl::Buffer();
98 storage.
Ax = cl::Buffer();
107 cl::CommandQueue& queue,
108 cl_mem_flags staging_flags = CL_MEM_READ_ONLY | CL_MEM_HOST_READ_ONLY | CL_MEM_ALLOC_HOST_PTR,
109 bool blocking =
true) {
115 const std::size_t buffer_size_Ai = n_values *
sizeof(
uint);
116 const std::size_t buffer_size_Ax = n_values *
sizeof(T);
118 cl::Buffer staging_Ai(get_acc_cl()->get_context(), staging_flags, buffer_size_Ai);
119 cl::Buffer staging_Ax(get_acc_cl()->get_context(), staging_flags, buffer_size_Ax);
121 queue.enqueueCopyBuffer(storage.
Ai, staging_Ai, 0, 0, buffer_size_Ai);
122 queue.enqueueCopyBuffer(storage.
Ax, staging_Ax, 0, 0, buffer_size_Ax);
123 queue.enqueueReadBuffer(staging_Ai, blocking, 0, buffer_size_Ai, Ai);
124 queue.enqueueReadBuffer(staging_Ax, blocking, 0, buffer_size_Ax, Ax);
132 cl::CommandQueue& queue) {
135 .
add_type(
"TYPE", get_ttype<T>().
template as<Type>())
139 cl_fill_value<T>(queue, out.
Ax, n_rows, fill_value);
146 auto* acc = get_acc_cl();
148 uint block_size = acc->get_default_wgs();
151 auto kernel = builder.
make_kernel(
"sparse_to_dense");
152 kernel.setArg(0, in.
Ai);
153 kernel.setArg(1, in.
Ax);
154 kernel.setArg(2, out.
Ax);
157 cl::NDRange global(block_size * n_groups_to_dispatch);
158 cl::NDRange local(block_size);
159 queue.enqueueNDRangeKernel(kernel, cl::NDRange(), global, local);
#define CL_FINISH(queue)
Definition: cl_debug.hpp:34
OpenCL list-of-coordinates sparse vector representation.
Definition: cl_formats.hpp:77
cl::Buffer Ax
Definition: cl_formats.hpp:84
cl::Buffer Ai
Definition: cl_formats.hpp:83
OpenCL one-dim array for dense vector representation.
Definition: cl_formats.hpp:61
cl::Buffer Ax
Definition: cl_formats.hpp:67
Runtime opencl program builder.
Definition: cl_program_builder.hpp:55
CLProgramBuilder & set_name(const char *name)
Definition: cl_program_builder.cpp:37
CLProgramBuilder & add_type(const char *alias, const ref_ptr< Type > &type)
Definition: cl_program_builder.cpp:45
cl::Kernel make_kernel(const char *name)
Definition: cl_program_builder.hpp:67
CLProgramBuilder & set_source(const char *source)
Definition: cl_program_builder.cpp:61
void acquire()
Definition: cl_program_builder.cpp:65
uint values
Definition: tdecoration.hpp:58
void cl_coo_vec_read(const std::size_t n_values, uint *Ai, T *Ax, const CLCooVec< T > &storage, cl::CommandQueue &queue, cl_mem_flags staging_flags=CL_MEM_READ_ONLY|CL_MEM_HOST_READ_ONLY|CL_MEM_ALLOC_HOST_PTR, bool blocking=true)
Definition: cl_format_coo_vec.hpp:103
void cl_coo_vec_to_dense(const std::size_t n_rows, const T fill_value, const CLCooVec< T > &in, CLDenseVec< T > &out, cl::CommandQueue &queue)
Definition: cl_format_coo_vec.hpp:128
void cl_coo_vec_resize(const std::size_t n_values, CLCooVec< T > &storage)
Definition: cl_format_coo_vec.hpp:72
void cl_coo_vec_clear(CLCooVec< T > &storage)
Definition: cl_format_coo_vec.hpp:96
void cl_coo_vec_init(const std::size_t n_values, const uint *Ai, const T *Ax, CLCooVec< T > &storage)
Definition: cl_format_coo_vec.hpp:45
std::uint32_t uint
Library index and size type.
Definition: config.hpp:56
#define LOG_MSG(status, msg)
Definition: logger.hpp:66
Definition: algorithm.hpp:37
T min(T a, T b)
Definition: op.cpp:152
T max(T a, T b)
Definition: op.cpp:155