PARALUTION  1.0.0
PARALUTION
ocl_kernels_hyb.hpp
Go to the documentation of this file.
1 #ifndef PARALUTION_OCL_KERNELS_HYB_HPP_
2 #define PARALUTION_OCL_KERNELS_HYB_HPP_
3 
4 namespace paralution {
5 
6 const char *ocl_kernels_hyb =
7  "__kernel void kernel_ell_nnz_coo(const int nrow, const int max_row,\n"
8  " __global const int *row_offset, __global int *nnz_coo) {\n"
9  "\n"
10  " int gid = get_global_id(0);\n"
11  "\n"
12  " if (gid < nrow) {\n"
13  "\n"
14  " nnz_coo[gid] = 0;\n"
15  " int nnz_per_row = row_offset[gid+1] - row_offset[gid];\n"
16  "\n"
17  " if (nnz_per_row > max_row)\n"
18  " nnz_coo[gid] = nnz_per_row - max_row;\n"
19  "\n"
20  " }\n"
21  "\n"
22  "}\n"
23  "\n"
24  "__kernel void kernel_ell_fill_ell(const int nrow, const int max_row,\n"
25  " __global const int *row_offset, __global const int *col,\n"
26  " __global const ValueType *val, __global int *ELL_col,\n"
27  " __global ValueType *ELL_val, __global int *nnz_ell) {\n"
28  "\n"
29  " int gid = get_global_id(0);\n"
30  "\n"
31  " if (gid < nrow) {\n"
32  "\n"
33  " int n = 0;\n"
34  "\n"
35  " for (int i=row_offset[gid]; i<row_offset[gid+1]; ++i) {\n"
36  "\n"
37  " if (n >= max_row) break;\n"
38  "\n"
39  " int idx = n * nrow + gid;\n"
40  "\n"
41  " ELL_col[idx] = col[i];\n"
42  " ELL_val[idx] = val[i];\n"
43  "\n"
44  " ++n;\n"
45  "\n"
46  " }\n"
47  "\n"
48  " nnz_ell[gid] = n;\n"
49  "\n"
50  " }\n"
51  "\n"
52  "}\n"
53  "\n"
54  "__kernel void kernel_ell_fill_coo(const int nrow, __global const int *row_offset,\n"
55  " __global const int *col, __global const ValueType *val,\n"
56  " __global const int *nnz_coo, __global const int *nnz_ell,\n"
57  " __global int *COO_row, __global int *COO_col, __global ValueType *COO_val) {\n"
58  "\n"
59  " int gid = get_global_id(0);\n"
60  "\n"
61  " if (gid < nrow) {\n"
62  "\n"
63  " int row_ptr = row_offset[gid+1];\n"
64  "\n"
65  " for (int i=row_ptr - nnz_coo[gid]; i<row_ptr; ++i) {\n"
66  "\n"
67  " int idx = i - nnz_ell[gid];\n"
68  "\n"
69  " COO_row[idx] = gid;\n"
70  " COO_col[idx] = col[i];\n"
71  " COO_val[idx] = val[i];\n"
72  "\n"
73  " }\n"
74  "\n"
75  " }\n"
76  "\n"
77  "}\n"
78  "\n"
79 ;
80 }
81 
82 #endif // PARALUTION_OCL_KERNELS_HYB_HPP_
const char * ocl_kernels_hyb
Definition: ocl_kernels_hyb.hpp:6
Definition: backend_manager.cpp:43