<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Level Zero's SPIRV barrier function is not working on my Intel(R) UHD Graphics P630 [0x9bf6]
<div><br>
</div>
<div>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</div>
<div><br>
</div>
<div>call void @_Z7barrierj(i32 3)</div>
<div><br>
</div>
<div>declare spir_func void @_Z7barrierj(i32) #0</div>
<div>attributes #0 = { readnone }</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div><br>
</div>
<div>This is what Clang generates for the following statement:</div>
<div><br>
</div>
<div>barrier(CLK_LOCAL_MEM_FENCE | CLK_GLOBAL_MEM_FENCE);</div>
<div><br>
</div>
<div>tail call spir_func void @_Z7barrierj(i32 3) #4</div>
<div><br>
</div>
<div>declare spir_func void @_Z7barrierj(i32) local_unnamed_addr #2</div>
<div>attributes #2 = { convergent "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }</div>
<div>attributes #4 = { convergent nounwind }</div>
<div><br>
</div>
<span>I don't think the additional attributes matter here.</span><br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>Any ideas?</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Frank</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
</body>
</html>