Skip to content

Remap optimizations - #61

Open
jacob-moore22 wants to merge 6 commits into
mainfrom
Remap_Optimizations
Open

jacob-moore22 wants to merge 6 commits into
mainfrom
Remap_Optimizations

Conversation

@jacob-moore22

Copy link
Copy Markdown
Collaborator

Description

Extracts the final optimization stage (REMAP_OPT=6) out of the experimental
remap_dg_lumped_test_cuda.cpp into a clean, standalone implementation at
examples/reference_element/src/remap_dg_lumped_optimized.cpp, and factors the
3x3 Jacobian math that was duplicated across its kernels into reusable inline
Kokkos helpers.

remap_dg_lumped_test_cuda.cpp carried six cumulative optimization levels behind
#if REMAP_OPT >= N, plus scaffolding that only existed for experimentation. None
of it was wired into the build. This PR keeps only the level-6 code path and drops
the scaffolding, taking the file from 2263 to 1503 lines while reproducing the
reference results exactly.

Optimizations retained (all previously validated at level 6):

  • flat 1D index spaces instead of the FOR_FIRST/FOR_SECOND team policy
  • Jacobian, determinate and inverse computed once per quadrature point in a
    dedicated pass rather than once per DOF
  • field/velocity reconstruction hoisted out of the DOF loop
  • reference-element tables replicated in the layouts the kernels read, so a warp
    walks contiguous doubles
  • register-resident surface Jacobian and a fused single-pass L1/L2 error kernel
  • no host fences between stream-ordered kernels

New shared helpers in src/geometry/geometry.h, taking 9 doubles rather than
views, as the natural counterpart to the existing scalar det_3x3:

  • invert_3x3(det, j00..j22, i00..i22) — the scalar Cramer inverse that
    cramers_rule.hpp was missing (it has view-based forms only). This removes a
    ~30-line block that was copy-pasted verbatim between build_element_geometry
    and build_surface_flux.
  • nanson_area_normal(...) — reference normal to physical area normal

How Has This Been Tested?

The clean version is compared against remap_dg_lumped_test_cuda.cpp built with
-DREMAP_OPT=6, which is the exact code it was extracted from, so the two are
expected to agree bit-for-bit rather than merely to within a tolerance.

This was done on serial, OpenMP, and Cuda builds, and all passed.

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