1 #ifndef VIENNACL_LINALG_OPENCL_KERNELS_COMPRESSED_COMPRESSED_MATRIX_HPP
2 #define VIENNACL_LINALG_OPENCL_KERNELS_COMPRESSED_COMPRESSED_MATRIX_HPP
39 template<
typename StringT>
42 source.append(
"__kernel void vec_mul( \n");
43 source.append(
" __global const unsigned int * row_jumper, \n");
44 source.append(
" __global const unsigned int * row_indices, \n");
45 source.append(
" __global const unsigned int * column_indices, \n");
46 source.append(
" __global const "); source.append(numeric_string); source.append(
" * elements, \n");
47 source.append(
" uint nonzero_rows, \n");
48 source.append(
" __global const "); source.append(numeric_string); source.append(
" * x, \n");
49 source.append(
" uint4 layout_x, \n");
50 source.append(
" __global "); source.append(numeric_string); source.append(
" * result, \n");
51 source.append(
" uint4 layout_result) \n");
52 source.append(
"{ \n");
53 source.append(
" for (unsigned int i = get_global_id(0); i < nonzero_rows; i += get_global_size(0)) \n");
54 source.append(
" { \n");
55 source.append(
" "); source.append(numeric_string); source.append(
" dot_prod = 0; \n");
56 source.append(
" unsigned int row_end = row_jumper[i+1]; \n");
57 source.append(
" for (unsigned int j = row_jumper[i]; j < row_end; ++j) \n");
58 source.append(
" dot_prod += elements[j] * x[column_indices[j] * layout_x.y + layout_x.x]; \n");
59 source.append(
" result[row_indices[i] * layout_result.y + layout_result.x] = dot_prod; \n");
60 source.append(
" } \n");
61 source.append(
" } \n");
67 template<
typename NumericT>
77 static std::map<cl_context, bool> init_done;
86 viennacl::ocl::append_double_precision_pragma<NumericT>(ctx, source);
92 #ifdef VIENNACL_BUILD_INFO
93 std::cout <<
"Creating program " << prog_name << std::endl;
95 ctx.add_program(source, prog_name);
96 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. ...