Automatic Differentiation
 
Loading...
Searching...
No Matches
stan::math::matrix_cl< T > Class Template Reference

Detailed Description

template<typename T>
class stan::math::matrix_cl< T >

Represents an arithmetic matrix on the OpenCL device.

Template Parameters
Tan arithmetic type for the type stored in the OpenCL buffer.

Definition at line 47 of file matrix_cl.hpp.

#include <matrix_cl.hpp>

+ Inheritance diagram for stan::math::matrix_cl< T >:

Public Types

using Scalar = T
 
using type = T
 

Public Member Functions

template<matrix_cl_view matrix_view = matrix_cl_view::Entire>
void zeros_strict_tri ()
 Stores zeros in the strict's triangular part (excluding the diagonal) of a matrix on the OpenCL device.
 
int rows () const
 
int cols () const
 
int size () const
 
const matrix_cl_viewview () const
 
void view (const matrix_cl_view &view)
 
void clear_write_events () const
 Clear the write events from the event stacks.
 
void clear_read_events () const
 Clear the read events from the event stacks.
 
void clear_read_write_events () const
 Clear the write events from the event stacks.
 
const tbb::concurrent_vector< cl::Event > & write_events () const
 Get the events from the event stacks.
 
const tbb::concurrent_vector< cl::Event > & read_events () const
 Get the events from the event stacks.
 
const tbb::concurrent_vector< cl::Event > read_write_events () const
 Get the events from the event stacks.
 
void add_read_event (cl::Event new_event) const
 Add an event to the read event stack.
 
void add_write_event (cl::Event new_event) const
 Add an event to the write event stack.
 
void add_read_write_event (cl::Event new_event) const
 Add an event to the read/write event stack.
 
void wait_for_write_events () const
 Waits for the write events and clears the read event stack.
 
void wait_for_read_events () const
 Waits for the read events and clears the read event stack.
 
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.
 
const cl::Buffer & buffer () const
 
cl::Buffer & buffer ()
 
 matrix_cl ()
 
 matrix_cl (const cl::Buffer &A, const int R, const int C, matrix_cl_view partial_view=matrix_cl_view::Entire)
 Construct a matrix_cl<T> from an existing cl::Buffer object.
 
 matrix_cl (const matrix_cl< T > &A)
 Copy constructor.
 
 matrix_cl (matrix_cl< T > &&A)
 Move constructor.
 
 matrix_cl (const arena_matrix_cl< T > &A)
 Constructor from arena_matrix_cl.
 
template<typename Vec , require_std_vector_vt< is_eigen, Vec > * = nullptr, require_st_same< Vec, T > * = nullptr>
 matrix_cl (Vec &&A)
 Constructor for the matrix_cl that creates a copy of a std::vector of Eigen matrices on the OpenCL device.
 
 matrix_cl (const int rows, const int cols, matrix_cl_view partial_view=matrix_cl_view::Entire)
 Constructor for the matrix_cl that only allocates the buffer on the OpenCL device.
 
template<typename Mat , require_eigen_t< Mat > * = nullptr, require_vt_same< Mat, T > * = nullptr>
 matrix_cl (Mat &&A, matrix_cl_view partial_view=matrix_cl_view::Entire)
 Constructor for the matrix_cl that creates a copy of the Eigen matrix or Eigen expression on the OpenCL device.
 
template<typename Scal , typename = require_same_t<T, std::remove_reference_t<Scal>>>
 matrix_cl (Scal &&A, matrix_cl_view partial_view=matrix_cl_view::Diagonal)
 Constructor for the matrix_cl that creates a copy of a scalar on the OpenCL device.
 
template<typename Vec , require_std_vector_t< Vec > * = nullptr, require_vt_same< Vec, T > * = nullptr>
 matrix_cl (Vec &&A, matrix_cl_view partial_view=matrix_cl_view::Entire)
 Construct a matrix_cl of size Nx1 from std::vector.
 
template<typename Vec , require_std_vector_t< Vec > * = nullptr, require_vt_same< Vec, T > * = nullptr>
 matrix_cl (Vec &&A, const int &R, const int &C, matrix_cl_view partial_view=matrix_cl_view::Entire)
 Construct from std::vector with given rows and columns.
 
template<typename U , require_same_t< T, U > * = nullptr>
 matrix_cl (const U *A, const int &R, const int &C, matrix_cl_view partial_view=matrix_cl_view::Entire)
 Construct from array with given rows and columns.
 
template<typename Expr , require_all_kernel_expressions_and_none_scalar_t< Expr > * = nullptr, require_not_matrix_cl_t< Expr > * = nullptr>
 matrix_cl (const Expr &expression)
 Construct from a kernel generator expression.
 
matrix_cl< T > & operator= (matrix_cl< T > &&a)
 Move assignment operator.
 
matrix_cl< T > & operator= (const matrix_cl< T > &a)
 Copy assignment operator.
 
template<typename Expr , require_all_kernel_expressions_and_none_scalar_t< Expr > * = nullptr, require_not_matrix_cl_t< Expr > * = nullptr>
matrix_cl< T > & operator= (const Expr &expression)
 Assignment of a kernel generator expression evaluates the expression into this.
 
matrix_cl< T > & operator= (const arena_matrix_cl< T > &other)
 Assignment of arena_matrix_cl<T>.
 
const matrix_cl< T > & eval () const &
 Evaluates this.
 
matrix_cl< T > eval () &&
 
 ~matrix_cl ()
 Destructor waits for write events to prevent any kernels from writing memory that has already been reused.
 
void setZero ()
 Set the values of a matrix_cl to zero.
 

Private Member Functions

template<bool in_order = false>
cl::Event initialize_buffer (const T *A)
 Initializes the OpenCL buffer of this matrix by copying the data from given buffer.
 
template<bool in_order = false>
cl::Event initialize_buffer (T *A)
 
template<bool No_heap, typename U , std::enable_if_t< No_heap > * = nullptr>
void initialize_buffer_no_heap_if (U &&obj)
 Initializes the OpenCL buffer of this matrix by copying the data from given object.
 
template<bool No_heap, typename U , std::enable_if_t<!No_heap > * = nullptr>
void initialize_buffer_no_heap_if (U &&obj)
 
void initialize_buffer_cl (const matrix_cl< T > &A)
 Initializes the OpenCL buffer of this matrix by copying the data from given matrix_cl.
 

Static Private Member Functions

template<typename U >
static void delete_it_event (cl_event e, cl_int status, void *container)
 Deletes the container.
 
template<typename U >
static void delete_it_destructor (cl_mem buff, void *container)
 Deletes the container.
 

Private Attributes

cl::Buffer buffer_cl_
 
int rows_ {0}
 
int cols_ {0}
 
matrix_cl_view view_ {matrix_cl_view::Entire}
 
tbb::concurrent_vector< cl::Event > write_events_
 
tbb::concurrent_vector< cl::Event > read_events_
 

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