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
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 
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  */
50 {
51  public:
52  /// Default constructor.
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
118  /// operator = is not allowed for public
120 
121  /// Total number of elements.
122  size_t nElements;
123  /// Total number of allocated elements (the array size).
125 
126  /// Dimension sizes.
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 */
virtual size_t * GetDeviceData()
Get raw GPU data out of the class (for direct GPU kernel access).
Abstract base class. The common ancestor defining the common interface and allowing derived classes t...
Definition: BaseMatrix.h:48
virtual const size_t * GetHostData() const
Get raw data out of the class (for direct CPU kernel access).
virtual const size_t * GetDeviceData() const
Get raw GPU data out of the class (for direct GPU kernel access).
virtual struct TDimensionSizes GetDimensionSizes() const
Get dimension sizes of the matrix.
size_t nAllocatedElements
Total number of allocated elements (the array size).
virtual void CopyFromDevice()
Copy data from GPU -> CPU (Device -> Host).
size_t * deviceData
Raw GPU matrix data.
virtual void AllocateMemory()
Memory allocation (both on CPU and GPU)
virtual size_t * GetHostData()
Get raw data out of the class (for direct CPU kernel access).
virtual ~TBaseIndexMatrix()
Destructor.
struct TDimensionSizes dimensionSizes
Dimension sizes.
virtual void ZeroMatrix()
Zero all elements of the matrix (NUMA first touch).
The header file containing the structure with 3D dimension sizes.
size_t * hostData
Raw CPU matrix data.
Abstract base class for index based matrices defining basic interface. Higher dimensional matrices st...
virtual size_t GetElementCount() const
Get total element count of the matrix.
virtual void CopyToDevice()
Copy data from CPU -> GPU (Host -> Device).
virtual size_t GetAllocatedElementCount() const
Get total allocated element count (might differ from total element count used for the simulation beca...
size_t rowSize
Size of 1D row in X dimension.
TBaseIndexMatrix & operator=(const TBaseIndexMatrix &src)
operator = is not allowed for public
size_t nElements
Total number of elements.
size_t slabSize
Size of 2D slab (X,Y).
TBaseIndexMatrix()
Default constructor.
The header file of the common ancestor of all matrix classes. A pure abstract class.
Structure with 4D dimension sizes (3 in space and 1 in time).
virtual void FreeMemory()
Memory deallocation (both on CPU and GPU)