This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/build.sh
T
claudeandClaude Opus 5.5 8addda231b 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
2026-10-23 15:38:42 +02:00

63 lines
2.8 KiB
Bash
Executable File

#!/bin/sh
# build.sh -- configure, build and run the fast tests.
#
# With no arguments the build configures itself: if hipcc is present and a card can be enumerated,
# device kernels are compiled for that card's architecture, and otherwise the host backend is
# built. The host backend is a real implementation, not a stub -- everything except device kernels
# is exercised through it -- so a machine with no ROCm is a supported development configuration.
#
# Pass -DRAD_GPU_TARGETS=<arch>[;<arch>...] to cmake to compile for cards this machine does not
# have. Which of them actually get kernels is decided by the kernel libraries present; each one
# declares the architectures it serves.
#
# ./build.sh configure + build + the fast tests (ctest -L fast)
# ./build.sh -c wipe the build directory first
# ./build.sh --no-hip force the host backend even where hipcc exists
# ./build.sh --asan AddressSanitizer + UBSan, host backend, in build-asan/
# ./build.sh --tsan ThreadSanitizer, host backend, in build-tsan/
# ./build.sh --sycl the Intel GPU (SYCL) backend, in build-sycl/: the engine as usual, its
# SYCL code built by icpx (oneAPI); docs/SYCL_PORTING.md
# ./build.sh --debug CMAKE_BUILD_TYPE=Debug
# ./build.sh -b DIR build in DIR instead of build/ (or build-asan/, build-tsan/)
#
# The other tiers (docs/GUIDE.md §1.3): ctest --test-dir build -LE 'gpu|oot' for everything that
# runs without a card, plain ctest --test-dir build for everything.
set -e
BUILD=
CLEAN=0
SAN=
CMAKE_ARGS=""
while [ $# -gt 0 ]; do
case "$1" in
-c|--clean) CLEAN=1 ;;
--no-hip) CMAKE_ARGS="$CMAKE_ARGS -DRAD_WITH_HIP=OFF" ;;
--asan) SAN=asan ;;
--tsan) SAN=tsan ;;
--sycl) SAN=sycl ;;
--debug) CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug" ;;
-b) shift; BUILD="$1" ;;
*) echo "build.sh: unknown option $1" >&2; exit 2 ;;
esac
shift
done
# A sanitised build gets a directory of its own, so it never reconfigures the normal tree. Host
# code only: device kernels are not sanitised, and a sanitised engine is not one to serve from.
case "$SAN" in
asan) CMAKE_ARGS="$CMAKE_ARGS -DRAD_ASAN=ON -DRAD_TSAN=OFF -DRAD_WITH_HIP=OFF"
BUILD=${BUILD:-build-asan} ;;
tsan) CMAKE_ARGS="$CMAKE_ARGS -DRAD_TSAN=ON -DRAD_ASAN=OFF -DRAD_WITH_HIP=OFF"
BUILD=${BUILD:-build-tsan} ;;
# Not a sanitiser, but likewise a configuration with a directory of its own.
sycl) CMAKE_ARGS="$CMAKE_ARGS -DRAD_SYCL=ON -DRAD_WITH_HIP=OFF"
BUILD=${BUILD:-build-sycl} ;;
*) BUILD=${BUILD:-build} ;;
esac
[ "$CLEAN" = 1 ] && rm -rf "$BUILD"
cmake -S . -B "$BUILD" -G Ninja $CMAKE_ARGS
cmake --build "$BUILD" -j"$(nproc)"
ctest --test-dir "$BUILD" -L '^fast$' -j8 --no-tests=error --output-on-failure