1 #ifndef VIENNACL_LINALG_OPENCL_KERNELS_COMPRESSED_COMPRESSED_MATRIX_HPP
2 #define VIENNACL_LINALG_OPENCL_KERNELS_COMPRESSED_COMPRESSED_MATRIX_HPP
22 template<
typename StringT>
25 source.append(
"__kernel void vec_mul( \n");
26 source.append(
" __global const unsigned int * row_jumper, \n");
27 source.append(
" __global const unsigned int * row_indices, \n");
28 source.append(
" __global const unsigned int * column_indices, \n");
29 source.append(
" __global const "); source.append(numeric_string); source.append(
" * elements, \n");
30 source.append(
" uint nonzero_rows, \n");
31 source.append(
" __global const "); source.append(numeric_string); source.append(
" * x, \n");
32 source.append(
" uint4 layout_x, \n");
33 source.append(
" __global "); source.append(numeric_string); source.append(
" * result, \n");
34 source.append(
" uint4 layout_result) \n");
35 source.append(
"{ \n");
36 source.append(
" for (unsigned int i = get_global_id(0); i < nonzero_rows; i += get_global_size(0)) \n");
37 source.append(
" { \n");
38 source.append(
" "); source.append(numeric_string); source.append(
" dot_prod = 0; \n");
39 source.append(
" unsigned int row_end = row_jumper[i+1]; \n");
40 source.append(
" for (unsigned int j = row_jumper[i]; j < row_end; ++j) \n");
41 source.append(
" dot_prod += elements[j] * x[column_indices[j] * layout_x.y + layout_x.x]; \n");
42 source.append(
" result[row_indices[i] * layout_result.y + layout_result.x] = dot_prod; \n");
43 source.append(
" } \n");
44 source.append(
" } \n");
50 template<
typename NumericT>
60 static std::map<cl_context, bool> init_done;
69 viennacl::ocl::append_double_precision_pragma<NumericT>(ctx, source);
75 #ifdef VIENNACL_BUILD_INFO
76 std::cout <<
"Creating program " << prog_name << std::endl;
78 ctx.add_program(source, prog_name);
79 init_done[ctx.handle().get()] =
true;
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Provides OpenCL-related utilities.
static std::string program_name()
const viennacl::ocl::handle< cl_context > & handle() const
Returns the context handle.
void generate_vec_mul(StringT &source, std::string const &numeric_string)
Main namespace in ViennaCL. Holds all the basic types such as vector, matrix, etc. and defines operations upon them.
static void apply(viennacl::ocl::context const &)
const OCL_TYPE & get() const
static void init(viennacl::ocl::context &ctx)
Representation of an OpenCL kernel in ViennaCL.
Helper class for converting a type to its string representation.
Main kernel class for generating OpenCL kernels for compressed_compressed_matrix. ...