Stan Math Library  2.20.0
reverse mode automatic differentiation
helpers.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_OPENCL_KERNELS_HELPERS_HPP
2 #define STAN_MATH_OPENCL_KERNELS_HELPERS_HPP
3 #ifdef STAN_OPENCL
4 
5 #include <string>
6 
7 namespace stan {
8 namespace math {
9 namespace opencl_kernels {
10 
11 /*
12  * Defines helper macros for common matrix indexing operations
13  */
14 static const char* indexing_helpers =
15  R"(
16  // Matrix access helpers
17  #ifndef A_batch
18  #define A_batch(i,j,k) A[(k) * cols * rows + (j) * rows + (i)]
19  #endif
20  #ifndef A
21  #define A(i,j) A[(j) * rows + (i)]
22  #endif
23  #ifndef B
24  #define B(i,j) B[(j) * rows + (i)]
25  #endif
26  #ifndef C
27  #define C(i,j) C[(j) * rows + (i)]
28  #endif
29  // Transpose
30  #ifndef BT
31  #define BT(i,j) B[(j) * cols + (i)]
32  #endif
33  #ifndef AT
34  #define AT(i,j) A[(j) * cols + (i)]
35  #endif
36  // Moving between two buffers
37  #ifndef src
38  #define src(i,j) src[(j) * src_rows + (i)]
39  #endif
40  #ifndef dst
41  #define dst(i,j) dst[(j) * dst_rows + (i)]
42  #endif
43  )";
44 
45 /*
46  * Defines a helper macro for kernels with 2D local size
47  */
48 static const char* thread_block_helpers =
49  R"(
50  // The local memory column for each thread block
51  #define THREAD_BLOCK_SIZE_COL THREAD_BLOCK_SIZE/WORK_PER_THREAD
52  )";
53 } // namespace opencl_kernels
54 } // namespace math
55 } // namespace stan
56 #endif
57 #endif
static const char * indexing_helpers
Definition: helpers.hpp:14
static const char * thread_block_helpers
Definition: helpers.hpp:48

     [ Stan Home Page ] © 2011–2018, Stan Development Team.