Repository navigation
GPU stack 6/8: marker rows prepared inside the push kernels - #787
Open
max-models wants to merge 8 commits into
Open
max-models wants to merge 8 commits into
max-models wants to merge 8 commits into
Conversation
…the push kernels - Particles allocates the marker buffer column-major on the CuPy backend: kernels and the Python column operations access a few columns of many markers, so with a row-major buffer every access touched whole rows and the threads of a warp read addresses a row apart. The CUDA kernels address the buffer through its strides (Array2D<double> in MarkerArgs); NumPy keeps C order for the pyccel kernels. - push_eta_stage and push_vxb_analytic prepare each marker row themselves at stage 0 (MarkerArgs.prepare_rows), so Pusher._push skips the separate prepare_push pass when no init or evaluation kernel runs before them. prepare_push is launched on a 2D grid. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…repare_rows in the CUDA emulation Kernels without a CUDA version run on host copies of the device arrays, which keep the F order (cunumpy.to_numpy uses get(order='A')), and the pyccel kernels reject it: the sorting-box kernels failed on the fake CuPy (test_sorting_boxes_on_cupy_fake_cupy), and the same holds on a GPU for every marker kernel without a CUDA version. The buffer is therefore C-ordered unless the variable is set. The CUDA emulation of the tests reads the struct fields from the pyccel argument objects, which do not have the CUDA-only prepare_rows flag (every emulated marker kernel failed). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 16, 2026
max-models
added this pull request to stack #790
October 16, 2026 08:51
…k-5-diffusion-solve) # Conflicts: # src/struphy/kernel_arguments/pusher_args_cuda.py # src/struphy/pic/base.py # src/struphy/pic/pushing/prepare_push_cuda.cu # src/struphy/pic/pushing/pusher.py
…yout (feectools update)
…yout (fused gradient)
…yout (feectools update, CachedLaunch)
…k-5-diffusion-solve)
…yout (pcg_sr in the shear Alfven solves)
This branch has not been deployed
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.
Part 6 of 8 of the split of #772 (
cuda-aware-mpi-fixes) into stacked PRs. Requires struphy-hub/feectools#104 to be merged into feectoolsdevel-tinyfirst (PR 1 bumps the submodule).push_eta_stageandpush_vxb_analyticprepare each marker themselves at stage 0 (MarkerArgs.prepare_rows): they copy the phase-space coordinates to the rows fromfirst_pusher_idxand zero the rows after them, asprepare_pushdoes.Pusher._pushthen skips the separateprepare_pushlaunch when no init or evaluation kernel runs before them (those may read the prepared rows). The kernels cover the same markers, one thread per used marker (n_markers_used).prepare_rowsis a CUDA-only field ofMarkerArgs. The CUDA emulation of the tests reads it with default 0.Updated after #774 and #775 were merged into devel: on the original branch this PR also stored the marker buffer column-major on the GPU (
order="F"). devel now stores it as(n_cols, n_markers)on both backends, so that part is gone. The row preparation is ported tomarkers(j, ip)indexing.Tests
Local, macOS without a GPU, in a fresh environment with feectools
1d8d47cand the pinned cunumpy, after merging devel (with #774 and #775). The PR passestest_cuda_parity,test_cuda_emulation,test_kernel_backends,test_sorting,test_accum_matrix_cupy,test_preconditioner_cupy,test_poissonandtest_outputon its own. The top of the stack also passes the mass-matrix, preconditioner, Derham-GPU, fused-gradient, Kronecker-block, Poisson, shear Alfvén, post-processing, polar fake-CuPy and allpictests (1477 passed), the examples test for the two profiling cases, the sorting, Poisson and fused-gradient tests undermpirun -n 2, and the device MPI sort on the fake CuPy on 2 and 4 ranks. The Kronecker products match the stencil mass matrices to 5e-16 for M0, M1, M2, M3, Mv, M1n and M2n on a Cuboid, periodic and Dirichlet, on 1 and 2 ranks.Not tested on a GPU here. The CUDA kernels and the device paths need a run on the cluster.
Stack (merge in order)
devel-tiny)devel🤖 Generated with Claude Code