Skip to content

Spline fixes - #397

Open
jacobmerson wants to merge 4 commits into
SCOREC:developfrom
jacobmerson:spline-fixes
Open

jacobmerson wants to merge 4 commits into
SCOREC:developfrom
jacobmerson:spline-fixes

Conversation

@jacobmerson

Copy link
Copy Markdown
Collaborator

No description provided.

jacobmerson and others added 2 commits October 25, 2026 00:01
Several bugs made the spline evaluators wrong or silent on CUDA:

- Device builds default Rank2View to layout_left, but the evaluate
  kernels addressed rows of fval with row-major.
- Missing barriers with TeamThreadRange.
- Swap std::array to Kokkos::Array and std::min/std::max to kokkos
  version so code works without --expt-relaxed-constexpr
- The 1D coefficient init and the 2D MDRange launches used the default
  execution space. Interpolator in HostSpace launched device
  kernels on host pointers.
Check that 1D and 2D selectors return the requested derivatives in
PSPLINE column order without touching unused columns, that the explicit
and compact representations agree for every boundary condition, and
that bicubic splines reproduce a product of cubics for every end
condition such a product satisfies.

Port the checks of PSPLINE's pspltest that the spline tests lacked:
- splines on 3 to 5 points sampled from a two-point spline, with the
  same derivative ends, are that spline (smalltest)
- 2D splines periodic in one direction only are exact along the
  periodic nodes and wrap only the periodic axis (bpspline, bpsplinb)
- 1D value, first and second derivative errors converge at orders 4,
  3 and 2, and 2D values at order 4 (pspltest1, pspltest2)
- zero samples follow non-zero end and face data, and periodic splines
  of constant data are constant (smalltest)
- queries within the lookup tolerance outside a non-periodic grid are
  clamped to the end; queries beyond it are left untouched

Note: most of the test porting in this commit was done by Claude.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The tightened uniformity tolerance rejects valid translated grids because it does not account for coordinate-scale roundoff.

1 open issue
What changed in this PR

This PR improves PCMS cubic and bicubic spline correctness and host/device portability, with extensive regression coverage.

Changes:

  • Fix boundary-condition handling, workspace indexing, synchronization, and output layout handling.
  • Tighten grid validation and add periodic query wrapping and safer range checks.
  • Expand spline tests and include the spline header in the field installation list.
File Description
test/​test_spline_interpolator.cpp Updates view handling and adds numerical, boundary-condition, and portability tests.
test/​field_test_utils.h Adds a helper for creating device rank-one views from vectors.
src/​pcms/​field/​evaluator/​spline_interpolator.hpp Fixes spline construction, evaluation, synchronization, and validation.
src/​pcms/​field/​CMakeLists.txt Adds the spline interpolator header to the installation list.

Review effort: Balanced

Comment on lines +72 to +73
bool is_uniform_ascending = isUniformAscending<T, MemorySpace>(
x, std::sqrt(std::numeric_limits<T>::epsilon()));

This branch was successfully deployed

1 active deployment
asics — d3225e2a Deployed Oct 25, 2026 by jacobmerson via build_and_test #365
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.

2 participants