Skip to content

Add the Base/SIMD tutorial - #187

Merged
WeiqunZhang merged 3 commits into
AMReX-Codes:mainfrom
WeiqunZhang:simd
Nov 5, 2026
Merged

WeiqunZhang merged 3 commits into
AMReX-Codes:mainfrom
WeiqunZhang:simd

Conversation

@WeiqunZhang

Copy link
Copy Markdown
Member

Part 1 shows what lets the compiler vectorize a ParallelFor kernel on CPU: the same function with a non-inlined call and a branch (for illustration only), and inlined and branch-free, timed with BL_PROFILE. Part 2 uses the explicit SIMD layer, ParallelForSIMD with simd::load_1d/store_1d and a Vectorized functor, which runs scalar without AMReX_SIMD and on GPUs. The superbuild fetches vir-simd for AMReX_SIMD=ON (cmake/DependencySIMD.cmake).

The tests no longer trap floating-point exceptions: vectorized code raises them in inactive SIMD lanes and when the compiler speculates both arms of a select, with correct results, so the traps are a debugging aid for scalar runs. The trap arguments and the clang maytrap flag are removed from CMake, and AMReX_TESTING from the CI jobs, which all check their answers. A new CI job builds Base with AMReX_SIMD=ON; it drops -fno-operator-names, which vir-simd's alternative tokens reject.

Part 1 shows what lets the compiler vectorize a ParallelFor kernel on
CPU: the same function with a non-inlined call and a branch (for
illustration only), and inlined and branch-free, timed with BL_PROFILE.
Part 2 uses the explicit SIMD layer, ParallelForSIMD with
simd::load_1d/store_1d and a Vectorized functor, which runs scalar
without AMReX_SIMD and on GPUs. The superbuild fetches vir-simd for
AMReX_SIMD=ON (cmake/DependencySIMD.cmake).

The tests no longer trap floating-point exceptions: vectorized code
raises them in inactive SIMD lanes and when the compiler speculates
both arms of a select, with correct results, so the traps are a
debugging aid for scalar runs. The trap arguments and the clang maytrap
flag are removed from CMake, and AMReX_TESTING from the CI jobs, which
all check their answers. A new CI job builds Base with AMReX_SIMD=ON;
it drops -fno-operator-names, which vir-simd's alternative tokens
reject.
Stop the configure when AMReX_SIMD is combined with a GPU backend, allow
a few epsilon in the part-1 check for fast-math sqrt, start the docs
listing at the illustration-only comment, shorten the f_select comment
and inline the MPMD agent arguments.
Keep AMReX_TESTING in the CI jobs (it only fills new data with signaling
NaNs; the tutorials add no compiler flags for it), use an array length
that is not a multiple of the SIMD width so the scalar remainder runs,
describe amrex::For as ParallelFor without the CPU promise of independent
iterations, and keep compiler internals out of the Sphinx section.
@WeiqunZhang
WeiqunZhang merged commit bf1e51a into AMReX-Codes:main Nov 5, 2026
20 checks passed
@WeiqunZhang
WeiqunZhang deleted the simd branch November 5, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant