PARALUTION  1.0.0
PARALUTION
ocl_kernels_dense.hpp
Go to the documentation of this file.
1 #ifndef PARALUTION_OCL_KERNELS_DENSE_HPP_
2 #define PARALUTION_OCL_KERNELS_DENSE_HPP_
3 
4 namespace paralution {
5 
6 const char *ocl_kernels_dense =
7  "__kernel void kernel_dense_spmv(const int nrow, const int ncol, __global const ValueType *val,\n"
8  " __global const ValueType *in, __global ValueType *out) {\n"
9  "\n"
10  " int ai = get_global_id(0);\n"
11  "\n"
12  " if (ai < nrow) {\n"
13  "\n"
14  " ValueType sum = (ValueType)(0.0);\n"
15  "\n"
16  " for (int aj=0; aj<ncol; ++aj)\n"
17  " sum += val[ai+aj*nrow] * in[aj];\n"
18  "\n"
19  " out[ai] = sum;\n"
20  "\n"
21  " }\n"
22  "\n"
23  "}\n"
24  "\n"
25 // Replace column vector
26  "__kernel void kernel_dense_replace_column_vector(__global const ValueType *vec, const int idx, const int nrow,\n"
27  " __global ValueType *mat) {\n"
28  "\n"
29  " int ai = get_global_id(0);\n"
30  "\n"
31  " if(ai < nrow)\n"
32  " mat[ai+idx*nrow] = vec[ai];\n"
33  "\n"
34  "}\n"
35  "\n"
36 // Replace row vector
37  "__kernel void kernel_dense_replace_row_vector(__global const ValueType *vec, const int idx, const int nrow,\n"
38  " const int ncol, __global ValueType *mat) {\n"
39  "\n"
40  " int aj = get_global_id(0);\n"
41  "\n"
42  " if (aj < ncol)\n"
43  " mat[idx+aj*nrow] = vec[aj];\n"
44  "\n"
45  "}\n"
46  "\n"
47 // Extract column vector
48  "__kernel void kernel_dense_extract_column_vector(__global ValueType *vec, const int idx, const int nrow,\n"
49  " __global const ValueType *mat) {\n"
50  "\n"
51  " int ai = get_global_id(0);\n"
52  "\n"
53  " if (ai < nrow)\n"
54  " vec[ai] = mat[ai+idx*nrow];\n"
55  "\n"
56  "}\n"
57  "\n"
58 // Extract row vector
59  "__kernel void kernel_dense_extract_row_vector(__global ValueType *vec, const int idx, const int nrow,\n"
60  " const int ncol, __global const ValueType *mat) {\n"
61  "\n"
62  " int aj = get_global_id(0);\n"
63  "\n"
64  " if (aj < ncol)\n"
65  " vec[aj] = mat[idx+aj*nrow];\n"
66  "\n"
67  "}\n"
68  "\n"
69 ;
70 }
71 
72 #endif // PARALUTION_OCL_KERNELS_DENSE_HPP_
const char * ocl_kernels_dense
Definition: ocl_kernels_dense.hpp:6
Definition: backend_manager.cpp:43