Skip to content
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 #2040

Merged
merged 2 commits into from
Jun 30, 2021
Merged

Add OpenMP for FFTW #2040

merged 2 commits into from
Jun 30, 2021

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Jun 28, 2021

Same as Hi-PACE/hipace#541

For best results, use close-by pinning, esp. with MPI, and avoid oversubscription of cores, esp. if no hyperthreading is available:

export OMP_PROC_BIND=spread
export OMP_PLACES=threads
export OMP_NUM_THREADS=1 # 1,2,4,...

Close #2036

Add Comment to Avoid Accidental Box Over-Subscription

Traditionally, we use OpenMP for the AMReX MFIter-loop over multiple boxes on a rank (and tile/vectorize inside the box).
If we want to parallelize the FFT here with OpenMP, we should make sure that specific loop does not use the pragma omp then (thx @RemiLehe for the reminder):

Test with

  • Langmuir and scale it up a bit in cells if needed (update: not needed, 64^3 was sufficiently large):
    [Langmuir_multi_psatd]
    buildDir = .
    inputFile = Examples/Tests/Langmuir/inputs_3d_multi_rt
    runtime_params = algo.maxwell_solver=psatd psatd.fftw_plan_measure=0 warpx.cfl = 0.5773502691896258
    dim = 3
    addToCompileString = USE_PSATD=TRUE
    restartTest = 0
    useMPI = 1
    numprocs = 2
    useOMP = 1
    numthreads = 1
    compileTest = 0
    doVis = 0
    compareParticles = 1
    particleTypes = electrons positrons
    analysisRoutine = Examples/Tests/Langmuir/analysis_langmuir_multi.py
    analysisOutputImage = langmuir_multi_analysis.png
    tolerance = 5.e-11
Name                                                       NCalls  Incl. Min  Incl. Avg  Incl. Max   Max %
----------------------------------------------------------------------------------------------------------
export OMP_NUM_THREADS=1
SpectralSolver::ForwardTransform                              360      2.138      2.138      2.138  14.85%
SpectralSolver::BackwardTransform                             240      1.704      1.704      1.704  11.83%

export OMP_NUM_THREADS=2
SpectralSolver::ForwardTransform                              360      1.079      1.079      1.079  13.81%
SpectralSolver::BackwardTransform                             240     0.8471     0.8471     0.8471  10.84%

export OMP_NUM_THREADS=3
SpectralSolver::ForwardTransform                              360     0.8523     0.8523     0.8523  13.71%
SpectralSolver::BackwardTransform                             240     0.6879     0.6879     0.6879  11.07%

export OMP_NUM_THREADS=4
SpectralSolver::ForwardTransform                              360     0.7416     0.7416     0.7416  13.98%
SpectralSolver::BackwardTransform                             240     0.5924     0.5924     0.5924  11.17%

# Hyperthreading below
export OMP_NUM_THREADS=8
SpectralSolver::ForwardTransform                              360     0.7251     0.7251     0.7251  13.46%
SpectralSolver::BackwardTransform                             240     0.6363     0.6363     0.6363  11.81%

@ax3l ax3l added component: spectral Spectral solvers (PSATD, IGF) backend: openmp Specific to OpenMP execution (CPUs) labels Jun 28, 2021
@ax3l ax3l force-pushed the topic-openmp_fftw branch 2 times, most recently from adfd91d to 63ad145 Compare June 28, 2021 22:03
@ax3l ax3l changed the title Add OpenMP for FFTW [WIP] Add OpenMP for FFTW Jun 28, 2021
ax3l and others added 2 commits June 29, 2021 15:02
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.
Co-authored-by: Severin Diederichs <severin.diederichs@desy.de>
@ax3l ax3l force-pushed the topic-openmp_fftw branch from 63ad145 to f1e879d Compare June 29, 2021 22:30
@ax3l ax3l changed the title [WIP] Add OpenMP for FFTW Add OpenMP for FFTW Jun 29, 2021
@RemiLehe RemiLehe merged commit f428f5a into ECP-WarpX:development Jun 30, 2021
@RemiLehe
Copy link
Member

Awesome! Thanks a lot for this change!

@ax3l ax3l deleted the topic-openmp_fftw branch June 30, 2021 23:53
@ax3l ax3l mentioned this pull request Jul 6, 2021
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend: openmp Specific to OpenMP execution (CPUs) component: spectral Spectral solvers (PSATD, IGF) Performance optimization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FFTW: OpenMP
2 participants