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/scripts/sycl/devprobe.cpp
T
claudeandClaude Opus 5.5 c10caa44fb sycl: Phase 0 of the Intel backend -- the B65's limits and XMX types, the host baseline
scripts/sycl/probe.sh builds and runs two probes on the Arc Pro B65 (Level Zero, xe driver): the
device's limits and joint_matrix combinations, and an ESIMD DPAS check of E4M3 / E5M2 against bf16
and s8 controls in the same harness. bf16, fp16, s8 and tf32 XMX are exact; fp8 DPAS compiles for
bmg-g31 but returns garbage, so fp8 weights are widened to bf16 in-register (exact for E4M3).

docs/SYCL_PROGRESS.md is the resume log: device tables, the host baseline (82/88 of -LE 'gpu|oot';
the six failures are FFmpeg-less builds and CPU-time budgets on this VM), BetterBench setup, the
model library survey and the open blockers (no MiniCPM5 container in the library, no ROCm here).

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

112 lines
6.3 KiB
C++

// Phase 0 device probe: limits, aspects, sub-groups, joint_matrix combinations, and a
// numerical check of which XMX element types actually execute on the device.
#include <sycl/sycl.hpp>
#include <cmath>
#include <cstdio>
#include <vector>
namespace syclex = sycl::ext::oneapi::experimental;
namespace jm = sycl::ext::oneapi::experimental::matrix;
static const char *mt(jm::matrix_type t) {
switch (t) {
case jm::matrix_type::bf16: return "bf16";
case jm::matrix_type::fp16: return "fp16";
case jm::matrix_type::tf32: return "tf32";
case jm::matrix_type::fp32: return "fp32";
case jm::matrix_type::fp64: return "fp64";
case jm::matrix_type::sint8: return "s8";
case jm::matrix_type::uint8: return "u8";
case jm::matrix_type::sint32: return "s32";
case jm::matrix_type::uint32: return "u32";
default: return "other";
}
}
// One sub-group computes C[M x N] = A[M x K] * B[K x N] with joint_matrix, compared with a host loop.
template <typename Ta, typename Tc, size_t M, size_t N, size_t K>
static double jm_test(sycl::queue &q, const char *name) {
std::vector<Ta> a(M * K), b(K * N);
std::vector<Tc> c(M * N, 0);
std::vector<double> ref(M * N, 0);
for (size_t i = 0; i < M * K; i++) a[i] = Ta(float(int(i * 7 % 11) - 5) * 0.25f);
for (size_t i = 0; i < K * N; i++) b[i] = Ta(float(int(i * 5 % 13) - 6) * 0.5f);
for (size_t m = 0; m < M; m++)
for (size_t n = 0; n < N; n++)
for (size_t k = 0; k < K; k++) ref[m * N + n] += double(float(a[m * K + k])) * double(float(b[k * N + n]));
Ta *da = sycl::malloc_device<Ta>(M * K, q), *db = sycl::malloc_device<Ta>(K * N, q);
Tc *dc = sycl::malloc_device<Tc>(M * N, q);
q.memcpy(da, a.data(), sizeof(Ta) * M * K);
q.memcpy(db, b.data(), sizeof(Ta) * K * N);
q.memset(dc, 0, sizeof(Tc) * M * N).wait();
try {
q.parallel_for(sycl::nd_range<1>{16, 16}, [=](sycl::nd_item<1> it) [[sycl::reqd_sub_group_size(16)]] {
auto sg = it.get_sub_group();
jm::joint_matrix<sycl::sub_group, Ta, jm::use::a, M, K, jm::layout::row_major> ma;
jm::joint_matrix<sycl::sub_group, Ta, jm::use::b, K, N, jm::layout::row_major> mb;
jm::joint_matrix<sycl::sub_group, Tc, jm::use::accumulator, M, N> mc;
jm::joint_matrix_fill(sg, mc, Tc(0));
auto pa = sycl::address_space_cast<sycl::access::address_space::global_space, sycl::access::decorated::no>(da);
auto pb = sycl::address_space_cast<sycl::access::address_space::global_space, sycl::access::decorated::no>(db);
auto pc = sycl::address_space_cast<sycl::access::address_space::global_space, sycl::access::decorated::no>(dc);
jm::joint_matrix_load(sg, ma, pa, K);
jm::joint_matrix_load(sg, mb, pb, N);
jm::joint_matrix_mad(sg, mc, ma, mb, mc);
jm::joint_matrix_store(sg, mc, pc, N, jm::layout::row_major);
}).wait_and_throw();
} catch (sycl::exception &e) {
printf(" jm %-28s FAILED: %s\n", name, e.what());
return -1;
}
q.memcpy(c.data(), dc, sizeof(Tc) * M * N).wait();
double maxerr = 0;
for (size_t i = 0; i < M * N; i++) maxerr = std::fmax(maxerr, std::fabs(double(c[i]) - ref[i]));
printf(" jm %-28s M%zu N%zu K%zu max|err|=%g\n", name, M, N, K, maxerr);
sycl::free(da, q); sycl::free(db, q); sycl::free(dc, q);
return maxerr;
}
int main() {
sycl::queue q{sycl::gpu_selector_v, sycl::property::queue::in_order{}};
auto d = q.get_device();
printf("device: %s\n", d.get_info<sycl::info::device::name>().c_str());
printf("backend: %s driver: %s\n",
d.get_backend() == sycl::backend::ext_oneapi_level_zero ? "level_zero" : "other",
d.get_info<sycl::info::device::driver_version>().c_str());
printf("max_compute_units: %u\n", d.get_info<sycl::info::device::max_compute_units>());
printf("max_work_group_size: %zu\n", d.get_info<sycl::info::device::max_work_group_size>());
printf("sub_group_sizes:");
for (auto s : d.get_info<sycl::info::device::sub_group_sizes>()) printf(" %zu", s);
printf("\nlocal_mem_size: %llu\n", (unsigned long long)d.get_info<sycl::info::device::local_mem_size>());
printf("global_mem_size: %llu (%.2f GiB)\n", (unsigned long long)d.get_info<sycl::info::device::global_mem_size>(),
d.get_info<sycl::info::device::global_mem_size>() / 1073741824.0);
printf("max_mem_alloc_size: %llu (%.2f GiB)\n", (unsigned long long)d.get_info<sycl::info::device::max_mem_alloc_size>(),
d.get_info<sycl::info::device::max_mem_alloc_size>() / 1073741824.0);
printf("max_clock_frequency: %u MHz\n", d.get_info<sycl::info::device::max_clock_frequency>());
printf("global_mem_cache_size: %llu\n", (unsigned long long)d.get_info<sycl::info::device::global_mem_cache_size>());
printf("aspects: fp16=%d fp64=%d usm_device=%d usm_host=%d usm_shared=%d usm_system=%d atomic64=%d intel_matrix=%d\n",
d.has(sycl::aspect::fp16), d.has(sycl::aspect::fp64), d.has(sycl::aspect::usm_device_allocations),
d.has(sycl::aspect::usm_host_allocations), d.has(sycl::aspect::usm_shared_allocations),
d.has(sycl::aspect::usm_system_allocations), d.has(sycl::aspect::atomic64),
d.has(sycl::aspect::ext_intel_matrix));
try {
auto arch = d.get_info<syclex::info::device::architecture>();
printf("architecture enum: %d (bmg_g31=%d)\n", int(arch), int(syclex::architecture::intel_gpu_bmg_g31));
} catch (...) { printf("architecture: query failed\n"); }
printf("matrix_combinations:\n");
try {
auto combos = d.get_info<syclex::info::device::matrix_combinations>();
for (auto &c : combos)
printf(" A=%s B=%s C=%s D=%s M=%zu N=%zu K=%zu (max M %zu N %zu K %zu)\n", mt(c.atype), mt(c.btype),
mt(c.ctype), mt(c.dtype), c.msize, c.nsize, c.ksize, c.max_msize, c.max_nsize, c.max_ksize);
if (combos.empty()) printf(" (none)\n");
} catch (sycl::exception &e) { printf(" query failed: %s\n", e.what()); }
printf("joint_matrix execution checks:\n");
jm_test<sycl::ext::oneapi::bfloat16, float, 8, 16, 16>(q, "bf16 x bf16 -> f32");
jm_test<sycl::half, float, 8, 16, 16>(q, "fp16 x fp16 -> f32");
jm_test<int8_t, int32_t, 8, 16, 32>(q, "s8 x s8 -> s32");
return 0;
}