Skip to content

Commit 890fdb8

Browse files
fodinabortstellar
authored andcommitted
[OpenMP] Use __OPENMP_NVPTX__ instead of _OPENMP in complex wrapper headers.
This is very similar to 7f1e6fc, 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 (cherry picked from commit eaee608)
1 parent 075cca3 commit 890fdb8

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

clang/lib/Headers/__clang_cuda_complex_builtins.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// to work with CUDA and OpenMP target offloading [in C and C++ mode].)
1717

1818
#pragma push_macro("__DEVICE__")
19-
#ifdef _OPENMP
19+
#ifdef __OPENMP_NVPTX__
2020
#pragma omp declare target
2121
#define __DEVICE__ __attribute__((noinline, nothrow, cold, weak))
2222
#else
@@ -26,7 +26,7 @@
2626
// To make the algorithms available for C and C++ in CUDA and OpenMP we select
2727
// different but equivalent function versions. TODO: For OpenMP we currently
2828
// select the native builtins as the overload support for templates is lacking.
29-
#if !defined(_OPENMP)
29+
#if !defined(__OPENMP_NVPTX__)
3030
#define _ISNANd std::isnan
3131
#define _ISNANf std::isnan
3232
#define _ISINFd std::isinf
@@ -250,7 +250,7 @@ __DEVICE__ float _Complex __divsc3(float __a, float __b, float __c, float __d) {
250250
#undef _LOGBd
251251
#undef _LOGBf
252252

253-
#ifdef _OPENMP
253+
#ifdef __OPENMP_NVPTX__
254254
#pragma omp end declare target
255255
#endif
256256

clang/lib/Headers/openmp_wrappers/complex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include <cmath>
1919

2020
#define __CUDA__
21+
#define __OPENMP_NVPTX__
2122
#include <__clang_cuda_complex_builtins.h>
23+
#undef __OPENMP_NVPTX__
2224
#endif
2325

2426
// Grab the host header too.

clang/lib/Headers/openmp_wrappers/complex.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
#include <math.h>
1919

2020
#define __CUDA__
21+
#define __OPENMP_NVPTX__
2122
#include <__clang_cuda_complex_builtins.h>
23+
#undef __OPENMP_NVPTX__
2224
#endif
2325

2426
// Grab the host header too.

0 commit comments

Comments
 (0)