[PATCH] D20481: [CUDA] Define __USE_FAST_MATH__ when __FAST_MATH__ is defined.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Fri May 20 11:52:45 PDT 2016


jlebar created this revision.
jlebar added a reviewer: rsmith.
jlebar added a subscriber: cfe-commits.

The CUDA headers look for __USE_FAST_MATH__.

http://reviews.llvm.org/D20481

Files:
  lib/Headers/__clang_cuda_runtime_wrapper.h

Index: lib/Headers/__clang_cuda_runtime_wrapper.h
===================================================================
--- lib/Headers/__clang_cuda_runtime_wrapper.h
+++ lib/Headers/__clang_cuda_runtime_wrapper.h
@@ -42,6 +42,13 @@
 
 #if defined(__CUDA__) && defined(__clang__)
 
+// The CUDA headers use the __USE_FAST_MATH__ macro to determine whether we get
+// the slow-but-accurate or fast-but-inaccurate versions of functions like sin
+// and exp, but -ffast-math defines only __FAST_MATH__.
+#if defined(__FAST_MATH__) && !defined(__USE_FAST_MATH__)
+#define __USE_FAST_MATH__
+#endif
+
 // Include some forward declares that must come before cmath.
 #include <__clang_cuda_math_forward_declares.h>
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20481.57964.patch
Type: text/x-patch
Size: 708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160520/40e1f4c6/attachment.bin>


More information about the cfe-commits mailing list