kspaceFirstOrder3D-OMP  1.2
The C++ implementation of the k-wave toolbox for the time-domain simulation of acoustic wave fields in 3D
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 index matrices (based on the size_t datatype).
10  *
11  *
12  * @version kspaceFirstOrder3D 2.16
13  *
14  * @date 26 July 2011, 12:17 (created) \n
15  * 04 September 2017, 11:02 (revised)
16  *
17  * @copyright Copyright (C) 2017 Jiri Jaros and Bradley Treeby.
18  *
19  * This file is part of the C++ extension of the [k-Wave Toolbox](http://www.k-wave.org).
20  *
21  * This file is part of the k-Wave. k-Wave is free software: you can redistribute it and/or modify it under the terms
22  * of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the
23  * 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 the implied
26  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
27  * 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/](http://www.gnu.org/licenses/).
31  */
32 
33 
34 #ifndef BASE_INDEX_MATRIX_H
35 #define BASE_INDEX_MATRIX_H
36 
37 
39 #include <Utils/DimensionSizes.h>
40 
41 /**
42  * @class BaseIndexMatrix
43  * @brief Abstract base class for index based matrices defining basic interface.
44  * Higher dimensional matrices stored as 1D arrays, row-major order.
45 
46  * @details Abstract base class for index based matrices defining basic interface. Higher
47  * dimensional matrices stored as 1D arrays, row-major order. The I/O is done via HDF5 files.
48  */
50 {
51  public:
52  /// Default constructor.
54  /// Copy constructor is not allowed.
55  BaseIndexMatrix(const BaseIndexMatrix&) = delete;
56  /// Destructor.
57  virtual ~BaseIndexMatrix() {};
58 
59  /// operator= is not allowed.
60  BaseIndexMatrix& operator=(const BaseIndexMatrix&) = delete;
61 
62  /**
63  * @brief Get dimension sizes of the matrix.
64  * @return Dimension sizes of the matrix.
65  */
66  virtual const DimensionSizes& getDimensionSizes() const { return mDimensionSizes; };
67 
68  /**
69  * @brief Size of the matrix.
70  * @return Number of elements.
71  */
72  virtual size_t size() const { return mSize; };
73  /**
74  * @brief The capacity of the matrix (this may differ from size due to padding, etc.).
75  * @return Capacity of the currently allocated storage.
76  */
77  virtual size_t capacity() const { return mCapacity; };
78 
79  /// Zero all elements of the matrix (NUMA first touch).
80  virtual void zeroMatrix();
81 
82  /**
83  * @brief Get raw data out of the class (for direct kernel access).
84  * @return Mutable matrix data
85  */
86  virtual size_t* getData() { return mData; };
87 
88  /**
89  * @brief Get raw data out of the class (for direct kernel access), const version.
90  * @return Immutable matrix data.
91  */
92  virtual const size_t* getData() const { return mData; };
93 
94  protected:
95  /**
96  * @brief Aligned memory allocation (both on CPU and GPU).
97  * @throw std::bad_alloc - If there's not enough memory.
98  */
99  virtual void allocateMemory();
100  /// Memory deallocation (both on CPU and GPU)
101  virtual void freeMemory();
102 
103  /// Total number of elements.
104  size_t mSize;
105  /// Total number of allocated elements (in terms of size_t).
106  size_t mCapacity;
107 
108  /// Dimension sizes.
110 
111  /// Size of 1D row in X dimension.
112  size_t mRowSize;
113  /// Size of a XY slab.
114  size_t mSlabSize;
115 
116  /// Raw matrix data.
117  size_t* mData;
118 
119  private:
120 
121 };// end of BaseIndexMatrix
122 //----------------------------------------------------------------------------------------------------------------------
123 
124 #endif /* BASE_INDEX_MATRIX_H */
size_t mRowSize
Size of 1D row in X dimension.
size_t mSize
Total number of elements.
BaseIndexMatrix()
Default constructor.
virtual void zeroMatrix()
Zero all elements of the matrix (NUMA first touch).
size_t * mData
Raw matrix data.
BaseIndexMatrix & operator=(const BaseIndexMatrix &)=delete
operator= is not allowed.
virtual size_t * getData()
Get raw data out of the class (for direct kernel access).
virtual ~BaseIndexMatrix()
Destructor.
virtual size_t size() const
Size of the matrix.
Abstract base class. The common ancestor defining the common interface and allowing derived classes t...
Definition: BaseMatrix.h:48
virtual void allocateMemory()
Aligned memory allocation (both on CPU and GPU).
virtual const DimensionSizes & getDimensionSizes() const
Get dimension sizes of the matrix.
virtual size_t capacity() const
The capacity of the matrix (this may differ from size due to padding, etc.).
Structure with 4D dimension sizes (3 in space and 1 in time).
virtual const size_t * getData() const
Get raw data out of the class (for direct kernel access), const version.
The header file containing the structure with 3D dimension sizes.
size_t mCapacity
Total number of allocated elements (in terms of size_t).
size_t mSlabSize
Size of a XY slab.
DimensionSizes mDimensionSizes
Dimension sizes.
Abstract base class for index based matrices defining basic interface. Higher dimensional matrices st...
The header file of the common ancestor of all matrix classes. A pure abstract class.
virtual void freeMemory()
Memory deallocation (both on CPU and GPU)