Skip to content

Commit

Permalink
Fix Float16 capability
Browse files Browse the repository at this point in the history
For 16-bit floating point constants we have to emit the Float16
capability. The implementation is based on checking if cl_khr_fp16
extension from a source langue (OpenCL C) was enabled.
This commit fixes a bug: we should check for *source* extension instead
of SPIR-V extension.

Signed-off-by: Alexey Sotkin <alexey.sotkin@intel.com>
  • Loading branch information
AlexeySotkin committed Feb 5, 2020
1 parent bab8e49 commit 6a03da6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/SPIRV/libSPIRV/SPIRVType.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ class SPIRVTypeFloat : public SPIRVType {
SPIRVCapVec CV;
if (isTypeFloat(16)) {
CV.push_back(CapabilityFloat16Buffer);
auto Extensions = getModule()->getExtension();
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);
Expand Down
3 changes: 2 additions & 1 deletion test/half_extension.ll
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
; RUN: llvm-spirv %t.bc -o %t.spv
; RUN: spirv-val %t.spv

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

; ModuleID = 'main'
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
Expand Down

0 comments on commit 6a03da6

Please sign in to comment.