Repository navigation
Conversation
…devices), with colored assembly The per-element body of the masked kernel becomes elementMaskedOne, called from the host loop and from Kokkos functors; ADRH_FN is KOKKOS_INLINE_FUNCTION under ADRH_USE_KOKKOS, so the headers are one source for both. New: kokkos_kernel.h (element kernel; fused assembly into the global residual and a block-CSR Jacobian with greedy element coloring, no atomics), bench_kokkos.cpp, module_kokkos.cpp (adrh_kokkos, the host module's interface, so ad_regression.py and compare_with_python.py run on it with ADRH_MODULE), golden.py, build_kokkos.sh. The constexpr_for helpers and the per-element function are always_inline: reached through a member function they stayed real calls and the Poisson kernel ran 3.2x slower than in a plain loop. The same change makes the host prototype faster (masked coupled system 3.4 to 1.3 us per element, masked five-component chain 6.6 to 2.5). affineP1 uses if constexpr for the 2D branch. Checked: the Kokkos kernel is bitwise the host kernel on the CPU; colored assembly has the same bits at every thread count and on both GPUs; element residual and Jacobian against Proteus 8.6e-16 and 6.0e-16; the advection- diffusion regression, 2D and 3D, seven boundary treatments, within 1.2e-14 of the Proteus model. With FMA contraction off, Apple arm64, x86-64 and an NVIDIA GPU give identical bits for the kernels without transcendental functions. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The prototype's masked element kernel runs under Kokkos: threads on a CPU, a GPU through CUDA, from the same headers. Experimental, not part of the proteus build.
masked.h: the loop body is nowelementMaskedOne;elementKernelMaskedis the loop over it.portable.hmakes the functionsKOKKOS_INLINE_FUNCTIONunderADRH_USE_KOKKOS.kokkos_kernel.h:elementKernelKokkos(the prototype's interface) andassembleColored, which colors the elements by node sharing, and in one launch per color computes each element and adds it to the global residual and a block-CSR Jacobian. No atomics.module_kokkos.cpp:adrh_kokkos, same calling convention asadrh_proto.ADRH_MODULE=adrh_kokkos python ad_regression.py(orcompare_with_python.py) runs the existing Proteus comparison on it.golden.pycompares any two builds.bench_kokkos.cpp,build_kokkos.sh, README section.Decision this implements: Kokkos with element coloring for threads and devices in the generated kernels (cekees, 2026-10-24).
Results
Details and the table are in
experimental/adrh/README.md; raw logs are beside the campaign notes.-ffp-contract=off,--fmad=false), Apple arm64, x86-64 and the GPU give identical bits for Poisson and the five-component chain, and identical Jacobians for all four. The two kernels that callsindiffer in the residual's last bit between C libraries and CUDA.A finding in the host prototype
The compile-time loop helpers were left as real calls whenever the kernel was reached through a member function, which pushes every array of the element into memory: the Poisson kernel ran 3.2x slower there than in a plain loop. Kokkos was not the cause. They are
always_inlinenow, which also speeds the host prototype (masked coupled system 3.4 to 1.3 microseconds per element, masked five-component chain 6.6 to 2.5). Host outputs are bit-identical to before except the 2D advection-diffusion arrays, which move by 3e-16 (FMA contraction under the new inlining).affineP1usesif constexprfor its 2D branch (the dead 3D branch indexed out of range).Not done
No pytest: the directory's checks are scripts, and a Kokkos CI leg needs the build-system decision (kernels in a CMake-built library). The CUDA build was run on
ceds-modelonly.🤖 Generated with Claude Code