Stan Math Library  2.20.0
reverse mode automatic differentiation
add.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_OPENCL_ADD_HPP
2 #define STAN_MATH_OPENCL_ADD_HPP
3 #ifdef STAN_OPENCL
7 #include <CL/cl.hpp>
8 
9 namespace stan {
10 namespace math {
11 
24 inline matrix_cl add(const matrix_cl& A, const matrix_cl& B) {
25  check_matching_dims("add", "A", A, "B", B);
26  matrix_cl C(A.rows(), A.cols());
27  if (C.size() == 0) {
28  return C;
29  }
30  try {
31  opencl_kernels::add(cl::NDRange(A.rows(), A.cols()), C, A, B, A.rows(),
32  A.cols());
33  } catch (const cl::Error& e) {
34  check_opencl_error("add", e);
35  }
36  return C;
37 }
38 
51 inline auto operator+(const matrix_cl& A, const matrix_cl& B) {
52  return add(A, B);
53 }
54 } // namespace math
55 } // namespace stan
56 
57 #endif
58 #endif
const kernel_cl< out_buffer, in_buffer, in_buffer, int, int > add("add", {indexing_helpers, add_kernel_code})
See the docs for add() .
The matrix_cl class - allocates memory space on the OpenCL device, functions for transfering matrices...
void check_matching_dims(const char *function, const char *name1, const matrix_cl &y1, const char *name2, const matrix_cl &y2)
Check if two matrix_cls have the same dimensions.
Represents a matrix on the OpenCL device.
Definition: matrix_cl.hpp:29
fvar< T > operator+(const fvar< T > &x1, const fvar< T > &x2)
Return the sum of the specified forward mode addends.
double e()
Return the base of the natural logarithm.
Definition: constants.hpp:87
matrix_cl add(const matrix_cl &A, const matrix_cl &B)
Matrix addition on the OpenCL device.
Definition: add.hpp:24
void check_opencl_error(const char *function, const cl::Error &e)
Throws the domain error with specifying the OpenCL error that occured.

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