Stan Math Library  2.20.0
reverse mode automatic differentiation
Public Member Functions | List of all members
stan::math::matrix_cl Class Reference

Represents a matrix on the OpenCL device. More...

#include <matrix_cl.hpp>

Public Member Functions

template<TriangularViewCL triangular_view = TriangularViewCL::Entire>
void zeros ()
 Stores zeros in the matrix on the OpenCL device. More...
 
template<TriangularMapCL triangular_map = TriangularMapCL::LowerToUpper>
void triangular_transpose ()
 Copies a lower/upper triangular of a matrix to it's upper/lower. More...
 
template<TriangularViewCL triangular_view = TriangularViewCL::Entire>
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 More...
 
int rows () const
 
int cols () const
 
int size () const
 
void clear_write_events () const
 Clear the write events from the event stacks. More...
 
void clear_read_events () const
 Clear the read events from the event stacks. More...
 
void clear_read_write_events () const
 Clear the write events from the event stacks. More...
 
const std::vector< cl::Event > & write_events () const
 Get the events from the event stacks. More...
 
const std::vector< cl::Event > & read_events () const
 Get the events from the event stacks. More...
 
const std::vector< cl::Event > read_write_events () const
 Get the events from the event stacks. More...
 
void add_read_event (cl::Event new_event) const
 Add an event to the read event stack. More...
 
void add_write_event (cl::Event new_event) const
 Add an event to the write event stack. More...
 
void add_read_write_event (cl::Event new_event) const
 Add an event to the read/write event stack. More...
 
void wait_for_write_events () const
 Waits for the write events and clears the read event stack. More...
 
void wait_for_read_events () const
 Waits for the read events and clears the read event stack. More...
 
void wait_for_read_write_events () const
 Waits for read and write events to finish and clears the read, write, and read/write event stacks. More...
 
const cl::Buffer & buffer () const
 
 matrix_cl ()
 
 matrix_cl (const matrix_cl &A)
 
 matrix_cl (const int &rows, const int &cols)
 Constructor for the matrix_cl that only allocates the buffer on the OpenCL device. More...
 
template<int R, int C>
 matrix_cl (const Eigen::Matrix< double, R, C > &A)
 Constructor for the matrix_cl that creates a copy of the Eigen matrix on the OpenCL device. More...
 
matrix_cloperator= (const matrix_cl &a)
 

Detailed Description

Represents a matrix on the OpenCL device.

The matrix data is stored in the oclBuffer_.

Definition at line 29 of file matrix_cl.hpp.

Constructor & Destructor Documentation

◆ matrix_cl() [1/4]

stan::math::matrix_cl::matrix_cl ( )
inline

Definition at line 172 of file matrix_cl.hpp.

◆ matrix_cl() [2/4]

stan::math::matrix_cl::matrix_cl ( const matrix_cl A)
inline

Definition at line 174 of file matrix_cl.hpp.

◆ matrix_cl() [3/4]

stan::math::matrix_cl::matrix_cl ( const int &  rows,
const int &  cols 
)
inline

Constructor for the matrix_cl that only allocates the buffer on the OpenCL device.

Parameters
rowsnumber of matrix rows, must be greater or equal to 0
colsnumber of matrix columns, must be greater or equal to 0
Exceptions
<code>std::system_error</code>if the matrices do not have matching dimensions

Definition at line 204 of file matrix_cl.hpp.

◆ matrix_cl() [4/4]

template<int R, int C>
stan::math::matrix_cl::matrix_cl ( const Eigen::Matrix< double, R, C > &  A)
inlineexplicit

Constructor for the matrix_cl that creates a copy of the Eigen matrix on the OpenCL device.

Template Parameters
Ttype of data in the Eigen matrix
Parameters
Athe Eigen matrix
Exceptions
<code>std::system_error</code>if the matrices do not have matching dimensions

Writes the contents of A to the OpenCL buffer starting at the offset 0. CL_TRUE denotes that the call is blocking as we do not want to execute any further kernels on the device until we are sure that the data is finished transfering)

Definition at line 229 of file matrix_cl.hpp.

Member Function Documentation

◆ add_read_event()

void stan::math::matrix_cl::add_read_event ( cl::Event  new_event) const
inline

Add an event to the read event stack.

Parameters
new_eventThe event to be pushed on the event stack.

Definition at line 110 of file matrix_cl.hpp.

◆ add_read_write_event()

void stan::math::matrix_cl::add_read_write_event ( cl::Event  new_event) const
inline

Add an event to the read/write event stack.

Parameters
new_eventThe event to be pushed on the event stack.

Definition at line 126 of file matrix_cl.hpp.

◆ add_write_event()

void stan::math::matrix_cl::add_write_event ( cl::Event  new_event) const
inline

Add an event to the write event stack.

Parameters
new_eventThe event to be pushed on the event stack.

Definition at line 118 of file matrix_cl.hpp.

◆ buffer()

const cl::Buffer& stan::math::matrix_cl::buffer ( ) const
inline

Definition at line 170 of file matrix_cl.hpp.

◆ clear_read_events()

void stan::math::matrix_cl::clear_read_events ( ) const
inline

Clear the read events from the event stacks.

Definition at line 68 of file matrix_cl.hpp.

◆ clear_read_write_events()

void stan::math::matrix_cl::clear_read_write_events ( ) const
inline

Clear the write events from the event stacks.

Definition at line 76 of file matrix_cl.hpp.

◆ clear_write_events()

void stan::math::matrix_cl::clear_write_events ( ) const
inline

Clear the write events from the event stacks.

Definition at line 60 of file matrix_cl.hpp.

◆ cols()

int stan::math::matrix_cl::cols ( ) const
inline

Definition at line 53 of file matrix_cl.hpp.

◆ operator=()

matrix_cl& stan::math::matrix_cl::operator= ( const matrix_cl a)
inline

Definition at line 259 of file matrix_cl.hpp.

◆ read_events()

const std::vector<cl::Event>& stan::math::matrix_cl::read_events ( ) const
inline

Get the events from the event stacks.

Returns
The read/write event stack.

Definition at line 94 of file matrix_cl.hpp.

◆ read_write_events()

const std::vector<cl::Event> stan::math::matrix_cl::read_write_events ( ) const
inline

Get the events from the event stacks.

Returns
The read/write event stack.

Definition at line 102 of file matrix_cl.hpp.

◆ rows()

int stan::math::matrix_cl::rows ( ) const
inline

Definition at line 51 of file matrix_cl.hpp.

◆ size()

int stan::math::matrix_cl::size ( ) const
inline

Definition at line 55 of file matrix_cl.hpp.

◆ sub_block()

template<TriangularViewCL triangular_view>
void stan::math::matrix_cl::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 
)
inline

Write the contents of A into this starting at the top left of this

Parameters
Ainput matrix
A_ithe offset row in A
A_jthe offset column in A
this_ithe offset row for the matrix to be subset into
this_jthe offset col for the matrix to be subset into
nrowsthe number of rows in the submatrix
ncolsthe number of columns in the submatrix

Definition at line 28 of file sub_block.hpp.

◆ triangular_transpose()

template<TriangularMapCL triangular_map>
void stan::math::matrix_cl::triangular_transpose ( )
inline

Copies a lower/upper triangular of a matrix to it's upper/lower.

Template Parameters
triangular_mapSpecifies if the copy is lower-to-upper or upper-to-lower triangular. The value must be of type TriangularMap
Exceptions
<code>std::invalid_argument</code>if the matrix is not square.

Definition at line 28 of file triangular_transpose.hpp.

◆ wait_for_read_events()

void stan::math::matrix_cl::wait_for_read_events ( ) const
inline

Waits for the read events and clears the read event stack.

Definition at line 146 of file matrix_cl.hpp.

◆ wait_for_read_write_events()

void stan::math::matrix_cl::wait_for_read_write_events ( ) const
inline

Waits for read and write events to finish and clears the read, write, and read/write event stacks.

Definition at line 159 of file matrix_cl.hpp.

◆ wait_for_write_events()

void stan::math::matrix_cl::wait_for_write_events ( ) const
inline

Waits for the write events and clears the read event stack.

Definition at line 134 of file matrix_cl.hpp.

◆ write_events()

const std::vector<cl::Event>& stan::math::matrix_cl::write_events ( ) const
inline

Get the events from the event stacks.

Returns
The write event stack.

Definition at line 86 of file matrix_cl.hpp.

◆ zeros()

template<TriangularViewCL triangular_view>
void stan::math::matrix_cl::zeros ( )
inline

Stores zeros in the matrix on the OpenCL device.

Supports writing zeroes to the lower and upper triangular or the whole matrix.

Template Parameters
triangular_viewSpecifies if zeros are assigned to the entire matrix, lower triangular or upper triangular. The value must be of type TriangularViewCL

Definition at line 27 of file zeros.hpp.


The documentation for this class was generated from the following files:

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