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

+25 -5
View File
@@ -80,7 +80,8 @@ set(RAD_TEST_SHARDS_gbnf_test 4)
#
# ROCR_VISIBLE_DEVICES=99 hides every card, so a unit test runs on the host backend on every
# machine: the same code everywhere, and nothing touches a card a server is using. The _card
# entries below run the device tests on a card.
# entries below run the device tests on a card. A SYCL build hides its cards the same way with
# ONEAPI_DEVICE_SELECTOR (the backend uses Level Zero devices only).
#
# RAD_TEST_STRICT=1: a plugin or fixture this build makes is never legitimately absent, so a test
# that cannot find one fails rather than skips. RAD_TEST_TMPDIR puts radtest::tmpdir() in the build
@@ -109,7 +110,11 @@ set(RAD_TEST_OMP_ENV "OMP_WAIT_POLICY=passive" "OMP_NUM_THREADS=${RAD_TEST_OMP_T
set(RAD_TEST_CARD_ENV "RADIANCE_HOME=${CMAKE_BINARY_DIR}/radiance_home" ${RAD_TEST_OMP_ENV}
"RAD_TEST_STRICT=1" "RAD_TEST_TMPDIR=${CMAKE_BINARY_DIR}/tmp"
${RAD_TEST_SAN_ENV})
set(RAD_TEST_ENV ${RAD_TEST_CARD_ENV} "ROCR_VISIBLE_DEVICES=99")
set(RAD_TEST_HIDE_ENV "ROCR_VISIBLE_DEVICES=99")
if(RAD_SYCL_FOUND)
list(APPEND RAD_TEST_HIDE_ENV "ONEAPI_DEVICE_SELECTOR=!level_zero:*")
endif()
set(RAD_TEST_ENV ${RAD_TEST_CARD_ENV} ${RAD_TEST_HIDE_ENV})
# Binaries that need more CPU than the default budget, and what costs it. Lower an entry when its
# cost comes down, so the tripwire stays tight.
@@ -244,6 +249,21 @@ if(RAD_HIP_FOUND)
endforeach()
endif()
# The same on an Intel GPU through the SYCL backend, labelled sycl. The oneAPI environment must be
# loaded (the runtime finds its Level Zero adapter through it), and RAD_TEST_BACKEND=sycl makes a
# run that fell back to the host backend fail instead of passing on the CPU. RADIANCE_SYCL_TIMING=1
# turns event timing on, which the backend leaves off by default (core/device/sycl.cpp), so the
# whole device contract is under test.
if(RAD_SYCL_FOUND)
foreach(n device_test)
add_test(NAME ${n}_sycl COMMAND ${n} -perf_)
set_tests_properties(${n}_sycl PROPERTIES
LABELS sycl
TIMEOUT ${RAD_TEST_TIMEOUT}
ENVIRONMENT "${RAD_TEST_CARD_ENV};RAD_TEST_BACKEND=sycl;RADIANCE_SYCL_TIMING=1")
endforeach()
endif()
# ================================================================== whole models on the CPU
#
# engine_e2e_test runs the radiance binary on tiny synthetic checkpoints (tests/tiny_model.h) on
@@ -362,7 +382,7 @@ if(TARGET libavx AND TARGET rad-avx-check)
add_test(NAME avx_check
COMMAND rad-avx-check --ref ${RAD_PLUGIN_OUT}/kernels/libref.so
--avx ${RAD_PLUGIN_OUT}/kernels/libavx.so)
set(env ${RAD_TEST_OMP_ENV} "ROCR_VISIBLE_DEVICES=99" ${RAD_TEST_SAN_ENV})
set(env ${RAD_TEST_OMP_ENV} ${RAD_TEST_HIDE_ENV} ${RAD_TEST_SAN_ENV})
set_tests_properties(avx_check PROPERTIES TIMEOUT ${RAD_TEST_TIMEOUT} ENVIRONMENT "${env}")
endif()
@@ -376,7 +396,7 @@ if(TARGET rad-avx-check AND TARGET libref)
COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/avx_check_general.sh
$<TARGET_FILE:rad-avx-check> ${RAD_PLUGIN_OUT}/kernels/libref.so
$<TARGET_FILE:avx_subset_plugin>)
set(env ${RAD_TEST_OMP_ENV} "ROCR_VISIBLE_DEVICES=99" ${RAD_TEST_SAN_ENV})
set(env ${RAD_TEST_OMP_ENV} ${RAD_TEST_HIDE_ENV} ${RAD_TEST_SAN_ENV})
set_tests_properties(avx_check_general PROPERTIES TIMEOUT ${RAD_TEST_TIMEOUT} ENVIRONMENT "${env}")
endif()
@@ -530,7 +550,7 @@ add_test(NAME ops_doc
set_tests_properties(ops_doc PROPERTIES
SKIP_RETURN_CODE 77
TIMEOUT ${RAD_TEST_TIMEOUT}
ENVIRONMENT "ROCR_VISIBLE_DEVICES=99")
ENVIRONMENT "${RAD_TEST_HIDE_ENV}")
# tools/rad-export. Its standard-library checks always run; the merge arithmetic runs where torch
# and safetensors import, and the PEFT comparison where peft and transformers do too.
+15
View File
@@ -93,6 +93,21 @@ std::string temp_path(const char* tag) {
/* ------------------------------------------------------------------ identity */
/* RAD_TEST_BACKEND names the backend a run is registered for (the sycl-labelled entries set it).
* A run that fell back to another backend, typically the host one for want of a driver
* environment, fails here instead of passing every case on the CPU. */
TEST(the_backend_is_the_one_the_run_names) {
const char* want = std::getenv("RAD_TEST_BACKEND");
if (!want || !*want) return;
if (std::strcmp(rad::device_backend_name(), want) != 0)
fprintf(stderr, " RAD_TEST_BACKEND=%s but the %s backend is running: %s\n", want,
rad::device_backend_name(),
std::strcmp(want, "sycl") == 0
? "load the oneAPI environment (. /opt/intel/oneapi/setvars.sh)"
: "is the device visible?");
CHECK_EQ(std::string(rad::device_backend_name()), std::string(want));
}
TEST(backend_reports_itself) {
const char* name = rad::device_backend_name();
CHECK(name && *name);