From 63ad1453f7dcb861826fcb30206e687ba9eae2ef Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Mon, 28 Jun 2021 14:52:41 -0700 Subject: [PATCH] FFTW: Initialize Threads Co-authored-by: Severin Diederichs --- Source/FieldSolver/SpectralSolver/WrapFFTW.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/FieldSolver/SpectralSolver/WrapFFTW.cpp b/Source/FieldSolver/SpectralSolver/WrapFFTW.cpp index a4dfc8b293b..57a0fad046a 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){