Archived
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
57 lines
2.2 KiB
C
57 lines
2.2 KiB
C
#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 */
|