Skip to content

Using the half type does not generate the Float16 capability #3024

Open
@bashbaug

Description

@bashbaug

Found while reviewing KhronosGroup/SPIRV-Tools#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:

; CHECK-SPIRV-DAG: {{[0-9]+}} Capability Float16

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?

SPIRVCapVec getRequiredCapability() const override {
SPIRVCapVec CV;
if (isTypeFloat(16)) {
CV.push_back(CapabilityFloat16Buffer);
auto Extensions = getModule()->getSourceExtension();
if (std::any_of(Extensions.begin(), Extensions.end(),
[](const std::string &I) { return I == "cl_khr_fp16"; }))
CV.push_back(CapabilityFloat16);
} else if (isTypeFloat(64))
CV.push_back(CapabilityFloat64);
return CV;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions