summaryrefslogtreecommitdiff
path: root/lib/Target/NVPTX/NVPTXSubtarget.cpp
diff options
context:
space:
mode:
authorArtem Belevich <tra@google.com>2017-01-13 20:56:17 +0000
committerArtem Belevich <tra@google.com>2017-01-13 20:56:17 +0000
commitf53524b4f64eea25aec919f4a0147b1cd844940d (patch)
tree4e606f2545be0253f59609dc59729f9183498771 /lib/Target/NVPTX/NVPTXSubtarget.cpp
parent999a6572f34646b59935ac28817c8612bf1777ce (diff)
[NVPTX] Added support for half-precision floating point.
Only scalar half-precision operations are supported at the moment. - Adds general support for 'half' type in NVPTX. - fp16 math operations are supported on sm_53+ GPUs only (can be disabled with --nvptx-no-f16-math). - Type conversions to/from fp16 are supported on all GPU variants. - On GPU variants that do not have full fp16 support (or if it's disabled), fp16 operations are promoted to fp32 and results are converted back to fp16 for storage. Differential Revision: https://reviews.llvm.org/D28540 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291956 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/NVPTX/NVPTXSubtarget.cpp')
-rw-r--r--lib/Target/NVPTX/NVPTXSubtarget.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Target/NVPTX/NVPTXSubtarget.cpp b/lib/Target/NVPTX/NVPTXSubtarget.cpp
index 6e1f427ed02..acbee86ae38 100644
--- a/lib/Target/NVPTX/NVPTXSubtarget.cpp
+++ b/lib/Target/NVPTX/NVPTXSubtarget.cpp
@@ -23,6 +23,11 @@ using namespace llvm;
#define GET_SUBTARGETINFO_CTOR
#include "NVPTXGenSubtargetInfo.inc"
+static cl::opt<bool>
+ NoF16Math("nvptx-no-f16-math", cl::ZeroOrMore, cl::Hidden,
+ cl::desc("NVPTX Specific: Disable generation of f16 math ops."),
+ cl::init(false));
+
// Pin the vtable to this file.
void NVPTXSubtarget::anchor() {}
@@ -57,3 +62,7 @@ bool NVPTXSubtarget::hasImageHandles() const {
// Disabled, otherwise
return false;
}
+
+bool NVPTXSubtarget::allowFP16Math() const {
+ return hasFP16Math() && NoF16Math == false;
+}