-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[[cl::unroll_hint]] and [[cl::ivdep]] hints are not passed to SPIR-V #62
Comments
Have you tried to output LLVM instead of SPIR-V to check if this is Clang compiler issue or LLVM to SPIR-V converter (https://github.com/KhronosGroup/SPIRV-LLVM/tree/khronos/spirv-3.6.1)? |
No I haven't, thanks for the idea. I'll check it today. |
I took an action item in today's Khronos call to propose spec text to clarify this behavior. Here's what I have so far:
I think this is OK but I'm not particularly happy about it. Among other things:
So, I'm open to suggestions for improvement (@bsochack?), or perhaps validation that the text above is good enough, in which case I'll open a merge request with this addition. Thanks! |
It seems clang generates loop metadata for cl::unroll_hint and cl::ivdep in LLVM IR. e.g. #include <opencl_memory> using namespace cl; kernel void worker(global* a, global* b) The IR is like br i1 %5, label %6, label %18, !llvm.loop !6 !6 = distinct !{!6, !7, !8} However, LLVM/SPIRV converter currently is unable to recover the loop structure and associated loop info from LLVM IR. |
If I recall correctly, it is not specified in any document if OpenCL C++-to-SPIR-V compiler should always pass
[[cl::unroll_hint]]
and[[cl::ivdep]]
(ignore vector dependencies) hints to SPIR-V, or if OpenCL C++-to-SPIR-V compiler can decide not unroll the loop and ignore unroll hint.However, in my opinion, since SPIR-V is an intermediate language between human-readable OpenCL (and other languages) and hardware-specific byte code, OpenCL C++-to-SPIR-V compiler should compile loops with
[[cl::unroll_hint]]
and[[cl::ivdep]]
attributes. That is, it should compile those loops to structured loops (see StructuredControlFlow) withOpLoopMerge
instruction with information about the hints, so that later SPIR-V-to-hardware-specific-byte-code compiler can make a decision whether to unroll or vectorize the loop.Currently,
[[cl::unroll_hint]]
and[[cl::ivdep]]
hints are ignored and are not passed SPIR-V.The text was updated successfully, but these errors were encountered: