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/libxe2/CMakeLists.txt
T
pascallinxweilerandClaude Opus 5.5 b0e34c6324 libxe2: m2xfp4 verify GEMM on register DPAS -- no local-memory round trip
SPV_INTEL_subgroup_matrix_multiply_accumulate gives DPAS on operands in registers (dpas_f16 in
xe2_common.h; libxe2's link enables the extension). Its B operand is a lane's column as dwords of
fp16 pairs, which is what a lane decodes from its codes, so the 2 <= M <= 16 m2xfp4 GEMM no longer
writes the decoded weights to local memory and reads them back as a joint_matrix tile; the
activation is transposed once so a lane's A column is one 16-byte load. 15-20% a call at M = 8
(N=34816 K=5120 518 -> 463 us, N=5120 K=17408 312 -> 249 us). Same products: rel_l2 at most
1.46e-3 as before (185/185 model cases). XE2_M2_JM=1 keeps the local-memory form.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018EpFgqQidSnH8zo7boVZC1
2026-10-24 13:56:02 +02:00

42 lines
2.4 KiB
CMake

# libxe2 -- radiance's kernel library for Intel Xe2 GPUs (Battlemage; the Arc Pro B65), in SYCL.
# docs/SYCL_PORTING.md has the design, docs/SYCL_PROGRESS.md the state.
#
# Links radiance::abi and the SYCL runtime, nothing of radiance's. Built by icpx: in radiance's tree
# through the sycl/ sub-build, or standalone against an installed radiance:
# cmake -S libxe2 -B build -DCMAKE_CXX_COMPILER=icpx -DCMAKE_PREFIX_PATH=<radiance prefix>
if(NOT COMMAND rad_add_plugin)
cmake_minimum_required(VERSION 3.21)
project(libxe2 LANGUAGES CXX)
find_package(radiance REQUIRED)
rad_plugin_defaults()
endif()
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
message(FATAL_ERROR "libxe2 is SYCL and needs icpx (-DCMAKE_CXX_COMPILER=icpx); this configure "
"has ${CMAKE_CXX_COMPILER_ID}.")
endif()
if(NOT RAD_SYCL_TARGETS)
set(RAD_SYCL_TARGETS "intel_gpu_bmg_g31")
endif()
file(GLOB XE2_SRC CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
rad_add_plugin(libxe2 kernels SOURCES ${XE2_SRC})
# -ffp-contract=off is a correctness flag here as in libref: kernels are checked against it, so
# `a*b + c` rounds twice on both sides. It follows -ffp-model=precise, which would otherwise set
# contraction back on. -foffload-fp32-prec-div and -sqrt make device division and sqrt correctly
# rounded, as libref's are: a quantiser's scale is amax * (1/top), and a 1/top one ulp off moves
# codes that sit exactly on an E4M3 rounding tie, which bf16 inputs hit often.
# Device code is generated at link time (AOT), so every flag that shapes it goes to the link too;
# on the compile line alone it changes nothing on the card.
# SPV_INTEL_subgroup_matrix_multiply_accumulate: DPAS on operands in registers (xe2_common.h's
# dpas_f16), for kernels that decode a weight straight into the B operand.
set(_xe2_sycl -fsycl "-fsycl-targets=${RAD_SYCL_TARGETS}" -ffp-model=precise -ffp-contract=off
-Wno-overriding-option -foffload-fp32-prec-div -foffload-fp32-prec-sqrt
"SHELL:-Xspirv-translator -spirv-ext=+SPV_INTEL_subgroup_matrix_multiply_accumulate")
target_compile_options(libxe2 PRIVATE ${_xe2_sycl} -fvisibility=hidden)
get_filename_component(_xe2_icpx_bin "${CMAKE_CXX_COMPILER}" DIRECTORY)
get_filename_component(_xe2_oneapi_lib "${_xe2_icpx_bin}/../lib" ABSOLUTE)
target_link_options(libxe2 PRIVATE ${_xe2_sycl} "LINKER:-rpath,${_xe2_oneapi_lib}"
"LINKER:--no-undefined")