llvm
877282b6 - [SYCL][ESIMD] Add typed surface gather, scatter and prefetch APIs (#23359)

Commit
10 days ago
[SYCL][ESIMD] Add typed surface gather, scatter and prefetch APIs (#23359) Add experimental ESIMD APIs that read, write and prefetch up to four 32-bit channels per pixel of an image, addressed by integer pixel coordinates. Unlike gather_rgba/scatter_rgba, which address a buffer by byte offsets, these use typed surface messages, so the hardware converts between the image format and the 32-bit register type and handles out-of-bounds coordinates. Two variants are provided in the experimental::esimd namespace, because the dataport typed messages were replaced by LSC messages on Xe2: * Pre-Xe2: gather_rgba_typed and scatter_rgba_typed, lowered to llvm.genx.gather4.typed and llvm.genx.scatter4.typed. * Xe2 and later: lsc_gather_rgba_typed, lsc_scatter_rgba_typed and lsc_prefetch_rgba_typed, lowered to llvm.genx.lsc.{load.merge,store,prefetch}.quad.typed.bti. These also accept L1/L2 cache hints and a per-pixel LOD coordinate, and lsc_gather_rgba_typed has an overload that returns a pass-through value for the pixels with a zero mask, like lsc_gather. All APIs take an image accessor and U/V/R coordinate vectors, select the channels with an rgba_channel_mask, and use the same channel-major data layout as gather_rgba/scatter_rgba. N must be 8, 16 or 32 and the channel type must be 4 bytes; writes support only the R, GR, BGR and ABGR masks. Non-image accessors and cache hints that are invalid for the operation are rejected at compile time. The ESIMD extension documentation is updated accordingly. Tests: * sycl/test/esimd: compile-time restriction tests for both variants and a lowering test that checks the emitted GenX intrinsics and their operands. * sycl/test-e2e/ESIMD: read-modify-write round-trip tests and Mandelbrot examples for both variants. The pre-Xe2 tests require the Gen11, Gen12 or DG2 GPU families and the Xe2+ tests require Xe2 or later architectures. The LSC round-trip test also checks the pass-through values. The Mandelbrot examples use fixed-point integer arithmetic and require an exact match with a CPU reference. They can also write the image to a PPM file for visual inspection. Assisted-by: GitHub Copilot (Claude Opus 5.5)
Author
Parents
Loading