[PATCH] D85910: libclc: Add a __builtin to let SPIRV targets select between SW and HW FMA

Daniel Stone via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 08:11:29 PDT 2020


daniels updated this revision to Diff 287980.
daniels added a comment.

Added `noinline` to use software by default, letting implementation override


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85910/new/

https://reviews.llvm.org/D85910

Files:
  libclc/generic/lib/math/math.h
  libclc/spirv/lib/math/fma.cl
  libclc/spirv64/lib/math/fma.cl


Index: libclc/spirv64/lib/math/fma.cl
===================================================================
--- libclc/spirv64/lib/math/fma.cl
+++ libclc/spirv64/lib/math/fma.cl
@@ -4,3 +4,8 @@
 #define __CLC_BODY <fma.inc>
 #define __FLOAT_ONLY
 #include <clc/math/gentype.inc>
+
+bool __builtin_has_hw_fma32()
+{
+    return false;
+}
Index: libclc/spirv/lib/math/fma.cl
===================================================================
--- libclc/spirv/lib/math/fma.cl
+++ libclc/spirv/lib/math/fma.cl
@@ -4,3 +4,8 @@
 #define __CLC_BODY <fma.inc>
 #define __FLOAT_ONLY
 #include <clc/math/gentype.inc>
+
+bool __builtin_has_hw_fma32()
+{
+    return false;
+}
Index: libclc/generic/lib/math/math.h
===================================================================
--- libclc/generic/lib/math/math.h
+++ libclc/generic/lib/math/math.h
@@ -40,6 +40,9 @@
 
 #if (defined __AMDGCN__ || defined __R600__) && !defined __HAS_FMAF__
 #define HAVE_HW_FMA32() (0)
+#elif defined CLC_SPIRV || defined CLC_SPIRV64
+bool __attribute__((noinline)) __builtin_has_hw_fma32(void);
+#define HAVE_HW_FMA32() __builtin_has_hw_fma32()
 #else
 #define HAVE_HW_FMA32() (1)
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85910.287980.patch
Type: text/x-patch
Size: 1164 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200826/673ca757/attachment.bin>


More information about the llvm-commits mailing list