device: the SYCL backend -- Intel GPUs through oneAPI over Level Zero

A fourth DeviceBackend, in librad_sycl.so: in-order sycl::queues on one context, events as
barriers, copies and fills on the queue, gates as a spin kernel on a pinned flag, and the core's
advance and weight-table kernels as SYCL twins of their .hip files. RadStreams are RadSyclStreams
(abi/rad_sycl.h). Pinned host memory is page-aligned memory registered for device copies, since
O_DIRECT cannot read into SYCL's malloc_host pages; event timing is opt-in (RADIANCE_SYCL_TIMING=1)
because profiling queues cost ~20 us of host time a submission.

The SYCL code is its own CMake project, sycl/, configured with icpx through ExternalProject, so the
engine and every host plugin stay on the main compiler: a SYCL build's host code is the default
build's. RAD_SYCL (default OFF), build.sh --sycl, the sycl presets; HIP and SYCL in one build are
refused at configure.

On the SYCL backend --tp > 1 and ops resolved only to host kernels stop the start, since the Intel
backend runs on one card and never puts an op on the CPU. A SYCL build that sees no GPU warns that
it runs on the CPU and names the missing oneAPI environment.

device_test runs on the Arc Pro B65 as device_test_sycl (label sycl): 36 cases pass, 12 skip
(elastic memory, not provided; host-backend-only cases). Host tests hide Level Zero GPUs with
ONEAPI_DEVICE_SELECTOR. The host tier is the baseline's in both the default and the SYCL build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
claudeandClaude Opus 5.5 committed 2026-10-23 15:38:42 +02:00
1 parent 17524c95bd
commit 8addda231b
19 files changed
+1302 -39

No files matched your search

+16 -14
View File
@@ -194,16 +194,17 @@ implementations are already behind it. So no wrapper is introduced and the HIP p
| vtable entry | SYCL / Level Zero |
|---|---|
| `count`, `set`, `props` | GPU devices of the Level Zero platform; `props.arch` from `ext::oneapi::experimental::info::device::architecture` (`"intel_gpu_bmg_g31"`); `n_cu` = `max_compute_units` (160), `warp_size` = 16 (the sub-group the kernels use), `lds_bytes` = `local_mem_size`, `vram_free` from `ext::intel::info::device::free_memory` |
| `alloc` | `RAD_MEM_DEVICE` -> `malloc_device`; `HOST_PINNED` and `HOST_MAPPED` -> `malloc_host` (device-reachable, same address both sides, so `host_ptr`/`device_ptr` are identity); `HOST` -> plain `malloc` |
| streams | one in-order `sycl::queue` per stream on one shared `sycl::context`; `high_priority` -> `ext::oneapi::property::queue::priority_high` |
| events | `queue::ext_oneapi_submit_barrier()` returns the record; `event_wait` = `ext_oneapi_submit_barrier({e})` on the waiting queue (no host sync); `query` / `sync` on the event; `elapsed_ms` from profiling info (queues created with `enable_profiling`; its cost to be measured, and dropped if it shows) |
| `alloc` | `RAD_MEM_DEVICE` -> `malloc_device` behind a room check; `HOST_PINNED` and `HOST_MAPPED` -> page-aligned memory registered with `prepare_for_device_copy` (not `malloc_host`, which O_DIRECT cannot target; D10), same address both sides; `HOST` -> plain `malloc` |
| streams | one in-order `sycl::queue` per stream on one shared `sycl::context`; `high_priority` -> `ext::oneapi::property::queue::priority_high`; no `enable_profiling` unless `RADIANCE_SYCL_TIMING=1` (it costs ~20 us of host time a submission, D9) |
| events | `queue::ext_oneapi_submit_barrier()` returns the record; `event_wait` = `ext_oneapi_submit_barrier({e})` on the waiting queue (no host sync); `query` / `sync` on the event; `elapsed_ms` from profiling info, under `RADIANCE_SYCL_TIMING=1` only |
| copies, fills | `queue::memcpy`, `memset`; 2-D copy as `ext_oneapi_copy2d` or a row loop; ranges and lists as one small kernel / a loop of copies |
| `host_wrote` | nothing: USM host allocations are coherent for the device at submission |
| `vram_used` | `ext::intel::info::device::free_memory` |
| `pci_address` | `ext::intel::info::device::pci_address` |
| `runtime_version` | the SYCL platform version string |
| tapes | null at first; later `sycl_ext_oneapi_graph` (Phase 4, if submission overhead dominates decode) |
| vmem, DMA lane, link holds, rides, prefetch, gates | null (each a supported configuration) |
| gates | a one-work-item kernel spinning on a flag in pinned host memory |
| vmem, DMA lane, link holds, rides, prefetch | null (each a supported configuration) |
`select_backend()` tries, in order: AQL (if built with HIP and an AMD card is visible), SYCL (if built
with SYCL and a Level Zero GPU is visible), host. `RADIANCE_DEVICE_BACKEND=sycl|aql|host` (new)
@@ -261,16 +262,17 @@ without weights already fail as holes. `--debug-graph` shows the resolution eith
- `RAD_SYCL` (`OFF | ON | AUTO`, default **OFF**), `build.sh --sycl`, a `sycl` preset, a `sycl` ctest
label (card tests, `SKIP_RETURN_CODE 77` without a Level Zero GPU, like `gpu`).
- **Compiler.** CMake has no SYCL language, and `-fsycl` sources need `icpx`. With `RAD_SYCL=ON` the
whole build uses `icpx` as `CMAKE_CXX_COMPILER` and only SYCL sources get `-fsycl` (with
`-fsycl` on the link of targets holding them). Configure refuses `RAD_SYCL=ON` with another C++
compiler, naming the fix (`-DCMAKE_CXX_COMPILER=icpx`, which `build.sh --sycl` passes).
**`icpx` defaults to `-fp-model=fast`**; the SYCL build passes `-ffp-model=precise` to host code so
libref and libavx compute what they compute under GCC, and the host tier is run in the SYCL build
too to show it. The default build (GCC, `RAD_SYCL=OFF`) is unchanged.
*Fallback* if host code under `icpx` does not reproduce the GCC results: build the SYCL pieces
(`core/device/sycl.cpp` as a small C-ABI shared library, `libxe2`) as a separate CMake project
with `icpx` through `ExternalProject`, leaving the main build on GCC.
- **Compiler.** CMake has no SYCL language, and `-fsycl` sources need `icpx`. The first plan, the
whole build on `icpx`, failed: libavx calls `_pdep_u64` without `-mbmi2`, which GCC accepts and
clang refuses (`SYCL_PROGRESS.md` D6). So **the main build stays on its own compiler in every
configuration**, and the SYCL code is a separate CMake project, `sycl/`, configured with `icpx`
through `ExternalProject`: `librad_sycl.so` (the device backend with the core's SYCL kernels;
one C entry point, `rad_sycl_backend`, and a callback table for the engine's logger and error
slot, `core/device/sycl_host.h`) and later `libxe2.so`. Host code in a SYCL build is therefore the
default build's. `icpx` defaults to `-fp-model=fast`; the sub-build passes `-ffp-model=precise`.
- **Run time.** The SYCL runtime `dlopen`s its Level Zero adapter, which needs oneAPI's `umf/`
libraries, so the engine runs under the oneAPI environment (`. /opt/intel/oneapi/setvars.sh`).
Without it no GPU is visible and the engine warns that it is running on the CPU.
- **HIP and SYCL in one build**: allowed in principle (HIP is its own CMake language), but untestable
here (no ROCm). The first version refuses `RAD_SYCL=ON` together with a found HIP at configure
time with a clear message; lifting that is a later change made on a machine with both.