aboutsummaryrefslogtreecommitdiff
path: root/Source/FieldSolver/SpectralSolver
diff options
context:
space:
mode:
authorGravatar Axel Huebl <axel.huebl@plasma.ninja> 2021-06-30 15:34:58 -0700
committerGravatar GitHub <noreply@github.com> 2021-06-30 15:34:58 -0700
commitf428f5a26f11d715f1b8800e60f0b29154ce10a6 (patch)
tree7f8183fa37fcfb4b08cb57400d11957561b08d93 /Source/FieldSolver/SpectralSolver
parentadd16de9cb37c5c466db492512a495809d6ddded (diff)
downloadWarpX-f428f5a26f11d715f1b8800e60f0b29154ce10a6.tar.gz
WarpX-f428f5a26f11d715f1b8800e60f0b29154ce10a6.tar.zst
WarpX-f428f5a26f11d715f1b8800e60f0b29154ce10a6.zip
Add OpenMP for FFTW (#2040)
* CMake: Find out if FFTW supports OpenMP Add a heuristics that also works with PkgConfig to query OpenMP support in FFTW. Enable by default if we build with the OpenMP compute backend unless explicitly disabled. Add a macro to control the source-code, since FFTW does not offer a public define for this. * FFTW: Initialize Threads Co-authored-by: Severin Diederichs <severin.diederichs@desy.de> Co-authored-by: Severin Diederichs <severin.diederichs@desy.de>
Diffstat (limited to 'Source/FieldSolver/SpectralSolver')
-rw-r--r--Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp4
-rw-r--r--Source/FieldSolver/SpectralSolver/WrapFFTW.cpp12
2 files changed, 15 insertions, 1 deletions
diff --git a/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp b/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp
index bdb631063..056c030c0 100644
--- a/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp
+++ b/Source/FieldSolver/SpectralSolver/SpectralFieldData.cpp
@@ -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)
{
@@ -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)
{
diff --git a/Source/FieldSolver/SpectralSolver/WrapFFTW.cpp b/Source/FieldSolver/SpectralSolver/WrapFFTW.cpp
index a4dfc8b29..57a0fad04 100644
--- a/Source/FieldSolver/SpectralSolver/WrapFFTW.cpp
+++ b/Source/FieldSolver/SpectralSolver/WrapFFTW.cpp
@@ -1,4 +1,4 @@
-/* Copyright 2019-2020
+/* Copyright 2019-2021
*
* This file is part of WarpX.
*
@@ -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){