Repository navigation
SYCL backend (1/6): build switch, device list and forward projectors - #902
Conversation
1010aeb to
65a6502
Compare
| // if rounding never quite lets a crossing reach aM. One fetch per step, before | ||
| // the branch on the axis crossed. | ||
| const int maxsteps=(int)geo.nVoxelX+(int)geo.nVoxelY+(int)geo.nVoxelZ+3; | ||
| for (int step=0; step<maxsteps; step++){ |
There was a problem hiding this comment.
The siddon code changed in 3.3.1. I am happy to leave as is, the code that changed was mostly for performance reasons, let me know if you want to leave as is, or imitate 3.3.1
|
Thanks, this is nicely split and easy to follow. A few things before merging:
Fine as follow-up issues, not blocking: the kernels are the 3.3.0 ones (no multi-step Siddon from 3.3.1), and the projectors don't overlap copies with kernels (one buffer per device, a wait per block, split pieces added on the host), unlike CUDA's two streams per GPU. |
|
Thanks Ander, all good points.
I'll keep Siddon as is here and open a follow-up issue to match 3.3.1, plus one for the copy/kernel overlap. |
|
Thanks, all looks good. I've created the One heads-up for the rebase: master has moved on since 3.3.1, and #952 moved the compiled modules into the package. They are now |
SYCL counterparts of GpuIds.cpp, gpuUtils.cu and the four forward projectors in Common/CUDA, with the same headers, plus the shared SYCL helpers (tigre_sycl.cpp/.hpp, tigre_release_on_error.hpp).
sycl is no longer stopped as pending. Only the extensions whose sources are in Common/SYCL are built (SYCL_PENDING lists the others). On that build, importing tigre still works, and a function that needs a missing extension raises ImportError when it is called. _gpuUtils.getBackend() returns "cuda" or "sycl", and CUDA arrays given to Ax/Atb go through host memory on SYCL.
Tests that need an extension the SYCL build does not have yet are skipped. SYCL-only tests: Ax with little device memory, and the Siddon split. Device lists that mix a GPU and the CPU use one kind of device in the multi-device tests.
…ge splitting As Common/CUDA in 3.3.1 (CERN#903, CERN#905, CERN#906, CERN#917): - page_locking.hpp: tigre::hostRegister, hostUnregister and worthPageLocking. The image is page-locked (prepare_for_device_copy) only when it is split or more than 2 devices are used, only on GPUs, and pageable memory is used, with a warning, if page-locking fails. - If allocating the image piece and the projection buffer fails although the estimate says it fits, the image is split in more pieces and allocated again (tigre::tryMallocPieces), down to one slice per piece. - splitImage and splitImageInterp compute the last piece size signed, as CERN#906.
…dget Keep the working-set budget at min(0.95*global, free, TIGRE_SYCL_MEMORY_LIMIT_MB). Split image pieces so each single buffer also stays within max_mem_alloc_size (TIGRE_SYCL_MAX_ALLOC_MB for tests). On devices such as the Arc 140T, a 4 GiB allocation cap with a much larger global memory would otherwise over-split the image.
987fd08 to
9b1ca4c
Compare
|
Retargeted to |
|
Merged into sycl, thanks! Go ahead with 2/6 against sycl when you're ready. Could you also open the two follow-up issues (Siddon to match 3.3.1, and overlapping copies with kernels) so they don't get lost? |
What does this PR do?
This is the first of six PRs for the SYCL backend discussed in #885, split so that each one can be
reviewed on its own. It is based on TIGRE 3.3.1. With
TIGRE_BACKEND=sycl, the Python build compilesthe extensions from a new
Common/SYCLfolder with the oneAPI DPC++ compiler (icpx, oricxonWindows) instead of nvcc. CUDA stays the default. Without
TIGRE_BACKEND, the build looks for CUDAfirst, then HIP, then the SYCL compiler (
TIGRE_SYCL_CXXif set, otherwiseicpx/icx), and printswhat it chose.
Common/CUDAis not changed.Common/SYCLin this PR:GpuIds.cppandgpuUtils.cpp(the device list), the four forwardprojectors (
Siddon_projection*.cpp,ray_interpolated_projection*.cpp), and the shared SYCLhelpers (
tigre_sycl.cpp/.hpp,tigre_release_on_error.hpp,page_locking.hpp). Each file hasthe name of its
Common/CUDAcounterpart and uses the same header.devices (e.g. the CPU).
TIGRE_SYCL_ALL_DEVICES=1lists the other devices after the GPUs.TIGRE_SYCL_MEMORY_LIMIT_MBcaps the memory TIGRE plans with, so the tests can reach thesplitting paths on any device.
used. If page-locking fails, a
TIGRE:hostRegisterwarning is shown and pageable memory is used.more pieces and retried (
tigre::tryMallocPieces), down to one slice per piece.splitImage/splitImageInterpuse the Backprojection on 4+ GPUs: fix the crash when a GPU gets no slices #906 fix, so there are no empty pieces.setup.py:syclis removed fromBACKEND_PENDING.TIGRE_SYCL_CXXoverrides the compiler. OnWindows,
icxcompiles and links instead ofcl.exe. The CUDA part is unchanged; it is onlyindented under
if USE_SYCL: ... else:.Common/SYCL(
SYCL_PENDINGinsetup.py).import tigrestill works there, and a function that needs amissing extension raises
ImportErrorwhen it is called (tigre.utilities.gpu._import_extension).The CUDA build is unaffected: a missing extension still raises at import. In the tests, the
ones that need a missing extension are skipped (
conftest.py). PR 5/6 removesSYCL_PENDING,the stand-ins and the conftest additions again.
_gpuUtils.getBackend()returns"cuda"or"sycl". PyTorch CUDA tensors and CuPy arraysgiven to
tigre.Ax/tigre.Atbgo through host memory on the SYCL build.test_sycl_low_memory.py(Ax with little device memory), a SYCL case intest_siddon_split.py, anddevice_kinds.pyfor device lists that mix a GPU and the CPU.CUDA-only cases are skipped on the SYCL build.
The CI workflow is the next PR, and the SYCL CI results come with it. Docs and a changelog entry come
in 6/6. MATLAB follows separately.
Which parts of TIGRE does it touch?
Common/CUDA). NewCommon/SYCL;Common/CUDAis unchanged.Test environment
2025.2.0, Python 3.11.18, NumPy 2.2.6:
pytest166 passed, 129 skipped (most skips are tests thatneed extensions added in 3/6 to 5/6);
pytest -m extended7 passed, 21 skipped.CPU device to float rounding, unsplit and split.
test_sycl_low_memory,test_siddon_split,thin_shapesandprojectors_gpu: 44 passed, 44 skipped (36 need_Atb, 8 need 2 GPUs).Earlier versions of this backend, on TIGRE 3.2.0, Windows 11 Pro, oneAPI 2025.2 (not rerun on this
version): the test suite passed on an Intel Arc 140T, an Intel Arc Pro B50 and an Intel Arc Pro
B70 (Level Zero), and on the Arc Pro B70 together with an Intel Core Ultra 7 265F (Intel OpenCL
CPU runtime) in one device list. On an Intel Core Ultra 9 285H, the projector and TV results were
compared with the other devices' results; the full test suite was not run there.