[clang] eaee608 - [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in complex wrapper headers.
Joachim Meyer via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 29 15:25:01 PDT 2020
Author: Joachim Meyer
Date: 2020-10-29T23:24:49+01:00
New Revision: eaee608448c832e8f806faae30ae4100620c4688
URL: https://github.com/llvm/llvm-project/commit/eaee608448c832e8f806faae30ae4100620c4688
DIFF: https://github.com/llvm/llvm-project/commit/eaee608448c832e8f806faae30ae4100620c4688.diff
LOG: [OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in complex wrapper headers.
This is very similar to 7f1e6fcff942, just fixing a left-over.
With this, it should be possible to use both, -x cuda and -fopenmp in the same invocation,
enabling to use both OpenMP, targeting CPU, and CUDA, targeting the GPU.
Reviewed By: jdoerfert
Differential Revision: https://reviews.llvm.org/D90415
Added:
Modified:
clang/lib/Headers/__clang_cuda_complex_builtins.h
clang/lib/Headers/openmp_wrappers/complex
clang/lib/Headers/openmp_wrappers/complex.h
Removed:
################################################################################
diff --git a/clang/lib/Headers/__clang_cuda_complex_builtins.h b/clang/lib/Headers/__clang_cuda_complex_builtins.h
index 9b254f700b9d..2b701fef0ea2 100644
--- a/clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ b/clang/lib/Headers/__clang_cuda_complex_builtins.h
@@ -16,7 +16,7 @@
// to work with CUDA and OpenMP target offloading [in C and C++ mode].)
#pragma push_macro("__DEVICE__")
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
#pragma omp declare target
#define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
#else
@@ -26,7 +26,7 @@
// To make the algorithms available for C and C++ in CUDA and OpenMP we select
//
diff erent but equivalent function versions. TODO: For OpenMP we currently
// select the native builtins as the overload support for templates is lacking.
-#if !defined(_OPENMP)
+#if !defined(__OPENMP_NVPTX__)
#define _ISNANd std::isnan
#define _ISNANf std::isnan
#define _ISINFd std::isinf
@@ -276,7 +276,7 @@ __DEVICE__ float _Complex __divsc3(float __a, float __b, float __c, float __d) {
#undef _fmaxd
#undef _fmaxf
-#ifdef _OPENMP
+#ifdef __OPENMP_NVPTX__
#pragma omp end declare target
#endif
diff --git a/clang/lib/Headers/openmp_wrappers/complex b/clang/lib/Headers/openmp_wrappers/complex
index 306ffe208053..142e526b81b3 100644
--- a/clang/lib/Headers/openmp_wrappers/complex
+++ b/clang/lib/Headers/openmp_wrappers/complex
@@ -18,7 +18,9 @@
#include <cmath>
#define __CUDA__
+#define __OPENMP_NVPTX__
#include <__clang_cuda_complex_builtins.h>
+#undef __OPENMP_NVPTX__
#endif
// Grab the host header too.
diff --git a/clang/lib/Headers/openmp_wrappers/complex.h b/clang/lib/Headers/openmp_wrappers/complex.h
index 829c7a785725..00d278548f82 100644
--- a/clang/lib/Headers/openmp_wrappers/complex.h
+++ b/clang/lib/Headers/openmp_wrappers/complex.h
@@ -18,7 +18,9 @@
#include <math.h>
#define __CUDA__
+#define __OPENMP_NVPTX__
#include <__clang_cuda_complex_builtins.h>
+#undef __OPENMP_NVPTX__
#endif
// Grab the host header too.
More information about the cfe-commits
mailing list