Skip to content

Commit 53e9698

Browse files
authored
[NVPTX] Enable the _Float16 type for NVPTX compilation (llvm#82436)
Summary: The PTX target supports the f16 type natively and we alreaqdy have a few LLVM backend tests that support the LLVM-IR. We should be able to enable this for generic use. This is done prior the f16 math functions being written in the GPU libc case.
1 parent d3fcf31 commit 53e9698

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ to ``float``; see below for more information on this emulation.
833833
* 32-bit ARM (natively on some architecture versions)
834834
* 64-bit ARM (AArch64) (natively on ARMv8.2a and above)
835835
* AMDGPU (natively)
836+
* NVPTX (natively)
836837
* SPIR (natively)
837838
* X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
838839
* RISC-V (natively if Zfh or Zhinx is available)

clang/lib/Basic/Targets/NVPTX.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ NVPTXTargetInfo::NVPTXTargetInfo(const llvm::Triple &Triple,
6161
NoAsmVariants = true;
6262
GPU = CudaArch::UNUSED;
6363

64+
// PTX supports f16 as a fundamental type.
65+
HasLegalHalfType = true;
66+
HasFloat16 = true;
67+
6468
if (TargetPointerWidth == 32)
6569
resetDataLayout("e-p:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64");
6670
else if (Opts.NVPTXUseShortPointers)

clang/test/SemaCUDA/float16.cu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -fsyntax-only -triple x86_64 -aux-triple amdgcn -verify %s
2+
// RUN: %clang_cc1 -fsyntax-only -triple x86_64 -aux-triple nvptx64 -verify %s
23
// expected-no-diagnostics
34
#include "Inputs/cuda.h"
45

0 commit comments

Comments
 (0)