1 #ifndef VIENNACL_LINALG_OPENCL_KERNELS_ILU_HPP
2 #define VIENNACL_LINALG_OPENCL_KERNELS_ILU_HPP
19 template<
typename StringT>
22 source.append(
"__kernel void level_scheduling_substitute( \n");
23 source.append(
" __global const unsigned int * row_index_array, \n");
24 source.append(
" __global const unsigned int * row_indices, \n");
25 source.append(
" __global const unsigned int * column_indices, \n");
26 source.append(
" __global const "); source.append(numeric_string); source.append(
" * elements, \n");
27 source.append(
" __global "); source.append(numeric_string); source.append(
" * vec, \n");
28 source.append(
" unsigned int size) \n");
29 source.append(
"{ \n");
30 source.append(
" for (unsigned int row = get_global_id(0); \n");
31 source.append(
" row < size; \n");
32 source.append(
" row += get_global_size(0)) \n");
33 source.append(
" { \n");
34 source.append(
" unsigned int eq_row = row_index_array[row]; \n");
35 source.append(
" "); source.append(numeric_string); source.append(
" vec_entry = vec[eq_row]; \n");
36 source.append(
" unsigned int row_end = row_indices[row+1]; \n");
38 source.append(
" for (unsigned int j = row_indices[row]; j < row_end; ++j) \n");
39 source.append(
" vec_entry -= vec[column_indices[j]] * elements[j]; \n");
41 source.append(
" vec[eq_row] = vec_entry; \n");
42 source.append(
" } \n");
43 source.append(
"} \n");
48 template<
class NumericT>
58 static std::map<cl_context, bool> init_done;
67 viennacl::ocl::append_double_precision_pragma<NumericT>(ctx, source);
70 if (numeric_string ==
"float" || numeric_string ==
"double")
76 #ifdef VIENNACL_BUILD_INFO
77 std::cout <<
"Creating program " << prog_name << std::endl;
79 ctx.add_program(source, prog_name);
80 init_done[ctx.handle().get()] =
true;
void generate_ilu_level_scheduling_substitute(StringT &source, std::string const &numeric_string)
Manages an OpenCL context and provides the respective convenience functions for creating buffers...
Provides OpenCL-related utilities.
const viennacl::ocl::handle< cl_context > & handle() const
Returns the context handle.
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
Main kernel class for generating OpenCL kernels for incomplete LU factorization preconditioners.
static void init(viennacl::ocl::context &ctx)
Representation of an OpenCL kernel in ViennaCL.
Helper class for converting a type to its string representation.
static std::string program_name()