| kspaceFirstOrder3D-CUDA 1.1 The CUDA/C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BaseIndexMatrix.h
Go to the documentation of this file.
1 /**
2 * @file BaseIndexMatrix.h
3 *
4 * @author Jiri Jaros \n
5 * Faculty of Information Technology \n
6 * Brno University of Technology \n
7 * jarosjir@fit.vutbr.cz
8 *
9 * @brief The header file containing the base class for 64b-wide integers implemented as
10 * size_t datatype.
11 *
12 * @version kspaceFirstOrder3D 3.4
13 *
14 * @date 26 July 2011, 14:17 (created) \n
15 * 29 July 2016, 16:51 (revised)
16 *
17 * @section License
18 * This file is part of the C++ extension of the k-Wave Toolbox
19 * (http://www.k-wave.org).\n Copyright (C) 2016 Jiri Jaros and Bradley Treeby.
20 *
21 * This file is part of the k-Wave. k-Wave is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU Lesser General Public License as published by the Free Software
23 * Foundation, either version 3 of the License, or (at your option) any later version.
24 *
25 * k-Wave is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
26 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
27 * General Public License for more details.
28 *
29 * You should have received a copy of the GNU Lesser General Public License along with k-Wave.
30 * If not, see http://www.gnu.org/licenses/.
31 */
32
33 #ifndef BASE_INDEX_MATRIX_H
34 #define BASE_INDEX_MATRIX_H
35
36 #include <MatrixClasses/BaseMatrix.h>
37 #include <Utils/DimensionSizes.h>
38
39
40 /**
41 * @class TBaseIndexMatrix
42 * @brief Abstract base class for index based matrices defining basic interface.
43 * Higher dimensional matrices stored as 1D arrays, row-major order.
44
45 * @details Abstract base class for index based matrices defining basic interface. Higher
46 * dimensional matrices stored as 1D arrays, row-major order. This matrix stores the data
47 * on both the CPU and GPU side.
48 */
49 class TBaseIndexMatrix : public TBaseMatrix
50 {
51 public:
52 /// Default constructor.
53 TBaseIndexMatrix();
54
55 /// Destructor.
56 virtual ~TBaseIndexMatrix(){};
57
58 /// Get dimension sizes of the matrix.
59 virtual struct TDimensionSizes GetDimensionSizes() const
60 {
61 return dimensionSizes;
62 }
63
64 /// Get total element count of the matrix.
65 virtual size_t GetElementCount() const
66 {
67 return nElements;
68 };
69
70 /// Get total allocated element count (might differ from total element count used for the simulation because of padding).
71 virtual size_t GetAllocatedElementCount() const
72 {
73 return nAllocatedElements;
74 };
75
76 /// Zero all elements of the matrix (NUMA first touch).
77 virtual void ZeroMatrix();
78
79 /// Get raw data out of the class (for direct CPU kernel access).
80 virtual size_t* GetHostData()
81 {
82 return hostData;
83 }
84
85 /// Get raw data out of the class (for direct CPU kernel access).
86 virtual const size_t* GetHostData() const
87 {
88 return hostData;
89 }
90
91 /// Get raw GPU data out of the class (for direct GPU kernel access).
92 virtual size_t* GetDeviceData()
93 {
94 return deviceData;
95 }
96
97 /// Get raw GPU data out of the class (for direct GPU kernel access).
98 virtual const size_t* GetDeviceData() const
99 {
100 return deviceData;
101 }
102
103 /// Copy data from CPU -> GPU (Host -> Device).
104 virtual void CopyToDevice();
105
106 /// Copy data from GPU -> CPU (Device -> Host).
107 virtual void CopyFromDevice();
108
109 protected:
110
111 /// Memory allocation (both on CPU and GPU)
112 virtual void AllocateMemory();
113 /// Memory deallocation (both on CPU and GPU)
114 virtual void FreeMemory();
115
116 /// Copy constructor is not allowed for public
117 TBaseIndexMatrix(const TBaseIndexMatrix& src);
118 /// operator = is not allowed for public
119 TBaseIndexMatrix & operator=(const TBaseIndexMatrix& src);
120
121 /// Total number of elements.
122 size_t nElements;
123 /// Total number of allocated elements (the array size).
124 size_t nAllocatedElements;
125
126 /// Dimension sizes.
127 struct TDimensionSizes dimensionSizes;
128
129 /// Size of 1D row in X dimension.
130 size_t rowSize;
131 /// Size of 2D slab (X,Y).
132 size_t slabSize;
133
134 /// Raw CPU matrix data.
135 size_t* hostData;
136 /// Raw GPU matrix data.
137 size_t* deviceData;
138
139 private:
140
141 };// end of TBaseLongMatrix
142 //--------------------------------------------------------------------------------------------------
143
144 #endif /* BASE_INDEX_MATRIX_H */
TBaseIndexMatrix::GetDeviceData
virtual size_t * GetDeviceData()
Get raw GPU data out of the class (for direct GPU kernel access).
Definition: BaseIndexMatrix.h:92
TBaseMatrix
Abstract base class. The common ancestor defining the common interface and allowing derived classes t...
Definition: BaseMatrix.h:48
TBaseIndexMatrix::GetHostData
virtual const size_t * GetHostData() const
Get raw data out of the class (for direct CPU kernel access).
Definition: BaseIndexMatrix.h:86
TBaseIndexMatrix::GetDeviceData
virtual const size_t * GetDeviceData() const
Get raw GPU data out of the class (for direct GPU kernel access).
Definition: BaseIndexMatrix.h:98
TBaseIndexMatrix::GetDimensionSizes
virtual struct TDimensionSizes GetDimensionSizes() const
Get dimension sizes of the matrix.
Definition: BaseIndexMatrix.h:59
TBaseIndexMatrix::nAllocatedElements
size_t nAllocatedElements
Total number of allocated elements (the array size).
Definition: BaseIndexMatrix.h:124
TBaseIndexMatrix::CopyFromDevice
virtual void CopyFromDevice()
Copy data from GPU -> CPU (Device -> Host).
Definition: BaseIndexMatrix.cpp:94
TBaseIndexMatrix::deviceData
size_t * deviceData
Raw GPU matrix data.
Definition: BaseIndexMatrix.h:137
TBaseIndexMatrix::AllocateMemory
virtual void AllocateMemory()
Memory allocation (both on CPU and GPU)
Definition: BaseIndexMatrix.cpp:113
TBaseIndexMatrix::GetHostData
virtual size_t * GetHostData()
Get raw data out of the class (for direct CPU kernel access).
Definition: BaseIndexMatrix.h:80
TBaseIndexMatrix::~TBaseIndexMatrix
virtual ~TBaseIndexMatrix()
Destructor.
Definition: BaseIndexMatrix.h:56
TBaseIndexMatrix::dimensionSizes
struct TDimensionSizes dimensionSizes
Dimension sizes.
Definition: BaseIndexMatrix.h:127
TBaseIndexMatrix::ZeroMatrix
virtual void ZeroMatrix()
Zero all elements of the matrix (NUMA first touch).
Definition: BaseIndexMatrix.cpp:68
DimensionSizes.h
The header file containing the structure with 3D dimension sizes.
TBaseIndexMatrix::hostData
size_t * hostData
Raw CPU matrix data.
Definition: BaseIndexMatrix.h:135
TBaseIndexMatrix
Abstract base class for index based matrices defining basic interface. Higher dimensional matrices st...
Definition: BaseIndexMatrix.h:49
TBaseIndexMatrix::GetElementCount
virtual size_t GetElementCount() const
Get total element count of the matrix.
Definition: BaseIndexMatrix.h:65
TBaseIndexMatrix::CopyToDevice
virtual void CopyToDevice()
Copy data from CPU -> GPU (Host -> Device).
Definition: BaseIndexMatrix.cpp:81
TBaseIndexMatrix::GetAllocatedElementCount
virtual size_t GetAllocatedElementCount() const
Get total allocated element count (might differ from total element count used for the simulation beca...
Definition: BaseIndexMatrix.h:71
TBaseIndexMatrix::rowSize
size_t rowSize
Size of 1D row in X dimension.
Definition: BaseIndexMatrix.h:130
TBaseIndexMatrix::operator=
TBaseIndexMatrix & operator=(const TBaseIndexMatrix &src)
operator = is not allowed for public
TBaseIndexMatrix::nElements
size_t nElements
Total number of elements.
Definition: BaseIndexMatrix.h:122
TBaseIndexMatrix::slabSize
size_t slabSize
Size of 2D slab (X,Y).
Definition: BaseIndexMatrix.h:132
TBaseIndexMatrix::TBaseIndexMatrix
TBaseIndexMatrix()
Default constructor.
Definition: BaseIndexMatrix.cpp:52
BaseMatrix.h
The header file of the common ancestor of all matrix classes. A pure abstract class.
TDimensionSizes
Structure with 4D dimension sizes (3 in space and 1 in time).
Definition: DimensionSizes.h:66
TBaseIndexMatrix::FreeMemory
virtual void FreeMemory()
Memory deallocation (both on CPU and GPU)
Definition: BaseIndexMatrix.cpp:138