KhronosGroup / KhronosGroup/SPIRV-LLVM-Translator
Problems with barrier function
- Dominant language
- LLVM
- Stars
- 625
- Forks
- 279
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 34
Description
Level Zero's SPIRV barrier function is not working on my Intel(R) UHD Graphics P630 [0x9bf6]
The kernel I'm looking at implements a reduction (sum) within a workgroup (local). It sums over the elements of an array of floats and stores the intermediate results in local memory. The required synchronization within the workgroup is implemented via
```
call void @_Z7barrierj(i32 3)
declare spir_func void @_Z7barrierj(i32) #0
attributes #0 = { readnone }
```
However, the kernel doesn't work correctly. It's result is off a little bit from the correct value. This is a typical symptom when the barrier function is not working correctly.
The kernel gets translated to SPIRV and then loaded and launched with Intel Level Zero/compute-runtime. And that's when the barrier is not working. I don't know at what stage it gets messed up.
I have tried passing '1' and '2' to the barrier function and not issuing the call at all: Exactly the same outcome. This hints to the fact that the barrier is not called at all.
This is what Clang generates for the following statement:
```
barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE);
tail call spir_func void @_Z7barrierj(i32 3) #4
declare spir_func void @_Z7barrierj(i32) local_unnamed_addr #2
attributes #2 = { convergent "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
attributes #4 = { convergent nounwind }
```
I don't think the additional attributes matter here.
Any ideas?
Contributor guide
Research direction
Begin with the provided LLVM IR and trace the barrier through SPIR-V translation and the Level Zero/compute-runtime launch; compare behavior for barrier arguments 1, 2, and 3 and with the call omitted. Done means locating the stage where synchronization is lost and documenting a reproducible result for the reduction kernel.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100