kspaceFirstOrder3D-CUDA  1.1
The CUDA/C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TBaseFloatMatrix Class Reference

Abstract base class for float based matrices defining basic interface. Higher dimensional matrices stored as 1D arrays, row-major order. More...

#include <BaseFloatMatrix.h>

Inheritance diagram for TBaseFloatMatrix:
Collaboration diagram for TBaseFloatMatrix:

Public Member Functions

 TBaseFloatMatrix ()
 Default constructor. More...
 
virtual TDimensionSizes GetDimensionSizes () const
 Get dimension sizes of the matrix.
 
virtual size_t GetElementCount () const
 Get element count of the matrix.
 
virtual size_t GetAllocatedElementCount () const
 Get total allocated element count (might differ from total element count used for the simulation because of padding).
 
virtual void ZeroMatrix ()
 Zero all elements of the matrix (NUMA first touch). More...
 
virtual void ScalarDividedBy (const float scalar)
 Divide scalar/ matrix_element[i]. More...
 
virtual float * GetHostData ()
 Get raw CPU data out of the class (for direct CPU kernel access).
 
virtual const float * GetHostData () const
 Get raw CPU data out of the class (for direct CPU kernel access).
 
virtual float * GetDeviceData ()
 Get raw GPU data out of the class (for direct GPU kernel access).
 
virtual const float * GetDeviceData () const
 Get raw GPU data out of the class (for direct GPU kernel access).
 
virtual void CopyToDevice ()
 Copy data from CPU -> GPU (Host -> Device). More...
 
virtual void CopyFromDevice ()
 Copy data from GPU -> CPU (Device -> Host). More...
 
- Public Member Functions inherited from TBaseMatrix
 TBaseMatrix ()
 Default constructor.
 
virtual ~TBaseMatrix ()
 Destructor.
 
virtual void ReadDataFromHDF5File (THDF5_File &file, TMatrixName &matrixName)=0
 Read matrix from the HDF5 file. More...
 
virtual void WriteDataToHDF5File (THDF5_File &file, TMatrixName &matrixName, const size_t compressionLevel)=0
 Write data into the HDF5 file. More...
 

Protected Member Functions

virtual void AllocateMemory ()
 Memory allocation (both on CPU and GPU). More...
 
virtual void FreeMemory ()
 Memory allocation (both on CPU and GPU). More...
 
 TBaseFloatMatrix (const TBaseFloatMatrix &src)
 Copy constructor is not directly allowed.
 
TBaseFloatMatrixoperator= (const TBaseFloatMatrix &src)
 Operator = is not directly allowed.
 

Protected Attributes

size_t nElements
 Total number of elements.
 
size_t nAllocatedElements
 Total number of allocated elements (in terms of floats).
 
struct TDimensionSizes dimensionSizes
 Dimension sizes.
 
size_t dataRowSize
 Size of a 1D row in X dimension.
 
size_t dataSlabSize
 Size of a 2D slab.
 
float * hostData
 Raw CPU matrix data.
 
float * deviceData
 Raw GPU matrix data.
 

Detailed Description

Abstract base class for float based matrices defining basic interface. Higher dimensional matrices stored as 1D arrays, row-major order.Implemented both on CPU and GPU side.

Definition at line 49 of file BaseFloatMatrix.h.

Constructor & Destructor Documentation

TBaseFloatMatrix::TBaseFloatMatrix ( )

Default constructor

Definition at line 56 of file BaseFloatMatrix.cpp.

Member Function Documentation

void TBaseFloatMatrix::AllocateMemory ( )
protectedvirtual

Memory allocation based on the total number of elements.
CPU memory is aligned by the DATA_ALIGNMENT and then registered as pinned and zeroed.

Definition at line 133 of file BaseFloatMatrix.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void TBaseFloatMatrix::CopyFromDevice ( )
virtual

Copy data from GPU -> CPU (Device -> Host). The transfer is synchronous (there is nothing to overlap with in the code)

Implements TBaseMatrix.

Definition at line 115 of file BaseFloatMatrix.cpp.

Here is the caller graph for this function:

void TBaseFloatMatrix::CopyToDevice ( )
virtual

Copy data from CPU -> GPU (Host -> Device). The transfer is synchronous (there is nothing to overlap with in the code)

Implements TBaseMatrix.

Definition at line 102 of file BaseFloatMatrix.cpp.

void TBaseFloatMatrix::FreeMemory ( )
protectedvirtual

Free memory. Both on the CPU and GPU side

Definition at line 162 of file BaseFloatMatrix.cpp.

Here is the caller graph for this function:

void TBaseFloatMatrix::ScalarDividedBy ( const float  scalar)
virtual

Divide a scalar by the elements of matrix.

Parameters
[in]scalar- Scalar to be divided by evey element of the array

Definition at line 88 of file BaseFloatMatrix.cpp.

Here is the caller graph for this function:

void TBaseFloatMatrix::ZeroMatrix ( )
virtual

Zero all allocated elements in parallel.
Also work as the first touch strategy on NUMA machines.

Definition at line 73 of file BaseFloatMatrix.cpp.

Here is the caller graph for this function:


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