]> granicus.if.org Git - clang/commitdiff
[CUDA] Work around a new quirk in CUDA9 headers.
authorArtem Belevich <tra@google.com>
Fri, 15 Sep 2017 17:30:53 +0000 (17:30 +0000)
committerArtem Belevich <tra@google.com>
Fri, 15 Sep 2017 17:30:53 +0000 (17:30 +0000)
In CUDA-9 some of device-side math functions that we need are conditionally
defined within '#if _GLIBCXX_MATH_H'. We need to temporarily undo the guard
around inclusion of math_functions.hpp.

Differential Revision: https://reviews.llvm.org/D37906

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@313369 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Headers/__clang_cuda_runtime_wrapper.h

index b5b173cd0cdb88373f8633d4992067c73643e8f8..e4fc5860b50367b1811254889844151f665c0bb6 100644 (file)
@@ -254,7 +254,17 @@ static inline __device__ void __brkpt(int __c) { __brkpt(); }
 #pragma push_macro("__GNUC__")
 #undef __GNUC__
 #define signbit __ignored_cuda_signbit
+
+// CUDA-9 omits device-side definitions of some math functions if it sees
+// include guard from math.h wrapper from libstdc++. We have to undo the header
+// guard temporarily to get the definitions we need.
+#pragma push_macro("_GLIBCXX_MATH_H")
+#if CUDA_VERSION >= 9000
+#undef _GLIBCXX_MATH_H
+#endif
+
 #include "math_functions.hpp"
+#pragma pop_macro("_GLIBCXX_MATH_H")
 #pragma pop_macro("__GNUC__")
 #pragma pop_macro("signbit")