[PATCH] D37906: [CUDA] Work around a new quirk in CUDA9 headers.
tra created this revision. Herald added a subscriber: sanjoy. 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 https://reviews.llvm.org/D37906 Files: clang/lib/Headers/__clang_cuda_runtime_wrapper.h Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h === --- clang/lib/Headers/__clang_cuda_runtime_wrapper.h +++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h @@ -254,7 +254,17 @@ #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") Index: clang/lib/Headers/__clang_cuda_runtime_wrapper.h === --- clang/lib/Headers/__clang_cuda_runtime_wrapper.h +++ clang/lib/Headers/__clang_cuda_runtime_wrapper.h @@ -254,7 +254,17 @@ #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") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37906: [CUDA] Work around a new quirk in CUDA9 headers.
jlebar added a comment. This is a bit of a Chesterton's Fence -- do we know why they're doing this? I guess it's probably going to be OK because our overriding semantics will make it OK, and our test-suite tests (should) exercise all of math.h. But I'm still a little worried about it. https://reviews.llvm.org/D37906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37906: [CUDA] Work around a new quirk in CUDA9 headers.
tra added a comment. I don't think we really care why they do it for nvcc. My understanding is that nvcc needs to avoid name clashes between their implementation of functions and the ones that come from the host headers and that's why they have to tread really carefully around host includes. We just need to get those definitions of the device-side functions and we don't care whether host-side functions with the same name are visible at the same time. I wish CUDA would just put all device-side function definitions into a separate file/namespace and let us cherry-pick them at will. Alas, we have to work around nvcc's work arounds... BTW, this change essentially augments the job that the "#undef __GNUC__" above used to do in older CUDA versions. CUDA9 replaced __GNUC__ with _GLIBCXX_MATH_H in CUDA-9 in some places. https://reviews.llvm.org/D37906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37906: [CUDA] Work around a new quirk in CUDA9 headers.
jlebar accepted this revision. jlebar added a comment. This revision is now accepted and ready to land. > BTW, this change essentially augments the job that the "#undef GNUC" above > used to do in older CUDA versions. CUDA9 replaced GNUC with _GLIBCXX_MATH_H > in CUDA-9 in some places. Ah, that's right. Okay then. :) https://reviews.llvm.org/D37906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D37906: [CUDA] Work around a new quirk in CUDA9 headers.
This revision was automatically updated to reflect the committed changes. Closed by commit rL313369: [CUDA] Work around a new quirk in CUDA9 headers. (authored by tra). Changed prior to commit: https://reviews.llvm.org/D37906?vs=115415&id=115422#toc Repository: rL LLVM https://reviews.llvm.org/D37906 Files: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h === --- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h +++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h @@ -254,7 +254,17 @@ #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") Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h === --- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h +++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h @@ -254,7 +254,17 @@ #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") ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits