Stan Math Library  2.20.0
reverse mode automatic differentiation
sub_block.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_OPENCL_KERNELS_SUB_BLOCK_HPP
2 #define STAN_MATH_OPENCL_KERNELS_SUB_BLOCK_HPP
3 #ifdef STAN_OPENCL
4 
7 #include <vector>
8 
9 namespace stan {
10 namespace math {
11 namespace opencl_kernels {
12 // \cond
13 static const char *sub_block_kernel_code = STRINGIFY(
14  // \endcond
44  __kernel void sub_block(
45  __global double *src, __global double *dst, unsigned int src_offset_i,
46  unsigned int src_offset_j, unsigned int dst_offset_i,
47  unsigned int dst_offset_j, unsigned int size_i, unsigned int size_j,
48  unsigned int src_rows, unsigned int src_cols, unsigned int dst_rows,
49  unsigned int dst_cols, unsigned int triangular_view) {
50  int i = get_global_id(0);
51  int j = get_global_id(1);
52  if ((i + src_offset_i) < src_rows && (j + src_offset_j) < src_cols
53  && (i + dst_offset_i) < dst_rows && (j + dst_offset_j) < dst_cols) {
54  if ((triangular_view == LOWER && i >= j)
55  || (triangular_view == UPPER && i <= j)
56  || triangular_view == ENTIRE) {
57  dst((dst_offset_i + i), (dst_offset_j + j))
58  = src((src_offset_i + i), (src_offset_j + j));
59  }
60  }
61  }
62  // \cond
63 );
64 // \endcond
65 
69 const kernel_cl<in_buffer, out_buffer, int, int, int, int, int, int, int, int,
70  int, int, TriangularViewCL>
71  sub_block("sub_block", {indexing_helpers, sub_block_kernel_code});
72 
73 } // namespace opencl_kernels
74 } // namespace math
75 } // namespace stan
76 #endif
77 #endif
#define STRINGIFY(src)
Definition: kernel_cl.hpp:22
static const char * indexing_helpers
Definition: helpers.hpp:14
const kernel_cl< in_buffer, out_buffer, int, int, int, int, int, int, int, int, int, int, TriangularViewCL > sub_block("sub_block", {indexing_helpers, sub_block_kernel_code})
See the docs for sub_block() .
Creates functor for kernels.
Definition: kernel_cl.hpp:201

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