isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
gpuSignal.h
1 // -*- C++ -*-
2 // -*- coding: utf-8 -*-
3 //
4 // Source Author: Liang Yu
5 // Copyright 2019
6 
7 #pragma once
8 
9 #include "forward.h"
10 
11 #include <complex>
12 #include <valarray>
13 
14 #include <cufft.h>
15 #include <thrust/complex.h>
16 
17 #include <isce3/core/Common.h>
18 
19 template<class T>
21 
22  public:
23  // Default constructor
24  gpuSignal() {};
25  gpuSignal(cufftType _type);
26  ~gpuSignal();
27 
33  void azimuthFFT(int ncolumns, int nrows);
34 
40  void rangeFFT(int ncolumns, int nrows);
41 
47  void FFT2D(int ncolumns, int nrows);
48 
52  void fftPlan(int rank, int* n, int howmany,
53  int* inembed, int istride, int idist,
54  int* onembed, int ostride, int odist);
55 
57  void nextPowerOfTwo(size_t N, size_t& fftLength);
58 
60  inline void _configureRangeFFT(int ncolumns, int nrows);
61 
63  inline void _configureAzimuthFFT(int ncolumns, int nrows);
64 
66  void dataToDevice(std::complex<T> *input);
67  void dataToDevice(std::valarray<std::complex<T>> &input);
68  void dataToHost(std::complex<T> *output);
69  void dataToHost(std::valarray<std::complex<T>> &output);
70 
72  void forward();
73 
75  void forwardC2C(std::complex<T> *input, std::complex<T> *output);
76  void forwardC2C(std::valarray<std::complex<T>> &input,
77  std::valarray<std::complex<T>> &output);
78  void forwardZ2Z(std::complex<T> *input, std::complex<T> *output);
79  void forwardZ2Z(std::valarray<std::complex<T>> &input,
80  std::valarray<std::complex<T>> &output);
81  void forwardD2Z(T *input, std::complex<T> *output);
82 
83  void forward(std::complex<T> *input, std::complex<T> *output);
84  void forward(std::valarray<std::complex<T>> &input,
85  std::valarray<std::complex<T>> &output);
86 
87  void forwardDevMem(T *input, T *output);
88  void forwardDevMem(T *dataInPlace);
89 
91  void inverse();
92 
94  void inverseC2C(std::complex<T> *input, std::complex<T> *output);
95  void inverseC2C(std::valarray<std::complex<T>> &input,
96  std::valarray<std::complex<T>> &output);
97  void inverseZ2Z(std::complex<T> *input, std::complex<T> *output);
98  void inverseZ2Z(std::valarray<std::complex<T>> &input,
99  std::valarray<std::complex<T>> &output);
100  void inverseZ2D(std::complex<T> *input, T *output);
101 
102  void inverse(std::complex<T> *input, std::complex<T> *output);
103  void inverse(std::valarray<std::complex<T>> &input,
104  std::valarray<std::complex<T>> &output);
105 
106  void inverseDevMem(T *input, T *output);
107  void inverseDevMem(T *dataInPlace);
108 
110  void upsample(std::valarray<std::complex<T>> &input,
111  std::valarray<std::complex<T>> &output,
112  int row,
113  int ncols,
114  int upsampleFactor);
115  void upsample(std::valarray<std::complex<T>> &input,
116  std::valarray<std::complex<T>> &output,
117  int row,
118  int ncols,
119  int upsampleFactor,
120  std::valarray<std::complex<T>> &shiftImpact);
121 
122  int getRows() {return _rows;};
123  int getColumns() {return _columns;};
124  int getNumElements() {return _n_elements;};
125 
126  T* getDevicePtr() {return _d_data;};
127 
128  private:
129  cufftHandle _plan;
130  bool _plan_set;
131  cufftType _cufft_type;
132 
133  // FFT plan parameters
134  int _rank;
135  int _n[2];
136  int _howmany;
137  int _inembed[2];
138  int _istride;
139  int _idist;
140  int _onembed[2];
141  int _ostride;
142  int _odist;
143  int _n_elements;
144  int _rows;
145  int _columns;
146 
147  // device memory pointers
148  T *_d_data;
149  bool _d_data_set;
150 };
151 
154 template<class T>
155 CUDA_GLOBAL void rangeShift_g(thrust::complex<T> *data_lo_res,
156  thrust::complex<T> *data_hi_res,
157  int n_rows,
158  int n_cols_lo,
159  int n_cols_hi);
160 
163 template<class T>
164 CUDA_GLOBAL void rangeShiftImpactMult_g(thrust::complex<T> *data_lo_res,
165  thrust::complex<T> *data_hi_res,
166  thrust::complex<T> *impact_shift,
167  int n_rows,
168  int n_cols_lo,
169  int n_cols_hi);
170 
171 template<class T>
172 void upsample(isce3::cuda::signal::gpuSignal<T> &fwd,
174  thrust::complex<T> *input,
175  thrust::complex<T> *output);
176 
177 template<class T>
178 void upsample(isce3::cuda::signal::gpuSignal<T> &fwd,
180  thrust::complex<T> *input,
181  thrust::complex<T> *output,
182  thrust::complex<T> *shiftImpact);
183 
184 template<class T>
185 void upsample(isce3::cuda::signal::gpuSignal<T> &fwd,
187  std::valarray<std::complex<T>> &input,
188  std::valarray<std::complex<T>> &output);
189 
190 template<class T>
191 void upsample(isce3::cuda::signal::gpuSignal<T> &fwd,
193  std::valarray<std::complex<T>> &input,
194  std::valarray<std::complex<T>> &output,
195  std::valarray<std::complex<T>> &shiftImpact);
196 
201 template<class T>
202 CUDA_GLOBAL void normalize_g(thrust::complex<T> *data,
203  T normalization,
204  size_t n_elements);
void rangeFFT(int ncolumns, int nrows)
initiate plan for FFT in azimuth direction for a block of complex data.
void FFT2D(int ncolumns, int nrows)
initiate plan for FFT in azimuth direction for a block of complex data.
void dataToDevice(std::complex< T > *input)
moving data in between device and host
void forwardC2C(std::complex< T > *input, std::complex< T > *output)
forward transforms
void forward()
forward transforms without intermediate return
void _configureAzimuthFFT(int ncolumns, int nrows)
determine the required parameters for setting azimuth FFT plans
void _configureRangeFFT(int ncolumns, int nrows)
determine the required parameters for setting range FFT plans
void upsample(std::valarray< std::complex< T >> &input, std::valarray< std::complex< T >> &output, int row, int ncols, int upsampleFactor)
upsample
Definition: forward.h:11
void fftPlan(int rank, int *n, int howmany, int *inembed, int istride, int idist, int *onembed, int ostride, int odist)
initiate cuFFT plan for a block of complex data input parameters cuFFT interface for fftw_plan_many_d...
void inverseC2C(std::complex< T > *input, std::complex< T > *output)
inverse transforms
void nextPowerOfTwo(size_t N, size_t &fftLength)
next power of two
void inverse()
inverse transforms using existing device memory
void azimuthFFT(int ncolumns, int nrows)
initiate plan for FFT in range direction for a block of complex data.

Generated for ISCE3.0 by doxygen 1.8.5.