Archived
abi: rad_sycl.h -- what a RadStream is under the SYCL backend
A SYCL kernel library has no hipLaunchKernel for the engine to serve, so under the SYCL backend a RadStream points to a RadSyclStream: a magic, its own version, and the engine's in-order sycl::queue. rad_sycl_queue() hands a plugin the queue or null for any other stream. The struct is versioned by RAD_SYCL_STREAM_VERSION rather than RAD_ABI_VERSION, since no shape an existing plugin compiles against changes; rad_abi.h and rad_types.h say so. The layout tests cover it: strict C11 in abi_c_test.c, and its rows in abi_layout_rows.h, where a struct the frozen table predates is allowed without a version bump. docs/SYCL_PROGRESS.md: D6 revised. Building everything with icpx fails in libavx (_pdep_u64 without -mbmi2, which GCC accepts and clang refuses), so the main build stays GCC and only SYCL code is built by icpx, as shared libraries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
This commit is contained in:
1 parent
ec4dbb6464
commit
a3dc47b79a
7 files changed
+78
-6
No files matched your search
+2
-1
@@ -16,7 +16,8 @@ extern "C" {
|
||||
* rad_builder.h, rad_runtime.h, rad_device.h, rad_encoding.h, rad_quant.h or rad_sample.h. Every
|
||||
* kind of plugin reports it, and a plugin that does not report exactly this version is refused at
|
||||
* load with both versions printed. A new optional export (e.g. rad_plugin_reference) is not a
|
||||
* change of shape: a plugin without it gets the default. */
|
||||
* change of shape: a plugin without it gets the default. rad_sycl.h is versioned on its own
|
||||
* (RAD_SYCL_STREAM_VERSION), since only SYCL kernel libraries read it. */
|
||||
#define RAD_ABI_VERSION 26u
|
||||
|
||||
/* ================================================================== plugin identity */
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef RAD_SYCL_H
|
||||
#define RAD_SYCL_H
|
||||
|
||||
/* rad_sycl.h -- what a RadStream is under the SYCL device backend (docs/SYCL_PORTING.md §4.2).
|
||||
*
|
||||
* On an AMD card a kernel plugin launches through hipLaunchKernel, which the engine serves on its
|
||||
* own queues (docs/PLUGIN.md §5). SYCL has no launch entry point the engine could serve, so a SYCL
|
||||
* kernel library is handed the queue itself: under the SYCL backend a RadStream points to a
|
||||
* RadSyclStream, whose `queue` is an in-order sycl::queue the engine owns. Under every other
|
||||
* backend a RadStream is not one, and `magic` says so.
|
||||
*
|
||||
* The struct carries its own version instead of moving RAD_ABI_VERSION, because no shape an
|
||||
* existing plugin compiles against changes; only SYCL plugins read it, and rad_sycl_queue() refuses
|
||||
* a struct of another version. Bump RAD_SYCL_STREAM_VERSION on any change below.
|
||||
*
|
||||
* What a launch may do with the queue mirrors docs/PLUGIN.md §5: submit kernels, copies and fills
|
||||
* to it. It must not wait on it (a launch never synchronises), allocate (scratch comes from the
|
||||
* `scratch` hook), submit host tasks, or keep the queue past the launch. */
|
||||
#include <stdint.h>
|
||||
|
||||
#include "rad_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RAD_SYCL_STREAM_MAGIC 0x4C435953u /* "SYCL", little-endian */
|
||||
#define RAD_SYCL_STREAM_VERSION 1u
|
||||
|
||||
typedef struct RadSyclStream {
|
||||
uint32_t magic; /* RAD_SYCL_STREAM_MAGIC */
|
||||
uint32_t version; /* RAD_SYCL_STREAM_VERSION */
|
||||
void* queue; /* sycl::queue*, in order, owned by the engine */
|
||||
int32_t device; /* the device index the queue submits to (rad_dev_set's numbering) */
|
||||
int32_t reserved;
|
||||
} RadSyclStream;
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus) && defined(SYCL_LANGUAGE_VERSION)
|
||||
#include <sycl/sycl.hpp>
|
||||
|
||||
/* The queue behind `s`, or null when `s` is not a SYCL stream of this version (another backend's
|
||||
* stream, or a plugin built against a different rad_sycl.h); the launch then returns
|
||||
* RAD_E_DEVICE. */
|
||||
inline sycl::queue* rad_sycl_queue(RadStream s) {
|
||||
const RadSyclStream* r = (const RadSyclStream*)s;
|
||||
if (!r || r->magic != RAD_SYCL_STREAM_MAGIC || r->version != RAD_SYCL_STREAM_VERSION)
|
||||
return nullptr;
|
||||
return (sycl::queue*)r->queue;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RAD_SYCL_H */
|
||||
+3
-2
@@ -326,8 +326,9 @@ typedef uint32_t rad_kvgroup;
|
||||
/* Opaque: the core never dereferences one. On a card it is the engine's own queue, not a
|
||||
* hipStream_t. A kernel plugin may use it only with hipLaunchKernel (and so <<<>>>),
|
||||
* hipMemcpyAsync, hipMemcpy2DAsync and hipMemsetAsync, which the engine implements itself, and
|
||||
* must pass it to nothing else in HIP (docs/PLUGIN.md, "What a launch may do"). Under the host
|
||||
* backend the host kernels ignore it. */
|
||||
* must pass it to nothing else in HIP (docs/PLUGIN.md, "What a launch may do"). Under the SYCL
|
||||
* backend it points to a RadSyclStream holding the engine's sycl::queue (rad_sycl.h). Under the
|
||||
* host backend the host kernels ignore it. */
|
||||
typedef void* RadStream;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -180,9 +180,15 @@ Planned use: Milestone A = `minicpm5-2b-bf16.rad` (blocked, item 1); Milestone B
|
||||
plugin's `build_target` with the device arch so libr4d rows are never selected on the B65. (§4.3)
|
||||
- D5: on the SYCL backend the "host-only ops ... Not a hole" placement is fatal unless
|
||||
`--debug-accept-host-ops`. (§4.4)
|
||||
- D6: `RAD_SYCL=ON` builds everything with `icpx`, host code at `-ffp-model=precise` (icpx's default
|
||||
is fast math); `-fsycl` only on SYCL sources. Fallback: ExternalProject for the SYCL pieces if
|
||||
host results differ from GCC's. HIP + SYCL refused together at configure until a ROCm machine can
|
||||
- D6 (revised 2026-10-23): ~~`RAD_SYCL=ON` builds everything with `icpx`~~. Tried: `cmake -B build-icpx
|
||||
-DCMAKE_CXX_COMPILER=icpx -DCMAKE_CXX_FLAGS=-ffp-model=precise -DRAD_WITH_HIP=OFF` fails in libavx:
|
||||
`avx_gemm_tile.cpp:289: always_inline function '_pdep_u64' requires target feature 'bmi2', but would
|
||||
be inlined into function 'qb_codes_zp' that is compiled without support` (GCC accepts it, clang does
|
||||
not), and fixing that means changing libavx. So the **main build stays GCC in every configuration**
|
||||
and only the SYCL code is built and linked by `icpx`, as shared libraries in a sub-build
|
||||
(`librad_sycl.so`: the device backend and the core's SYCL kernels, a C entry point and a callback
|
||||
table for logging and errors; `libxe2.so`: the kernel plugin). Host code in a SYCL build is then the
|
||||
default build's, byte for byte. HIP + SYCL refused together at configure until a ROCm machine can
|
||||
test it. (§4.5)
|
||||
- D7: `advance` and `wtab` get SYCL launchers; `xprefetch` stays off. (§4.6)
|
||||
- D8: `--tp > 1` refused at startup on the SYCL backend. (§4.7)
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "rad_quant.h"
|
||||
#include "rad_runtime.h"
|
||||
#include "rad_sample.h"
|
||||
#include "rad_sycl.h"
|
||||
#include "rad_types.h"
|
||||
#include "rad_yarn.h"
|
||||
|
||||
|
||||
@@ -642,6 +642,12 @@ ABI_FIELD(RadSampleParams, hist_len)
|
||||
ABI_FIELD(RadSampleParams, mask_row)
|
||||
ABI_FIELD(RadSampleParams, flags)
|
||||
ABI_FIELD(RadSampleParams, dry_rep_limit)
|
||||
ABI_STRUCT(RadSyclStream)
|
||||
ABI_FIELD(RadSyclStream, magic)
|
||||
ABI_FIELD(RadSyclStream, version)
|
||||
ABI_FIELD(RadSyclStream, queue)
|
||||
ABI_FIELD(RadSyclStream, device)
|
||||
ABI_FIELD(RadSyclStream, reserved)
|
||||
ABI_STRUCT(RadTensor)
|
||||
ABI_FIELD(RadTensor, data)
|
||||
ABI_FIELD(RadTensor, dtype)
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "rad_quant.h"
|
||||
#include "rad_runtime.h"
|
||||
#include "rad_sample.h"
|
||||
#include "rad_sycl.h"
|
||||
#include "rad_types.h"
|
||||
#include "rad_yarn.h"
|
||||
|
||||
|
||||
Reference in new issue
Block a user