Krzysztof Drewniak df739ba008
[mlir][gpu] Add address space modifier to gpu.barrier (#177425)
This is a takeover of PR ##110527

This commit adds an optional list of memory fences to gpu.barrier,
allowing users to specify which memory scopes they wish to fence
explicitly, while leaving the default semantics (which are equivalent to
calling for a global and local fence by analogy to CUDA's __syncthreads)
unchanged. The new expanded semantics are implemented for SPIR-V and for
the AMDGPU backend.

See also

https://discourse.llvm.org/t/rfc-add-memory-scope-to-gpu-barrier/81021/2?u=fmarno,
where the default behavior of a gpu.barrier was hashed out (though note
that the examples based on VMCNT are outdated for AMDGPU in that memory
fences can now be annotated with the correct set of address spaces).

This commit also deprecates amdgpu.lds_barrier for usecases that don't
involve targeting a gfx908.

Assisted-by: Cursor/Claude code (tests and extending amdgpu.lds_barrier
pattern while copying it over)

---------

Co-authored-by: Finlay Marno <finlay.marno@codeplay.com>
Co-authored-by: Jakub Kuderski <kubakuderski@gmail.com>
Co-authored-by: Alan Li <alan.li@me.com>
2026-01-26 12:08:47 -08:00
..