Skip to content

Commit

Permalink
Set a base_flag for FFTW Chebyshev setup
Browse files Browse the repository at this point in the history
Makes it more convenient to change to, for example, FFTW.ESTIMATE if
that is desired. No run-time option to change the FFTW flag is provided
because there is not a convenient struct to put the option in (although
that could be done without a lot of effort).
  • Loading branch information
johnomotani committed Apr 15, 2024
1 parent 10a3815 commit 81daf5b
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions moment_kinetics/src/chebyshev.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ function setup_chebyshev_pseudospectral(coord, run_directory; ignore_MPI=false)
wisdom_filename = joinpath(run_directory, "fftw_wisdom.save")
end

# When using FFTW.WISDOM_ONLY, the flag should be combined with the flag that was
# originally used to generate the 'wisdom' otherwise if the original flag was 'lower
# effort' (i.e. was FFTW.ESTIMATE) then the default (FFTW.MEASURE) will be used
# instead. Note that we also need an FFTW flag in chebyshev_radau_weights(), so if
# this flag is changed, that one should be changed too (if it is used). The flag is
# not automatically pased through, because there is not a convenient way to pass a
# flag through to chebyshev_radau_weights().
base_flag = FFTW.MEASURE

function this_barrier()
if !ignore_MPI
# Normal case, all processors are creating the coordinate
Expand All @@ -88,12 +97,13 @@ function setup_chebyshev_pseudospectral(coord, run_directory; ignore_MPI=false)
if wisdom_filename !== nothing
# Load wisdom
FFTW.import_wisdom(wisdom_filename)
fftw_flags = FFTW.MEASURE | FFTW.WISDOM_ONLY
# Flags can be combined with a bitwise-or operation `|`.
fftw_flags = base_flag | FFTW.WISDOM_ONLY
else
fftw_flags = FFTW.MEASURE
fftw_flags = base_flag
end
else
fftw_flags = FFTW.MEASURE
fftw_flags = base_flag
end

lobatto = setup_chebyshev_pseudospectral_lobatto(coord, fftw_flags)
Expand Down

0 comments on commit 81daf5b

Please sign in to comment.