Skip to content

Argument class for SplineFunction kernel arguments - #721

Draft
max-models wants to merge 4 commits into
polar-splines-cupyfrom
spline-function-args-class
Draft

max-models wants to merge 4 commits into
polar-splines-cupyfrom
spline-function-args-class

Conversation

@max-models

@max-models max-models commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Stack: part 10 of 14, based on #720 (merge that first), next: #724. Full order: #709 → #708 → #711 → #712 → #705 → #713 → #714 → #718 → #720 → #721 → #724 → #725 → #723 → #722.

Stack merge: in SplineFunction.__init__ (feec/psydac_derham.py), the SplineArguments/CudaSplineArguments are now built after #709's degree check and its host-to-device copy of the knots.


Solves the following issue(s):

Solves #678 (the remaining point: #667 (comment)). Part of #650.

Core changes:

SplineFunction no longer builds (kind, pn, tn1, tn2, tn3, starts) tuples for the spline evaluation kernels. It now uses an argument class pair, like DerhamArguments/CudaDerhamArguments:

  • New pyccel class kernel_arguments/spline_args_kernels.SplineArguments(kind, pn, tn1, tn2, tn3, starts) and its CUDA twin kernel_arguments/spline_args_cuda.CudaSplineArguments (a CudaStructArguments with struct SplineArgs). The header kernel_arguments/spline_args.cuh is generated by the new write_spline_header(). SPLINE_STRUCTS is added to CUDA_STRUCTS.
  • SplineFunction.__init__ creates one argument object per component: SplineArguments on NumPy, CudaSplineArguments on CuPy. They are stored in _args_spline, which replaces _args_eval. The CUDA degree check (degrees 1 to 8) moves from SplineFunction into CudaSplineArguments, the same as in CudaDerhamArguments.
  • eval_spline_mpi_markers, eval_spline_mpi_matrix and eval_spline_mpi_sparse_meshgrid (pyccel and CUDA, still 1:1) take args_spline instead of the six loose arguments. The shared helper eval_spline_mpi (pyccel and __device__) keeps its flat signature, because other kernels call it too.
  • CudaSplineArguments accepts only C-contiguous knot vectors. SplineFunction already passes contiguous ones, so test_evaluation_parity now uses contiguous knots instead of strided views.

No CUDA kernel other than these three takes the spline arguments, and pushers and accumulation already use DerhamArguments. One possible follow-up: eval_spline_mpi_tensor_product_fixed is a pyccel-only kernel in evaluation_kernels_3d.py that SplineFunction still calls with loose kind, pn, starts (no knots).

Tests:

  • test_kernel_backends.py: the new pair is added to ARGUMENT_PAIRS, so the mirror check (and the struct layout check on a GPU) covers it. New test test_generated_spline_header. The owner test checks that SplineFunction creates SplineArguments on NumPy.
  • kernel_test_args.spline_evaluation_arguments returns (_data, args_spline), so the parity and emulation cases now pass the argument object. test_cuda_emulation.CUDA_CLASSES includes CudaSplineArguments.

Local tests (macOS, no GPU), after recompiling the changed kernels:

  • bsplines/tests, feec/tests/test_eval_field.py, feec/tests/test_derham_gpu.py, pic/tests/test_cuda_emulation.py, pic/tests/test_kernel_backends.py, pic/tests/test_cuda_parity.py, pic/tests/test_pushers.py, pic/tests/test_accum_vec_H1.py: 258 passed, 315 skipped. On devel, the same files gave 256 passed, 314 skipped; the differences are the 2 new tests and 1 new GPU-only skip.
  • mpirun -n 2 on bsplines/tests/test_eval_spline_mpi.py, feec/tests/test_eval_field.py, pic/tests/test_pushers.py, pic/tests/test_accum_vec_H1.py: 139 passed (139 on devel).
  • CPU emulation of the three CUDA kernels against pyccel passes (test_emulated_parity[eval_spline_mpi_*]).
  • With cunumpy's fake CuPy, an ad-hoc check built CudaSplineArguments and packed the struct, and the degree check and the rejection of host arrays both work. The fake CuPy cannot construct a full Derham, so SplineFunction on CuPy was not run end-to-end.

GPU tests were not run (no GPU available). This affects the struct layout, the parity tests and test_spline_function_backends[cupy].

Model-specific changes:

None.

Documentation changes:

CUDA_STRATEGY.md: the new pair is added to the argument class table and the current-state table, plus a short note in the PR 16 implementation notes.

🤖 Generated with Claude Code

max-models and others added 2 commits October 7, 2026 22:50
SplineFunction builds one SplineArguments (CudaSplineArguments on CuPy) per
component, holding kind, pn, tn1, tn2, tn3 and starts. The eval_spline_mpi_*
entry kernels (pyccel and CUDA) take it as args_spline instead of six loose
arguments. New struct SplineArgs in kernel_arguments/spline_args.cuh,
generated by write_spline_header().

Solves #678.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stack the PR on #720.

Conflict in feec/psydac_derham.py (SplineFunction.__init__): SplineArguments/CudaSplineArguments of #721 built
from the degree check and the host-to-device copy of the knots of #709.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@max-models
max-models changed the base branch from devel to polar-splines-cupy October 7, 2026 22:16
max-models added a commit that referenced this pull request Oct 7, 2026
Stack the PR on #721.

Conflicts in CUDA_STRATEGY.md: checklist entries in PR order, kept the notes of every PR.
Semantic fix for #721 below: SplineFunction.eval_tp_fixed_loc takes kind, pn and starts from the
SplineArguments of the component (self._args_spline) instead of the removed tuple self._args_eval.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
max-models added a commit that referenced this pull request Oct 7, 2026
…d starts from SplineArguments

spline_evaluation_arguments returns (_data, args_spline) since #721.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
max-models added a commit that referenced this pull request Oct 7, 2026
Stack the PR on #725.

Conflicts: feec/mass.py, boundary_mass.py, basis_projection_ops.py (took #725's kernel folders; their outputs moved
into the folders), test_cuda_emulation.py (#723's argument_arrays check on top of the tests added below),
CUDA_STRATEGY.md (kept both notes).
Semantic fixes for the PRs below:
- OUTPUTS for the 16 FEEC assembly folders of #725 (same arguments as the former PyccelKernel(outputs=...)
  wraps, plus kernel_*d_vec and surface_kernel_3d_vec) and for eval_spline_mpi_tensor_product_fixed (#724).
- OUTPUTS of eval_spline_mpi_markers/matrix/sparse_meshgrid point at values in the SplineArguments
  signatures of #721 (3, 5, 5).
- argument_arrays (cuda_parity_cases.py) knows CudaSplineArguments (#721).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
max-models added a commit that referenced this pull request Oct 8, 2026
Stack the PR on #723.

Conflicts: eval_spline_mpi_{markers,matrix,sparse_meshgrid}_cuda.cu (SplineArgs of #721 with the qualified
evaluation_kernels_3d::eval_spline_mpi), linalg_kernels.cuh, filler_kernels.cuh, particle_to_mat_kernels.cuh
(helpers of #705/#713 moved into their module namespaces).
Semantic fixes: the struphy_cuda::<pyccel module> rule applied to the CUDA code of the PRs below:
linear_vlasov_ampere (#705), vlasov_maxwell (#713), bstar_parallel_3form (#718) and
eval_spline_mpi_tensor_product_fixed (#724) use 'using namespace struphy_cuda;' and qualified helper calls;
m_v_fill_b_v1_symm calls filler_kernels:: and evaluation_kernels_3d::; the fill_v1_symm test wrapper
calls particle_to_mat_kernels::m_v_fill_b_v1_symm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@max-models
max-models added this pull request to stack #728 October 8, 2026 05:45
@max-models
max-models removed this pull request from stack #728 October 8, 2026 06:00
@max-models
max-models added this pull request to stack #729 October 8, 2026 06:00
@max-models
max-models marked this pull request as draft October 8, 2026 09:13

This branch has not been deployed

No deployments
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