KhronosGroup / KhronosGroup/SPIRV-LLVM-Translator

Using the half type does not generate the Float16 capability

Open
#3,024 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
LLVM
Stars
625
Forks
279
Avg merge
3d 5h
Merged PRs (30d)
34

Description

Found while reviewing https://github.com/KhronosGroup/SPIRV-Tools/pull/6009.

Surprisingly, using the `half` type does not generate SPIR-V modules that declare the **Float16** capability. We have some tests that are checking that the right capability is declared, for example:

https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/4eea290c449fca2efd28cfa46d3946c5feaf988c/test/half_extension.ll#L17

However, this is unfortunately matching `Capability Float16Buffer`, so it is not actually checking for `Capability Float16`. If I change this check instead to:

```
; CHECK-SPIRV: Capability {{Float16 *$}}
```

Then the test starts to fail.

Recommended actions:

1. Change all tests to check for `Float16` at the end of the line, similar to the check above.
* Are there any other capabilities that are the prefix of another capability that may be affected similarly?
2. Figure out why **Float16Buffer** is being declared and not **Float16**. Possibly something is going wrong here?

https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/4eea290c449fca2efd28cfa46d3946c5feaf988c/lib/SPIRV/libSPIRV/SPIRVType.h#L214-L224

Contributor guide

Open the contributing guide

Research direction

Start with test/half_extension.ll and update the capability checks so Float16 is matched at the end of the line; review related capability checks for the same prefix issue. Then inspect lib/SPIRV/libSPIRV/SPIRVType.h#L214-L224 to trace why using half declares Float16Buffer instead of Float16, and run the affected tests to confirm the capability output.

Written by the indexing model from the issue text.

Assessment

Domain
compilers, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.