Skip to content

Commit

Permalink
FFTW: Initialize Threads
Browse files Browse the repository at this point in the history
Co-authored-by: Severin Diederichs <severin.diederichs@desy.de>
  • Loading branch information
ax3l and SeverinDiederichs committed Jun 29, 2021
1 parent d508049 commit f1e879d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ SpectralFieldData::ForwardTransform (const int lev,
#endif

// Loop over boxes
// Note: we do NOT OpenMP parallelize here, since we use OpenMP threads for
// the FFTs on each box!
for ( MFIter mfi(mf); mfi.isValid(); ++mfi ){
if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
{
Expand Down Expand Up @@ -247,6 +249,8 @@ SpectralFieldData::BackwardTransform( const int lev,
#endif

// Loop over boxes
// Note: we do NOT OpenMP parallelize here, since we use OpenMP threads for
// the iFFTs on each box!
for ( MFIter mfi(mf); mfi.isValid(); ++mfi ){
if (cost && WarpX::load_balance_costs_update_algo == LoadBalanceCostsUpdateAlgo::Timers)
{
Expand Down
12 changes: 11 additions & 1 deletion Source/FieldSolver/SpectralSolver/WrapFFTW.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2019-2020
/* Copyright 2019-2021
*
* This file is part of WarpX.
*
Expand Down Expand Up @@ -32,6 +32,16 @@ namespace AnyFFT
{
FFTplan fft_plan;

#if defined(AMREX_USE_OMP) && defined(WarpX_FFTW_OMP)
# ifdef AMREX_USE_FLOAT
fftwf_init_threads();
fftwf_plan_with_nthreads(omp_get_max_threads());
# else
fftw_init_threads();
fftw_plan_with_nthreads(omp_get_max_threads());
# endif
#endif

// Initialize fft_plan.m_plan with the vendor fft plan.
// Swap dimensions: AMReX FAB are Fortran-order but FFTW is C-order
if (dir == direction::R2C){
Expand Down

0 comments on commit f1e879d

Please sign in to comment.