1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// RLX — versatile ML compiler + runtime.
// Copyright (C) 2026 Eugene Hauptmann, Nataliya Kosmyna.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 3.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! RLX Intel oneAPI backend — the dedicated `Device::OneApi` path for Intel
//! Arc / Data Center Max GPUs via the **Level Zero** runtime.
//!
//! Layout mirrors the other native GPU backends (rlx-cuda / rlx-vulkan):
//! - `level_zero` — hand-rolled `ze_*` FFI, dynamic-loaded (`libze_loader`);
//! builds + links with no oneAPI runtime present (macOS / CI).
//! - `device` — driver/device/context/compute-queue singleton; gracefully
//! unavailable when no Level Zero GPU is reachable.
//! - `kernels` — embedded OpenCL-C→SPIR-V blobs (`build.rs` via `ocloc`) +
//! their `ze_module`/`ze_kernel` cache.
//! - `arena` — f32-uniform USM-shared buffer for the native dispatch path.
//! - `host` — `rlx-cpu` reference eval (whole-graph on the dev box; per-op
//! fallback on hardware).
//! - `backend` — `OneApiExecutable`: legalize → run (native dispatch when a
//! device + kernels exist, else the CPU-reference interpreter).
//!
//! ## Status
//!
//! The Level Zero bring-up, SPIR-V module/kernel wiring, USM arena, and per-op
//! dispatch are implemented but **not yet validated on Intel hardware** — there
//! is none on the dev box. Until then every op is served by the bit-exact
//! `rlx-cpu` reference, so the backend is *correct* everywhere and *native* on
//! Arc / Data Center Max pending bring-up. See `README.md` for the validation
//! plan and the SPIR-V flavor (OpenCL-Kernel vs Vulkan-Shader) rationale.
/// True if a Level Zero GPU device is reachable on this system. The runtime
/// registry only registers `Device::OneApi` when this returns `true`, so hosts
/// with no oneAPI runtime (macOS, CI) fall through cleanly.
/// Human-readable name of the selected Intel device, if any.
/// Whether native SPIR-V kernels were embedded for this build (Intel oneAPI
/// build host with `ocloc` + `RLX_ONEAPI_BUILD_KERNELS=1`). When `false`, the
/// native path serves every op through the CPU reference.