You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SortingBoxes cannot be created on the CuPy backend #726
SortingBoxes cannot be created on the CuPy backend, so any species with SortingParameters(boxes_per_dim=...) fails during setup on the GPU.
Found in:#719 (end-to-end GPU test for LinearVlasovAmpereOneSpecies). The CuPy run was probed on cunumpy's fake CuPy with CUDA launches emulated on the CPU. With sorting boxes enabled it stops in SortingBoxes, so the test in #719 runs without sorting boxes.
What fails (src/struphy/pic/sorting.py, SortingBoxes._set_boxes, devel 25688c5):
sorting.py:228-230: n_cols = round(n_mkr * (1 + 1 / xp.sqrt(n_mkr) + self._box_bufsize)). On CuPy, xp.sqrt of a Python int returns a 0-d device array, and Python's round() does not accept it.
sorting.py:239: initialize_neighbours(self._neighbours, ...). This is the pyccel kernel from pic/sorting_kernels.py:68, called with the device array self._neighbours created by xp.zeros a few lines above.
SortingBoxes is created in Particles at src/struphy/pic/base.py:2597, so the failure happens at setup, before any box sorting in the time loop.
Suggested fix:
Compute n_cols with math.sqrt (it is host-side bookkeeping, not device data).
Build _neighbours on the host with the pyccel initialize_neighbours and copy it to the device once (setup data). Alternatively, add a CUDA version in its own folder, following CUDA_STRATEGY.md.
Add a fake-CuPy test that creates Particles with boxes_per_dim on CuPy.
This only fixes setup. Sorting the markers into boxes on the device (Particles.put_particles_in_boxes, assign_box_to_each_particle, sort_boxed_particles) is still part of #694, and the SPH models need it.
Related: #694, #719. Part of #650 (see CUDA_STRATEGY.md).
Activity
[gpu-2] Benchmark script for VlasovAmpere and VlasovMaxwell (#735)
[gpu-2] Benchmark script for VlasovAmpere and VlasovMaxwell (#735)
Set up sorting boxes on the CuPy backend (#736)