STORMM Source Documentation
Loading...
Searching...
No Matches
stormm::stmath::HpcMatrix< T > Class Template Reference

A matrix object that can traverse CPU and GPU memory. More...

#include <matrix.h>

Public Member Functions

HybridLabel getLabel () const
 Produce the label for this matrix (obtained from the label of its primary contents)
 
void resize (size_t new_rows, size_t new_cols)
 Change the number of rows and columns. Elements outside the bounds of the new matrix will be discarded. If the new matrix is larger than the old one, all elements will be preserved and new elements will be initialized to zero.
 
void reset ()
 Empty the matrix and set its size to 0 by 0.
 
operator() (size_t row_idx, size_t col_idx, HybridTargetLevel tier=HybridTargetLevel::HOST)
 Element-wise access via the function call () operator. This entails two bounds checks.
 
atHost (size_t row_idx, size_t col_idx)
 Element-wise access to host data without bounds checks, following on the Armadillo naming conventions.
 
atDevice (size_t row_idx, size_t col_idx)
 Element-wise access to data on the GPU without bounds checks, following on the Armadillo naming conventions.
 
Hybrid< T > colptr (size_t col_idx, const char *tag_in=nullptr)
 Get a Hybrid POINTER-kind object that is set directly to the column of interest.
 
 HpcMatrix (const char *tag_in=nullptr, HybridFormat format_in=default_hpc_format)
 Constructors must set public-facing reference variables in addition to private member variables.
 
 HpcMatrix (size_t rows_in, size_t cols_in, const char *tag_in=nullptr, HybridFormat format_in=default_hpc_format, MatrixFillMode fill_method=MatrixFillMode::VALUE, T fill_value=static_cast< T >(0))
 
 HpcMatrix (size_t rows_in, size_t cols_in, MatrixFillMode fill_method, T fill_value=static_cast< T >(0), const char *tag_in=nullptr, HybridFormat format_in=default_hpc_format)
 
 HpcMatrix (size_t rows_in, size_t cols_in, MatrixFillMode fill_method, Ran2Generator *matrng, const char *tag_in=nullptr, HybridFormat format_in=default_hpc_format)
 
const T * memptr (HybridTargetLevel tier=HybridTargetLevel::HOST) const
 Pointer to the memory itself, on the host or the device. This takes its name from the Armadillo vec, mat, and cube classes.
 
T * memptr (HybridTargetLevel tier=HybridTargetLevel::HOST)
 

Public Attributes

const size_t & n_rows
 
const size_t & n_cols
 
const size_t & n_elem
 

Detailed Description

template<typename T>
class stormm::stmath::HpcMatrix< T >

A matrix object that can traverse CPU and GPU memory.

Constructor & Destructor Documentation

◆ HpcMatrix()

template<typename T>
stormm::stmath::HpcMatrix< T >::HpcMatrix ( const char * tag_in = nullptr,
HybridFormat format_in = default_hpc_format )

Constructors must set public-facing reference variables in addition to private member variables.

Overloaded:

  • Initialize an empty matrix with zero rows and zero columns
  • Initialize a matrix with a given numer of rows and columns, all elements set to zero
Parameters
rows_inThe number of rows to allocate
cols_inThe number of columns to allocate
fill_methodManner in which to fill the indices
fill_valueA scalar value for initializing all elements if fill_method is VALUE, or the random seed for initializing a random number generator if fill_method is RANDU or RANDN

Member Function Documentation

◆ atDevice()

template<typename T>
T stormm::stmath::HpcMatrix< T >::atDevice ( size_t row_idx,
size_t col_idx )

Element-wise access to data on the GPU without bounds checks, following on the Armadillo naming conventions.

Parameters
row_idxIndex of the row to access, starting at 0
col_idxIndex of the column to access, starting at 0

◆ atHost()

template<typename T>
T stormm::stmath::HpcMatrix< T >::atHost ( size_t row_idx,
size_t col_idx )

Element-wise access to host data without bounds checks, following on the Armadillo naming conventions.

Parameters
row_idxIndex of the row to access, starting at 0
col_idxIndex of the column to access, starting at 0

◆ colptr()

template<typename T>
Hybrid< T > stormm::stmath::HpcMatrix< T >::colptr ( size_t col_idx,
const char * tag_in = nullptr )

Get a Hybrid POINTER-kind object that is set directly to the column of interest.

Parameters
col_idxThe column of interest
tag_inA note to help identify the column pointer

◆ memptr()

template<typename T>
const T * stormm::stmath::HpcMatrix< T >::memptr ( HybridTargetLevel tier = HybridTargetLevel::HOST) const

Pointer to the memory itself, on the host or the device. This takes its name from the Armadillo vec, mat, and cube classes.

Overloaded:

  • Get a const pointer if the object is const
  • Get a pointer that can modify the underlying data if the object is non-const
Parameters
tierIndicator of whether to offer a pointer to host or GPU device memory

◆ operator()()

template<typename T>
T stormm::stmath::HpcMatrix< T >::operator() ( size_t row_idx,
size_t col_idx,
HybridTargetLevel tier = HybridTargetLevel::HOST )

Element-wise access via the function call () operator. This entails two bounds checks.

Parameters
row_idxIndex of the row to access, starting at 0
col_idxIndex of the column to access, starting at 0
tierIndicator of whether to access data on the host or on the GPU

◆ resize()

template<typename T>
void stormm::stmath::HpcMatrix< T >::resize ( size_t new_rows,
size_t new_cols )

Change the number of rows and columns. Elements outside the bounds of the new matrix will be discarded. If the new matrix is larger than the old one, all elements will be preserved and new elements will be initialized to zero.

Parameters
new_rowsNew number of rows to allocate
new_colsNew number of columns to allocate

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