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
TBaseIndexMatrix Class Reference

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

#include <BaseIndexMatrix.h>

Inheritance diagram for TBaseIndexMatrix:
Collaboration diagram for TBaseIndexMatrix:

Public Member Functions

 TBaseIndexMatrix ()
 Default constructor. More...
 
virtual ~TBaseIndexMatrix ()
 Destructor.
 
virtual struct TDimensionSizes GetDimensionSizes () const
 Get dimension sizes of the matrix.
 
virtual size_t GetElementCount () const
 Get total 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 size_t * GetHostData ()
 Get raw data out of the class (for direct CPU kernel access).
 
virtual const size_t * GetHostData () const
 Get raw data out of the class (for direct CPU kernel access).
 
virtual size_t * GetDeviceData ()
 Get raw GPU data out of the class (for direct GPU kernel access).
 
virtual const size_t * 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 deallocation (both on CPU and GPU) More...
 
 TBaseIndexMatrix (const TBaseIndexMatrix &src)
 Copy constructor is not allowed for public.
 
TBaseIndexMatrixoperator= (const TBaseIndexMatrix &src)
 operator = is not allowed for public
 

Protected Attributes

size_t nElements
 Total number of elements.
 
size_t nAllocatedElements
 Total number of allocated elements (the array size).
 
struct TDimensionSizes dimensionSizes
 Dimension sizes.
 
size_t rowSize
 Size of 1D row in X dimension.
 
size_t slabSize
 Size of 2D slab (X,Y).
 
size_t * hostData
 Raw CPU matrix data.
 
size_t * deviceData
 Raw GPU matrix data.
 

Detailed Description

Abstract base class for index based matrices defining basic interface. Higher dimensional matrices stored as 1D arrays, row-major order. This matrix stores the data on both the CPU and GPU side.

Definition at line 49 of file BaseIndexMatrix.h.

Constructor & Destructor Documentation

TBaseIndexMatrix::TBaseIndexMatrix ( )

Default constructor

Definition at line 52 of file BaseIndexMatrix.cpp.

Member Function Documentation

void TBaseIndexMatrix::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. The GPU memory is allocated on GPU but not zeroed (no reason).

Definition at line 113 of file BaseIndexMatrix.cpp.

Here is the caller graph for this function:

void TBaseIndexMatrix::CopyFromDevice ( )
virtual

Copy data from GPU -> CPU (Device -> Host).

Implements TBaseMatrix.

Definition at line 94 of file BaseIndexMatrix.cpp.

void TBaseIndexMatrix::CopyToDevice ( )
virtual

Copy data from CPU -> GPU (Host -> Device).

Implements TBaseMatrix.

Definition at line 81 of file BaseIndexMatrix.cpp.

void TBaseIndexMatrix::FreeMemory ( )
protectedvirtual

Free memory.

Definition at line 138 of file BaseIndexMatrix.cpp.

Here is the caller graph for this function:

void TBaseIndexMatrix::ZeroMatrix ( )
virtual

Zero all allocated elements.

Definition at line 68 of file BaseIndexMatrix.cpp.


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