-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add OpenMP for FFTW #541
Add OpenMP for FFTW #541
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
#include "AnyDST.H" | ||
#include "utils/HipaceProfilerWrapper.H" | ||
|
||
#ifdef AMREX_USE_OMP | ||
# include <omp.h> | ||
#endif | ||
|
||
namespace AnyDST | ||
{ | ||
#ifdef AMREX_USE_FLOAT | ||
|
@@ -16,6 +20,18 @@ namespace AnyDST | |
const int nx = real_size[0]; | ||
const int ny = real_size[1]; | ||
|
||
#if defined(AMREX_USE_OMP) && defined(HIPACE_FFTW_OMP) | ||
if (nx > 32 && ny > 32) { | ||
# 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()); | ||
Comment on lines
+27
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also add, just to expose even more control, a runtime parameter that can overwrite the value passed to The default would be the heuristic you already added ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, this will be an interesting addition. After an offline discussion with @MaxThevenet, I will merge this PR as is and add this feature as soon as we have other openMP acceleration. As it is the only function using openMP, we have currently full control with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh right, I forgot this is the first OpenMP accelerated part 😅 |
||
# endif | ||
} | ||
#endif | ||
|
||
// Initialize fft_plan.m_plan with the vendor fft plan. | ||
// Swap dimensions: AMReX FAB are Fortran-order but FFTW is C-order | ||
dst_plan.m_plan = VendorCreatePlanR2R2D( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lovely!