Skip to content

interpolate: masked batch spline evaluation#225

Open
krystophny wants to merge 10 commits into
mainfrom
soa-mask-batch-eval
Open

interpolate: masked batch spline evaluation#225
krystophny wants to merge 10 commits into
mainfrom
soa-mask-batch-eval

Conversation

@krystophny

Copy link
Copy Markdown
Member

Adds masked variants of the hot-path batch spline evaluation routines so callers can avoid recomputing field values for inactive points (e.g. converged particles in SoA Newton iterations).

Changes:

  • add evaluate_batch_splines_3d_many_der2_mask
  • add evaluate_batch_splines_1d_many_der3_mask
  • add unit test test_batch_interpolate_mask
  • fix Makefile parallel build ordering for tools/h5merge (depends on libneo build)

Test evidence:

  • /tmp/libneo_make_test_mask.log

Add masked batch spline evaluation for 2D, plus OpenACC resident kernels

for 1D der2/der3 and 3D der2, using unified per-point cores.

Also export MAX_BATCH_* constants and extend mask tests to cover 2D.
@qodo-code-review

Copy link
Copy Markdown
Contributor

CI Feedback 🧐

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

Action: Build and test

Failed stage: Build [❌]

Failed test name: ""

Failure summary:

The action failed during compilation of the Fortran source src/interpolate/batch_interpolate.f90.
-
gfortran failed while building src/interpolate/CMakeFiles/interpolate.dir/batch_interpolate.f90.o
because a referenced symbol is missing from a module.
- Error at
src/interpolate/batch_interpolate.f90:31: Symbol 'evaluate_batch_splines_2d_many_mask' ... not found
in module 'batch_interpolate_2d'.
- This caused ninja to stop (subcommand failed), which made make
fail and the GitHub Action exit with code 2.

Relevant error logs:
1:  ##[group]Runner Image Provisioner
2:  Hosted Compute Agent
...

1116:  [370/566] Building Fortran object test/CMakeFiles/test_transport.x.dir/transport/test_transport.f90.o
1117:  [371/566] Building Fortran object CMakeFiles/coil_convert.x.dir/src/magfie/coil_convert.f90.o
1118:  [372/566] Building Fortran object test/CMakeFiles/test_collision_freqs.x.dir/collisions/test_collision_freqs.f90.o
1119:  [373/566] Building Fortran object CMakeFiles/vacfield.x.dir/src/magfie/vacfield.f90.o
1120:  [374/566] Building Fortran object extra/MyMPILib/CMakeFiles/MyMPILib.dir/Internal/wuDataRequester_module.f90.o
1121:  [375/566] Building Fortran object test/CMakeFiles/test_binsrc.x.dir/source/test_binsrc.f90.o
1122:  [376/566] Building Fortran object test/CMakeFiles/test_boozer_coordinates_exports.x.dir/source/test_boozer_coordinates_exports.f90.o
1123:  [377/566] Building Fortran object test/CMakeFiles/test_arnoldi.x.dir/source/test_arnoldi.f90.o
1124:  [378/566] Building Fortran object test/CMakeFiles/test_geqdsk_tools.x.dir/source/test_geqdsk_tools.f90.o
1125:  [379/566] Building Fortran object test/CMakeFiles/test_hdf5_tools.x.dir/source/test_hdf5_tools.f90.o
1126:  [380/566] Building Fortran object test/CMakeFiles/test_system_utility.x.dir/source/test_system_utility.f90.o
1127:  [381/566] Building C object test/CMakeFiles/test_system_utility.x.dir/__/src/local_rusage.c.o
1128:  [382/566] Building Fortran object test/CMakeFiles/test_simpson.x.dir/source/test_simpson.f90.o
1129:  [383/566] Building Fortran object src/interpolate/CMakeFiles/interpolate.dir/batch_interpolate_3d.f90.o
1130:  [384/566] Building Fortran object src/interpolate/CMakeFiles/interpolate.dir/batch_interpolate.f90.o
1131:  FAILED: [code=1] src/interpolate/CMakeFiles/interpolate.dir/batch_interpolate.f90.o include/batch_interpolate.mod 
1132:  /usr/bin/gfortran -I/home/runner/work/libneo/libneo/src/interpolate -I/usr/lib/x86_64-linux-gnu/fortran/gfortran-mod-15/openmpi -I/usr/lib/x86_64-linux-gnu/openmpi/lib -I/usr/include -O3 -Jinclude -fPIC -fPIC -g -cpp -fno-realloc-lhs -fmax-errors=1 -fbacktrace -ffree-line-length-132 -O3 -DNDEBUG -ffast-math -ffp-contract=fast -funroll-loops -ftree-vectorize -march=x86-64-v2 -mtune=generic -Wtrampolines -Werror=trampolines -fpreprocessed -c src/interpolate/CMakeFiles/interpolate.dir/batch_interpolate.f90-pp.f90 -o src/interpolate/CMakeFiles/interpolate.dir/batch_interpolate.f90.o
1133:  /home/runner/work/libneo/libneo/src/interpolate/batch_interpolate.f90:31:67:
1134:  31 |                                     evaluate_batch_splines_2d_many, &
1135:  |                                                                   1
1136:  Error: Symbol ‘evaluate_batch_splines_2d_many_mask’ referenced at (1) not found in module ‘batch_interpolate_2d’
1137:  compilation terminated due to -fmax-errors=1.
1138:  [385/566] Building Fortran object src/magfie/CMakeFiles/magfie.dir/bdivfree.f90.o
1139:  [386/566] Building Fortran object test/CMakeFiles/test_util.x.dir/source/test_util.f90.o
1140:  [387/566] Building Fortran object test/CMakeFiles/test_plag_coeff.x.dir/source/test_plag_coeff.f90.o
1141:  [388/566] Building Fortran object extra/MyMPILib/CMakeFiles/MyMPILib.dir/Generic/scheduler_module.f90.o
1142:  [389/566] Building Fortran object src/contrib/CMakeFiles/CONTRIB.dir/minpack.f90.o
1143:  ninja: build stopped: subcommand failed.
1144:  make: *** [Makefile:27: ninja] Error 1
1145:  ##[error]Process completed with exit code 2.
1146:  ##[group]Run actions/upload-artifact@v4

Add evaluate_batch_splines_2d_many_mask and evaluate_batch_splines_2d_many_der_mask,
mirroring the 1d/3d masked variants: masked-out points are skipped so caller-set
entries (sentinels) are preserved. These were already exported and exercised by
test_batch_interpolate_mask but never implemented, leaving the branch unbuildable.
The masked/core/resident batch evaluation routines added on this branch were the
only ones in their modules lacking the recursive attribute that every sibling
carries (needed for OpenMP thread safety under gfortran -fcheck=all). Add it.
- batch_interpolate_1d.f90: revert 18 subroutine headers reflowed to
  3-space while their bodies stayed 4-space, restoring internal
  consistency.
- interpolate.f90 construct_splines_3d: restore properly nested
  do-loop indentation, lost in a merge conflict resolution that
  picked the unrelated branch's flattened style over main's.
- batch_interpolate_types.f90: drop MAX_BATCH_QUANTITIES/MAX_BATCH_ORDER,
  never referenced anywhere and no fixed-size arrays to bound.
- batch_interpolate_2d.f90: add evaluate_batch_splines_2d_many_mask_resident
  with OpenACC directives mirroring the existing
  evaluate_batch_splines_2d_many_resident pattern, and wire dispatch
  into evaluate_batch_splines_2d_many_mask. evaluate_batch_splines_2d_many_der_mask
  stays CPU-only: its unmasked sibling evaluate_batch_splines_2d_many_der
  has no resident/acc variant either (it uses heap-allocated local
  work arrays inside the per-point loop), so there is no established
  pattern to mirror there.
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