<div dir="ltr">Dear Developers,<div><br></div><div><span style="color:rgb(0,0,0);font-size:12.8px">I compiled a OpenCL kernel before (on Nov. last year) like</span><br></div><div><span style="color:rgb(0,0,0);font-size:12.8px"><br></span></div><div><span style="color:rgb(0,0,0);font-size:12.8px">__kernel void g(__global float* array)</span></div><div><span style="color:rgb(0,0,0);font-size:12.8px">{</span></div><div><span style="color:rgb(0,0,0);font-size:12.8px">  array[get_global_id(0)] = 1;</span></div><div><span style="color:rgb(0,0,0);font-size:12.8px">}</span></div><div><span style="color:rgb(0,0,0);font-size:12.8px"><br></span></div><div><span style="color:rgb(0,0,0);font-size:12.8px">with libclc, </span><span style="color:rgb(0,0,0);font-size:12.8px">which would originally use the instrinsics like </span><font color="#000000"><span style="font-size:12.8px">llvm.r600.read.local.size.x().</span></font></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.8px">I executed the generated object file with one version of the hsa-runtime [1] provided by Mr. Stellard, when there was more than one workgroup, the output of the program wasn't correct at that time. I guessed this might be because get_group_id() always returned 1 (not quite sure what was going on at that time).</span></font></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.8px">When I compile such cases using current llvm trunk, it uses a set of instrinsics starting with llvm.amdgcn, while it still uses llvm.r600.read.local.size.x(). The output LLVM IR code is like:</span></font></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.8px">define void @g(float addrspace(1)* nocapture %array) #0 {</span><br></font></div><div><font color="#000000"><span style="font-size:12.8px">  %x.i.i = tail call i32 @llvm.amdgcn.workgroup.id.x() #2</span></font></div><div><font color="#000000"><span style="font-size:12.8px">  %x.i12.i = tail call i32 @llvm.r600.read.local.size.x() #1</span></font></div><div><font color="#000000"><span style="font-size:12.8px">  %mul26.i = mul i32 %x.i12.i, %x.i.i </span></font></div><div><font color="#000000"><span style="font-size:12.8px">  %x.i4.i = tail call i32 @llvm.amdgcn.workitem.id.x() #2, !range !7</span></font><br></div><div><font color="#000000"><span style="font-size:12.8px">  %add.i = add i32 %x.i4.i, %mul26.i</span></font></div><div><font color="#000000"><span style="font-size:12.8px">  %0 = sext i32 %add.i to i64</span></font></div><div><font color="#000000"><span style="font-size:12.8px">  %arrayidx = getelementptr inbounds float, float addrspace(1)* %array, i64 %0</span></font></div><div><font color="#000000"><span style="font-size:12.8px">  store float 1.000000e+00, float addrspace(1)* %arrayidx, align 4, !tbaa !8</span></font></div><div><font color="#000000"><span style="font-size:12.8px">  ret void</span></font></div><div><font color="#000000"><span style="font-size:12.8px">}</span></font></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.8px">which cannot be handled by llc with the message "the non-hsa instrinsic with hsa target shown". </span></font></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.8px">After looking into the log (r259297)</span></font><span style="font-size:12.8px;color:rgb(0,0,0)">, m</span><font color="#000000"><span style="font-size:12.8px">y question is that is there other intrinsic that support this case when the target is amdgcn--amdhsa?  In the log of </span></font><span style="color:rgb(0,0,0);font-size:12.8px">r259297, it states that </span><font color="#000000"><span style="font-size:12.8px">AMDGPUPromoteAlloca pass (a backend pass) will generate this intrinsic, but even when I just emit-llvm without going through llc, this intrinsic is still emitted.</span></font></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><span style="font-size:12.8px;color:rgb(0,0,0)">[1] <a href="https://github.com/tstellarAMD/hsa-runtime">https://github.com/tstellarAMD/hsa-runtime</a></span><br></div><div><font color="#000000"><span style="font-size:12.8px"><br></span></font></div><div><div style="color:rgb(0,0,0);font-size:12.8px"><br></div><div style="color:rgb(0,0,0);font-size:12.8px">Regards,</div><div style="color:rgb(0,0,0);font-size:12.8px"><br></div><div style="color:rgb(0,0,0);font-size:12.8px"><div style="font-size:12.8px">李弘宇 (Li, Hong-Yu)</div><div style="font-size:12.8px">Department of Computer Science & Information Engineering</div><div style="font-size:12.8px">National Taiwan University</div></div></div></div>