![]() |
kspaceFirstOrder3D-CUDA
1.1
The CUDA/C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
|
Abstract base class for float based matrices defining basic interface. Higher dimensional matrices stored as 1D arrays, row-major order. More...
#include <BaseFloatMatrix.h>
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... | |
![]() | |
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. | |
TBaseFloatMatrix & | operator= (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. | |
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.
TBaseFloatMatrix::TBaseFloatMatrix | ( | ) |
Default constructor
Definition at line 56 of file BaseFloatMatrix.cpp.
|
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.
|
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.
|
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.
|
protectedvirtual |
Free memory. Both on the CPU and GPU side
Definition at line 162 of file BaseFloatMatrix.cpp.
|
virtual |
Divide a scalar by the elements of matrix.
[in] | scalar | - Scalar to be divided by evey element of the array |
Definition at line 88 of file BaseFloatMatrix.cpp.
|
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.