Repository navigation
Description
Is your feature request related to a problem? Please describe.
TIGRE builds only with CUDA, so it needs an NVIDIA GPU and has no CPU fallback. On machines without one (laptops with integrated graphics, workstations with a discrete Intel GPU, or CPU-only machines), TIGRE cannot be used.
Describe the solution you'd like
An opt-in SYCL build of the compiled modules, next to the CUDA build, which stays the default. A working version is on a fork: https://github.com/Einse57/TIGRE/tree/sycl-on-3.2.0
Common/SYCL/: SYCL versions of all theCommon/CUDAsources the Python build compiles (cone and parallel Siddon and interpolated projectors, the backprojectors, GD_TV, GD_AwTV, tv_proximal, PICCS, RandomNumberGenerator, gpuUtils, GpuIds), plus a small shared helper (tigre_sycl.cpp/.hpp). They implement the same C++ interfaces and reuse the headers inCommon/CUDA.setup.py: withTIGRE_SYCL=1, those sources are compiled with the oneAPI DPC++ compiler (icpx, oricxon Windows;TIGRE_SYCL_CXXoverrides it) instead of nvcc, and no CUDA toolkit is needed. Without the variable, the build is unchanged.Common/CUDAand the Cython bindings are not modified.- Devices: the Level Zero GPUs if there are any, otherwise the other GPUs, otherwise the remaining SYCL devices (such as the CPU through the Intel OpenCL CPU runtime). With
TIGRE_SYCL_ALL_DEVICES=1, the remaining devices are listed after the GPUs.gpuidsindex into that list, andONEAPI_DEVICE_SELECTORfilters it. - Docs: a "SYCL build" section in
docs/install/python.md. - CI:
.github/workflows/sycl.ymlbuilds with conda-forge's DPC++ 2025.2 and runs the full pytest suite on the SYCL CPU device onubuntu-latestandwindows-latest, so thegpu-marked tests also run on GitHub-hosted runners.
Tested on Windows 11 with oneAPI DPC++ 2025.2:
- Intel Arc 140T integrated GPU (Core Ultra 9 285H), Level Zero
- Intel Arc Pro B50 discrete GPU, Level Zero
- Intel Core Ultra 9 285H and Core Ultra 7 265F, Intel OpenCL CPU runtime
The full pytest suite gives 242 passed and 27 skipped on the Arc Pro B50 (commit 54e0ad1) and on the CPU device in the CI workflow (Linux and Windows), and 241 passed and 27 skipped on the Arc 140T (commit e1fab7e, which does not have the last tvdenoise fix or its added test). With PyTorch installed (2.15.0, CPU build), the Arc Pro B50 gives 248 passed and 26 skipped: the 6 tests in test_pytorch_bindings.py then run and pass. The 26 skipped tests are: 8 that need two or more GPUs (with the B50 and the CPU device together, all 8 pass); 2 test files that need PyTorch on a CUDA GPU (test_gpu_arrays.py and test_tv_low_memory.py, each skipped as one module); and 16 that are CUDA-specific (CUDA runtime, texture limits and texture objects). Untested: SYCL on non-Intel GPUs (AMD, NVIDIA), other Intel GPUs, and Intel GPUs on Linux.
Wall-time measurements and GPU vs CPU-device parity: https://github.com/Einse57/TIGRE/blob/sycl-on-3.2.0/notes/MEASUREMENTS.md. For example, algs.fdk on a 128³ volume with 60 projections took 0.035 s on the Arc 140T and 0.023 s on the Arc Pro B50 (0.13 s and 0.089 s on the two CPUs).
One behavioural difference from the CUDA build: CTnoise.add uses a different random number generator, so its values differ for the same input.
Known gaps:
- Python only.
MATLAB/Compile.mhas no SYCL option yet. - Multi-device paths were tested only with one Arc Pro B50 and the Core Ultra 7 265F CPU device in one process (
TIGRE_SYCL_ALL_DEVICES=1): the 8 multi-device tests pass, each device's share of the angles or slices is bitwise equal to its single-device result, and tvdenoise split across the two devices matches the single-device result within 7e-7; two or more GPUs are untested. - The branch now includes master up to tvdenoise: split results equal the unsplit ones (fixes #863) #873 (9f9b7ad, merged, not rebased). The CUDA changes since build: disable pinned memory with TIGRE_NO_PINNED_MEMORY env var #842 are ported to
Common/SYCLwhere they apply: tvdenoise split path: zero the right buffer, wait for copy-back (replaces #806, partly #863) #872 and tvdenoise: split results equal the unsplit ones (fixes #863) #873 (tvdenoise split path), Siddon (cone and parallel): consistent, more accurate and faster traversal (fixes #859) #865 (Siddon traversal, cone and parallel beam), Raise Python exceptions on CUDA errors instead of exit(1); busy GPU i… #854 (errors release device memory, "out of memory" and busy-device messages), TV: split correctly with little free memory; no more endless tvdenois… #864 (TV splitting with little free memory), Use 64-bit sizes where 32-bit integer products wrapped on large problems #868 (64-bit sizes), TV functions: release everything on error, as Ax/Atb do #870 (TV functions release memory on error), and the Ax/Atb "out of memory" check from Python: Ax/Atb take PyTorch CUDA tensors and CuPy arrays, on their GPU #857. Fix texture object leak in Atb (#617) #851 (texture objects), Ax: wait for each batch's copy-out before reusing its buffer; test #860 #861 (copy-out race) and Fix __CUDART_VERSION typo in TV/PICCS warp reduction kernels #862 (CUDART_VERSION) have no SYCL counterpart: the SYCL code uses no textures, in-order queues andsycl::reduction. - CuPy/PyTorch GPU arrays (Python: Ax/Atb take PyTorch CUDA tensors and CuPy arrays, on their GPU #857): the SYCL build copies them through host memory and returns the same kind of array; the SYCL entry points raise if given device pointers directly.
- Overlap the multi-GPU TV halo exchange across GPU boundaries #809's multi-GPU TV changes (halo-only exchange, peer copies) are not ported: they only change multi-GPU timing, and no machine with two or more GPUs was available to test them.
- In the multi-device tvdenoise exchange, the host buffer held one slice per variable while
buffer_lengthslices are copied; with one split andbuffer_length> 1 (e.g. a 128³ image on two devices with 24 MB) this corrupted the heap. Fixed in the SYCL version (54e0ad1).tv_proximal.cusizes its non-peer exchange buffer the same way (4*nExchanges*pixels_per_slice), so the CUDA build may have the same problem on GPUs without peer access; not tested. - With very little device memory (a 6 MB limit on a 64×256×256 image), minTV ends the Python process on Windows, on the GPUs and the CPU device; not yet looked into.
- It is open whether
sycl.ymlshould run in this repository or stay on the fork. A run takes about 10 minutes on Windows and 20 minutes on Linux.
Questions:
- Is an opt-in SYCL build something you would accept in TIGRE?
- If so, how would you prefer it split? For example: (a) build switch,
Common/SYCLsources and docs; (b) the CI workflow; (c) MATLAB support later. One PR or several, rebased on current master.
Describe alternatives you've considered
- HIP, as in [ROCm] Add AMD GPU support to the Python backend #747 (AMD GPUs, also opt-in with CUDA as the default). It covers different hardware and is independent of this proposal. Both change the build-selection part of
setup.py. - OpenCL C kernels, which would mean rewriting the kernels in a separate language. SYCL keeps them in C++ with a structure close to the CUDA sources.
Additional context
Related: #131 (HIP for AMD GPUs), #747 (ROCm/HIP build), #244 (shared Common/ source layout, which a Common/SYCL folder follows).
Activity
AnderBiguri commentedon Nov 19, 2026
Thanks a lot for this, it's a very thorough piece of work.
1. Yes, an opt-in SYCL build is something I'd like to have in TIGRE, with CUDA staying the default. CPU support through the SYCL CPU device is fine too. I'd document it as Intel CPUs (that's what Intel's OpenCL CPU runtime officially supports), with AMD x86 as untested. Ideally if we add CPU code I'd like it to be general for any CPU, but we can just do this and then open an issue describing that CPU support is limited/untested.
2. How to split it: several PRs, each rebased on current master, please. Give me a couple of days until I release TIGRE 3.3.0 with all fixes for GPU code that I have been doing lately, and then:
Common/SYCLand the docs.Common/or the build).As I like to be able to read the code, try to not make gigantic PRs, keep them feature-wise. I assume that at least one will be big "add all SYCL files" or something like that, but in general one feature each makes my life to test and understand the code better.
Build selection: before (a), I'd like to agree on one way to choose the backend, since #747 (HIP) also changes this part of
setup.py, and there is also a Metal (Apple Silicon) backend in progress. Instead of one on/off variable per backend, I'd prefer a singleTIGRE_BACKEND=cuda|hip|sycland, when it's not set, automatic detection based on which compiler is installed (nvcc/CUDA_HOME, thenhipcc/ROCM_PATH, thenicpx/icx), with CUDA first so that machines with an NVIDIA GPU and an Intel iGPU keep building CUDA. The build should print which backend it picked and why. Would that work for you? I'll ask the same on #747 so both PRs use it.Maintenance: CUDA will stay the reference implementation, and I don't have Intel hardware to test on. When CUDA code changes, I'll open an issue for the matching SYCL change, so it would be great if you (or other SYCL users) could keep an eye on those.
Benchmarks: It would be good to have at some point measurements of speed vs CUDA with exactly the same code. If you don't have access to this from your side, you can add a test code that I can rerun on my CUDA machines to compare.
The
tv_proximal.cuexchange buffer: good catch, thanks. I checked current master and the CUDA code has the same problem: the non-peer host buffer has one slice per slot, but each copy movesbuffer_lengthslices, so withbuffer_length > 1the slots overlap and the last one writes past the end. It needs 2+ GPUs without peer access andsplits == 1, which isn't that rare on consumer cards. I'll open a separate issue and fix it in CUDA, it will come before 3.3.0.Einse57 commentedon Nov 19, 2026
Thanks for the review!
TIGRE_BACKEND=cuda|hip|syclwith auto-detection (CUDA first, then HIP, then SYCL) and a printed reason works for me. I'll switch the SYCL build to that.I'll wait for 3.3.0, then rebase and open the PRs in the order you listed.
For CPU support, will document Intel CPUs as supported and AMD x86 as untested.
I'll also do my best to follow the CUDA-to-SYCL issues as they come up.
For the CUDA comparison, I'll add a small script that times the same projectors and algorithms on whichever backend is built, so you can rerun it on your CUDA machines.
Thanks for confirming the
tv_proximal.cubuffer issue.setup.py: choose the GPU backend with TIGRE_BACKEND or from the insta…
Compile.m: choose the GPU backend with -backend, TIGRE_BACKEND or the…
tvdenoise: size the multi-GPU halo host buffer for buffer_length slic…
AnderBiguri commentedon Nov 21, 2026
Hi @Einse57, thanks a lot for the two reports from your SYCL work. Both are fixed in TIGRE 3.3.0 (https://github.com/CERN/TIGRE/releases/tag/v3.3.0):
minTV/AwminTV/minPICCSreading outside the arrays: fixed in TV functions: halos stop at the image's ends (#899); free host memory on success #900. The halos now stop at the image's first and last slice, the same waytvdenoisedoes, and that also covers 1-slice pieces, which read before the start of the array. The new testtest_tv_host_bounds.pyputs the image between unreadable pages, much like your reproduction.Two other changes may be useful for the port:
AwminTVnow shares its host code withminTVand PICCS (tv_gradient_descentinGD_TV.cu), so there's one less copy of the splitting and halo logic to port.TIGRE_BACKEND; sycl currently stops with a message pointing to this issue.Thanks also for the credit in the release notes. Looking forward to the SYCL backend!
AnderBiguri commentedon Nov 21, 2026
Hi @Einse57, thanks for splitting the SYCL work up so nicely. A heads-up: benchmarking 3.3.0 against ASTRA showed that our multi-GPU Ax/Atb spend a large part of each call outside the kernels (page-locking host memory on every call, and sending the whole image or all projections to every GPU). We'll change how the operators handle host memory and split work across GPUs in TIGRE 3.3.1, in the next few days. Since the SYCL projectors mirror the Common/CUDA host code, it may be worth waiting a couple of days before porting more of it, so you port the new version once. The device list, the build switch and the kernels themselves shouldn't be affected.
Sorry again, I should have caught this earlier.
Einse57 commentedon Nov 22, 2026
Thanks for the heads-up. I'll hold the remaining SYCL PRs until 3.3.1 is out, then rebase #902's projector host code onto the new Ax/Atb host-memory and splitting code.
AnderBiguri commentedon Nov 23, 2026
OK done! https://github.com/CERN/TIGRE/releases/tag/v3.3.1
No more refactoring the GPU code anymore from my side, all free to fiddle with! Let me know if you need some understanding on what changed. Most of it was about speed and multi-GPU codes. I suspect large amount of the changes are not trivially transferable to SYCL. In the sense that many of the changes from 3.3.0 to 3.3.1 are about how CUDA compiles kernels, what takes time in an NVIDIA GPU and ways to minimize that.
I do not require the SYCL port to do this deep optimization of the codes, it existing is already a great feature.
Einse57 commentedon Nov 24, 2026
Thanks Ander, really appreciate the 3.3.1 work and the notes. I rebased #902 onto 3.3.1. The SYCL forward projectors now follow the same page-locking and splitting rules, and they match the CPU device on an Arc Pro B70. I'll send CI, Atb, TV and docs one PR at a time after #902.
Docs: Software that uses TIGRE, and a roadmap