Skip to content

Commit 25d4d51

Browse files
authored
Merge pull request #1 from cwuelker/master
Small changes
2 parents 42140d1 + 3e01bf9 commit 25d4d51

5 files changed

Lines changed: 15 additions & 15 deletions

File tree

include/PFSOFTlib_headers/fftw_wrapper.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ PFSOFT_BEGIN
2828
extern "C"
2929
{
3030
/*- FFTW FUNCTIONS -*/
31-
void uzl_fftw_layer_wise_DFT2_grid3D (int cols, int rows, int lays, double* arr);
32-
void uzl_fftw_layer_wise_IDFT2_grid3D(int cols, int rows, int lays, double* arr);
31+
void uzl_fftw_layer_wise_DFT2_grid3D (int cols, int rows, int lays, double* arr, int threads);
32+
void uzl_fftw_layer_wise_IDFT2_grid3D(int cols, int rows, int lays, double* arr, int threads);
3333
}
3434

3535
PFSOFT_END

include/PFSOFTlib_headers/grid3D_cx.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ grid3D< complex< T >, if_pod_type< T > >
7878
inline complex< pod_type >& operator()(const size_t& row, const size_t& col, const size_t& lay);
7979
inline const complex< pod_type >& operator()(const size_t& row, const size_t& col, const size_t& lay) const;
8080

81-
inline void layer_wise_DFT2(const complex< double >& scale = complex< pod_type >(1, 0));
82-
inline void layer_wise_IDFT2(const complex< double >& scale = complex< pod_type >(1, 0));
81+
inline void layer_wise_DFT2(const complex< double >& scale = complex< pod_type >(1, 0), int threads = 1);
82+
inline void layer_wise_IDFT2(const complex< double >& scale = complex< pod_type >(1, 0), int threads = 1);
8383
};
8484

8585

@@ -306,7 +306,7 @@ const complex< T >& grid3D< complex< T >, if_pod_type< T > >::operator()(const s
306306

307307
template< typename T >
308308
inline
309-
void grid3D< complex< T >, if_pod_type< T > >::layer_wise_DFT2(const complex< double >& scale)
309+
void grid3D< complex< T >, if_pod_type< T > >::layer_wise_DFT2(const complex< double >& scale, int threads)
310310
{
311311
// declare variables
312312
size_t i;
@@ -336,7 +336,7 @@ void grid3D< complex< T >, if_pod_type< T > >::layer_wise_DFT2(const complex< do
336336
}
337337

338338
// perform layerwise FFT2
339-
uzl_fftw_layer_wise_DFT2_grid3D(cols, rows, lays, data);
339+
uzl_fftw_layer_wise_DFT2_grid3D(cols, rows, lays, data, threads);
340340

341341
// skip if scale is default
342342
if (scale.re != 1 || scale.im != 0)
@@ -367,7 +367,7 @@ void grid3D< complex< T >, if_pod_type< T > >::layer_wise_DFT2(const complex< do
367367

368368
template< typename T >
369369
inline
370-
void grid3D< complex< T >, if_pod_type< T > >::layer_wise_IDFT2(const complex< double >& scale)
370+
void grid3D< complex< T >, if_pod_type< T > >::layer_wise_IDFT2(const complex< double >& scale, int threads)
371371
{
372372
// declare variables
373373
size_t i;
@@ -397,7 +397,7 @@ void grid3D< complex< T >, if_pod_type< T > >::layer_wise_IDFT2(const complex< d
397397
}
398398

399399
// perform layerwise FFT2
400-
uzl_fftw_layer_wise_IDFT2_grid3D(cols, rows, lays, data);
400+
uzl_fftw_layer_wise_IDFT2_grid3D(cols, rows, lays, data, threads);
401401

402402
// skip if scale is default
403403
if (scale.re != 1 || scale.im != 0)

src/fftw_wrapper.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ PFSOFT_BEGIN
4444
/*- Wrapper for needed library functions -*/
4545
extern "C"
4646
{
47-
void uzl_fftw_layer_wise_DFT2_grid3D(int cols, int rows, int lays, double* arr)
47+
void uzl_fftw_layer_wise_DFT2_grid3D(int cols, int rows, int lays, double* arr, int threads)
4848
{
4949
#ifdef _OPENMP
5050

@@ -67,7 +67,7 @@ extern "C"
6767
}
6868

6969
// execute plans in parallel
70-
#pragma omp parallel for private(i) shared(lays, plans) schedule(dynamic)
70+
#pragma omp parallel for private(i) shared(lays, plans) schedule(dynamic) num_threads(threads)
7171
for (i = 0; i < lays; ++i)
7272
{
7373
// execute FFT2 plan
@@ -108,7 +108,7 @@ extern "C"
108108
#endif
109109
}
110110

111-
void uzl_fftw_layer_wise_IDFT2_grid3D(int cols, int rows, int lays, double* arr)
111+
void uzl_fftw_layer_wise_IDFT2_grid3D(int cols, int rows, int lays, double* arr, int threads)
112112
{
113113
#ifdef _OPENMP
114114

@@ -131,7 +131,7 @@ extern "C"
131131
}
132132

133133
// execute plans in parallel
134-
#pragma omp parallel for private(i) shared(lays, plans) schedule(dynamic)
134+
#pragma omp parallel for private(i) shared(lays, plans) schedule(dynamic) num_threads(threads)
135135
for (i = 0; i < lays; ++i)
136136
{
137137
// execute FFT2 plan
@@ -173,4 +173,4 @@ extern "C"
173173
}
174174
}
175175

176-
PFSOFT_END
176+
PFSOFT_END

src/fn_dsoft.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void DSOFT(grid3D< complex< double > > sample, DSOFTFourierCoefficients& fc, int
101101
/*****************************************************************
102102
** FFT2 transform layers of sample grid for fixed k **
103103
*****************************************************************/
104-
sample.layer_wise_DFT2();
104+
sample.layer_wise_DFT2(complex< double > (1.0, 0.0), threads);
105105

106106
/*****************************************************************
107107
** M = 0, M' = 0 **

src/fn_idsoft.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ void IDSOFT(const DSOFTFourierCoefficients& fc, grid3D< complex< double > >& syn
286286
/*****************************************************************
287287
** IFFT2 transform layers of input sample grid for fixed k **
288288
*****************************************************************/
289-
synthesis.layer_wise_IDFT2(complex< double > (1. / (4. * bandwidth * bandwidth), 0));
289+
synthesis.layer_wise_IDFT2(complex< double > (1. / (4. * bandwidth * bandwidth), 0), threads);
290290
}
291291

292292
PFSOFT_NAMESPACE_END

0 commit comments

Comments
 (0)