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(
" "); source.append(numeric_string); source.append(
" alpha, \n");
51 source.append(
" __global "); source.append(numeric_string); source.append(
" * result, \n");
52 source.append(
" uint4 layout_result, \n");
53 source.append(
" "); source.append(numeric_string); source.append(
" beta) \n");
54 source.append(
"{ \n");
55 source.append(
" for (unsigned int i = get_global_id(0); i < nonzero_rows; i += get_global_size(0)) \n");
56 source.append(
" { \n");
57 source.append(
" "); source.append(numeric_string); source.append(
" dot_prod = 0; \n");
58 source.append(
" unsigned int row_end = row_jumper[i+1]; \n");
59 source.append(
" for (unsigned int j = row_jumper[i]; j < row_end; ++j) \n");
60 source.append(
" dot_prod += elements[j] * x[column_indices[j] * layout_x.y + layout_x.x]; \n");
62 source.append(
" if (beta != 0) result[row_indices[i] * layout_result.y + layout_result.x] += alpha * dot_prod; \n");
63 source.append(
" else result[row_indices[i] * layout_result.y + layout_result.x] = alpha * dot_prod; \n");
64 source.append(
" } \n");
65 source.append(
" } \n");
71 template<
typename NumericT>
81 static std::map<cl_context, bool> init_done;
90 viennacl::ocl::append_double_precision_pragma<NumericT>(ctx, source);
96 #ifdef VIENNACL_BUILD_INFO
97 std::cout <<
"Creating program " << prog_name << std::endl;
99 ctx.add_program(source, prog_name);
100 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)
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. ...