KhronosGroup / KhronosGroup/SPIR
[[cl::unroll_hint]] and [[cl::ivdep]] hints are not passed to SPIR-V
- Dominant language
- C++
- Stars
- 183
- Forks
- 51
- PR merge metrics
- No merged PRs in 30d
Description
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](https://www.khronos.org/registry/spir-v/specs/1.1/SPIRV.html#StructuredControlFlow)) with `OpLoopMerge` 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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing how the OpenCL C++-to-SPIR-V compiler handles [[cl::unroll_hint]] and [[cl::ivdep]], then consult the SPIR-V StructuredControlFlow and OpLoopMerge specifications linked in the issue. Done means the generated SPIR-V preserves these loop hints for later compilation decisions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100