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
CUFFTComplexMatrix.h
Go to the documentation of this file.
1 /**
2  * @file CUFFTComplexMatrix.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 class that implements 3D FFT using the cuFFT
10  * interface.
11  *
12  * @version kspaceFirstOrder3D 3.4
13  *
14  * @date 09 August 2011, 13:10 (created) \n
15  * 10 August 2016, 10:57 (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 CUFFT_COMPLEX_MATRIX_H
34 #define CUFFT_COMPLEX_MATRIX_H
35 
36 #include <map>
37 #include <cufft.h>
38 
40 #include <Logger/ErrorMessages.h>
41 
42 /**
43  * @class TCUFFTComplexMatrix
44  * @brief Class implementing 3D Real-To-Complex and Complex-To-Real transforms using CUDA
45  * FFT interface.
46  * @details Class implementing 3D Real-To-Complex and Complex-To-Real transforms using CUDA
47  * FFT interface.
48  *
49  */
51 {
52  public:
53  /// Constructor (inherited from TComplexMatrix).
54  TCUFFTComplexMatrix(const TDimensionSizes& DimensionSizes) : TComplexMatrix(DimensionSizes) {};
55  /// Destructor (Inherited from TComplexMatrix).
56  virtual ~TCUFFTComplexMatrix(){};
57 
58  /// Create static cuFFT plan for Real-to-Complex.
59  static void Create_FFT_Plan_3D_R2C(const TDimensionSizes& inMatrixDims);
60  /// Create static cuFFT plan for Complex-to-Real.
61  static void Create_FFT_Plan_3D_C2R(const TDimensionSizes& outMatrixDims);
62 
63  /// Create static cuFFT plan for Real-to-Complex in the X dimension.
64  static void Create_FFT_Plan_1DX_R2C(const TDimensionSizes& inMatrixDims);
65  /// Create static cuFFT plan for Real-to-Complex in the Y dimension.
66  static void Create_FFT_Plan_1DY_R2C(const TDimensionSizes& inMatrixDims);
67  /// Create static cuFFT plan for Real-to-Complex in the Z dimension.
68  static void Create_FFT_Plan_1DZ_R2C(const TDimensionSizes& inMatrixDims);
69 
70  /// Create static cuFFT plan for Complex-to-Real in the X dimension.
71  static void Create_FFT_Plan_1DX_C2R(const TDimensionSizes& outMatrixDims);
72  /// Create static cuFFT plan for Complex-to-Real in the Y dimension.
73  static void Create_FFT_Plan_1DY_C2R(const TDimensionSizes& outMatrixDims);
74  /// Create static cuFFT plan for Complex-to-Real in the Z dimension.
75  static void Create_FFT_Plan_1DZ_C2R(const TDimensionSizes& outMatrixDims);
76 
77  /// Destroy all static plans and error messages.
78  static void DestroyAllPlansAndStaticData();
79 
80  /// Compute 3D out-of-place Real-to-Complex FFT.
81  void Compute_FFT_3D_R2C(TRealMatrix& inMatrix);
82  /// Compute 3D out-of-place Complex-to-Real FFT.
83  void Compute_FFT_3D_C2R(TRealMatrix& outMatrix);
84 
85  /// Compute 1D out-of-place Real-to-Complex FFT in the X dimension.
86  void Compute_FFT_1DX_R2C(TRealMatrix& inMatrix);
87  /// Compute 1D out-of-place Real-to-Complex FFT in the Y dimension.
88  void Compute_FFT_1DY_R2C(TRealMatrix& inMatrix);
89  /// Compute 1D out-of-place Real-to-Complex FFT in the Z dimension.
90  void Compute_FFT_1DZ_R2C(TRealMatrix& inMatrix);
91 
92  /// Compute 1D out-of-place Complex-to-Real FFT in the X dimension.
93  void Compute_FFT_1DX_C2R(TRealMatrix& outMatrix);
94  /// Compute 1D out-of-place Complex-to-Real FFT in the Y dimension.
95  void Compute_FFT_1DY_C2R(TRealMatrix& outMatrix);
96  /// Compute 1D out-of-place Complex-to-Real FFT in the Z dimension.
97  void Compute_FFT_1DZ_C2R(TRealMatrix& outMatrix);
98 
99 
100  protected:
101 
102  /// Copy constructor not allowed for public.
104  /// Operator = not allowed for public.
106 
107  /// cuFFT plan for the 3D Real-to-Complex transform.
108  static cufftHandle cufftPlan_3D_R2C;
109  /// cuFFT plan for the 3D Complex-to-Real transform.
110  static cufftHandle cufftPlan_3D_C2R;
111 
112  /// cuFFT plan for the 1D Real-to-Complex transform in the X dimension.
113  static cufftHandle cufftPlan_1DX_R2C;
114  /// cuFFT plan for the 3D Real-to-Complex transform in the Y dimension.
115  static cufftHandle cufftPlan_1DY_R2C;
116  /// cuFFT plan for the 3D Real-to-Complex transform in the Z dimension.
117  static cufftHandle cufftPlan_1DZ_R2C;
118 
119  /// cuFFT plan for the 3D Complex-to-Real transform in the X dimension.
120  static cufftHandle cufftPlan_1DX_C2R;
121  /// cuFFT plan for the 3D Complex-to-Real transform in the Y dimension.
122  static cufftHandle cufftPlan_1DY_C2R;
123  /// cuFFT plan for the 3Z Complex-to-Real transform in the Z dimension.
124  static cufftHandle cufftPlan_1DZ_C2R;
125 
126  private:
127 
128  /// Throw an exception with a given error message
129  static void ThrowCUFFTException(const cufftResult cufftError,
130  const std::string& transformTypeName);
131 
132  static std::map<cufftResult, TErrorMessage> cuFFTErrorMessages;
133 
134 };// TCUFFTComplexMatrix
135 
136 #endif /* CUFFT_COMPLEX_MATRIX_H */
void Compute_FFT_1DY_R2C(TRealMatrix &inMatrix)
Compute 1D out-of-place Real-to-Complex FFT in the Y dimension.
static cufftHandle cufftPlan_1DZ_C2R
cuFFT plan for the 3Z Complex-to-Real transform in the Z dimension.
virtual ~TCUFFTComplexMatrix()
Destructor (Inherited from TComplexMatrix).
static void Create_FFT_Plan_1DZ_R2C(const TDimensionSizes &inMatrixDims)
Create static cuFFT plan for Real-to-Complex in the Z dimension.
void Compute_FFT_3D_C2R(TRealMatrix &outMatrix)
Compute 3D out-of-place Complex-to-Real FFT.
static void DestroyAllPlansAndStaticData()
Destroy all static plans and error messages.
static void Create_FFT_Plan_1DX_R2C(const TDimensionSizes &inMatrixDims)
Create static cuFFT plan for Real-to-Complex in the X dimension.
void Compute_FFT_1DZ_R2C(TRealMatrix &inMatrix)
Compute 1D out-of-place Real-to-Complex FFT in the Z dimension.
static void Create_FFT_Plan_1DY_C2R(const TDimensionSizes &outMatrixDims)
Create static cuFFT plan for Complex-to-Real in the Y dimension.
void Compute_FFT_1DY_C2R(TRealMatrix &outMatrix)
Compute 1D out-of-place Complex-to-Real FFT in the Y dimension.
static void Create_FFT_Plan_1DZ_C2R(const TDimensionSizes &outMatrixDims)
Create static cuFFT plan for Complex-to-Real in the Z dimension.
static cufftHandle cufftPlan_1DX_C2R
cuFFT plan for the 3D Complex-to-Real transform in the X dimension.
static void Create_FFT_Plan_3D_C2R(const TDimensionSizes &outMatrixDims)
Create static cuFFT plan for Complex-to-Real.
static cufftHandle cufftPlan_1DY_R2C
cuFFT plan for the 3D Real-to-Complex transform in the Y dimension.
static cufftHandle cufftPlan_3D_R2C
cuFFT plan for the 3D Real-to-Complex transform.
static void Create_FFT_Plan_1DX_C2R(const TDimensionSizes &outMatrixDims)
Create static cuFFT plan for Complex-to-Real in the X dimension.
void Compute_FFT_1DX_R2C(TRealMatrix &inMatrix)
Compute 1D out-of-place Real-to-Complex FFT in the X dimension.
TCUFFTComplexMatrix(const TDimensionSizes &DimensionSizes)
Constructor (inherited from TComplexMatrix).
static void Create_FFT_Plan_1DY_R2C(const TDimensionSizes &inMatrixDims)
Create static cuFFT plan for Real-to-Complex in the Y dimension.
void Compute_FFT_3D_R2C(TRealMatrix &inMatrix)
Compute 3D out-of-place Real-to-Complex FFT.
void Compute_FFT_1DX_C2R(TRealMatrix &outMatrix)
Compute 1D out-of-place Complex-to-Real FFT in the X dimension.
static cufftHandle cufftPlan_3D_C2R
cuFFT plan for the 3D Complex-to-Real transform.
The header file containing routines for error messages and error messages common for both linux and w...
static void Create_FFT_Plan_3D_R2C(const TDimensionSizes &inMatrixDims)
Create static cuFFT plan for Real-to-Complex.
The header file with the class for complex matrices.
The class for real matrices.
Definition: RealMatrix.h:45
TCUFFTComplexMatrix & operator=(const TCUFFTComplexMatrix &src)
Operator = not allowed for public.
void Compute_FFT_1DZ_C2R(TRealMatrix &outMatrix)
Compute 1D out-of-place Complex-to-Real FFT in the Z dimension.
static void ThrowCUFFTException(const cufftResult cufftError, const std::string &transformTypeName)
Throw an exception with a given error message.
static cufftHandle cufftPlan_1DY_C2R
cuFFT plan for the 3D Complex-to-Real transform in the Y dimension.
static cufftHandle cufftPlan_1DX_R2C
cuFFT plan for the 1D Real-to-Complex transform in the X dimension.
static std::map< cufftResult, TErrorMessage > cuFFTErrorMessages
The class for complex matrices.
Definition: ComplexMatrix.h:54
Class implementing 3D Real-To-Complex and Complex-To-Real transforms using CUDA FFT interface...
static cufftHandle cufftPlan_1DZ_R2C
cuFFT plan for the 3D Real-to-Complex transform in the Z dimension.
Structure with 4D dimension sizes (3 in space and 1 in time).