1 #ifndef STAN_MATH_OPENCL_SUB_BLOCK_HPP 2 #define STAN_MATH_OPENCL_SUB_BLOCK_HPP 27 template <TriangularViewCL triangular_view>
29 size_t this_i,
size_t this_j,
size_t nrows,
31 if (nrows == 0 || ncols == 0) {
34 if ((A_i + nrows) > A.
rows() || (A_j + ncols) > A.
cols()
35 || (this_i + nrows) > this->
rows() || (this_j + ncols) > this->
cols()) {
36 domain_error(
"sub_block",
"submatrix in *this",
" is out of bounds",
"");
40 cl::size_t<3> src_offset
41 = opencl::to_size_t<3>({A_i *
sizeof(double), A_j, 0});
42 cl::size_t<3> dst_offset
43 = opencl::to_size_t<3>({this_i *
sizeof(double), this_j, 0});
45 = opencl::to_size_t<3>({nrows *
sizeof(double), ncols, 1});
46 std::vector<cl::Event> kernel_events
49 cmdQueue.enqueueCopyBufferRect(A.
buffer(), this->
buffer(), src_offset,
50 dst_offset,
size, A.
rows() *
sizeof(double),
51 A.
rows() * A.
cols() *
sizeof(double),
52 sizeof(
double) * this->
rows(),
53 this->
rows() * this->
cols() *
sizeof(double),
54 &kernel_events, ©_event);
59 this_i, this_j, nrows, ncols, A.
rows(), A.
cols(),
60 this->
rows(), this->
cols(), triangular_view);
62 }
catch (
const cl::Error&
e) {
const std::vector< T > & vec_concat(const std::vector< T > &v1)
Ends the recursion to extract the event stack.
const cl::Buffer & buffer() const
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() .
The API to access the methods and values in opencl_context_base.
The matrix_cl class - allocates memory space on the OpenCL device, functions for transfering matrices...
void add_write_event(cl::Event new_event) const
Add an event to the write event stack.
void add_read_event(cl::Event new_event) const
Add an event to the read event stack.
void sub_block(const matrix_cl &A, size_t A_i, size_t A_j, size_t this_i, size_t this_j, size_t nrows, size_t ncols)
Write the contents of A into this starting at the top left of this
Represents a matrix on the OpenCL device.
Initialization for OpenCL:
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
const std::vector< cl::Event > read_write_events() const
Get the events from the event stacks.
double e()
Return the base of the natural logarithm.
void check_opencl_error(const char *function, const cl::Error &e)
Throws the domain error with specifying the OpenCL error that occured.
const std::vector< cl::Event > & write_events() const
Get the events from the event stacks.
cl::CommandQueue & queue()
Returns the reference to the active OpenCL command queue for the device.