[PATCH] D105221: [openmp][nfc] Simplify macros guarding math complex headers
Jon Chesterfield via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 30 11:51:13 PDT 2021
JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, tianshilei1992, pdhaliwal.
Herald added subscribers: guansong, kristof.beyls, tpr, yaxunl.
JonChesterfield requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.
[openmp][nfc] Simplify macros guarding math complex headers
The __CUDA__ macro is already defined for openmp/nvptx and is not used by
__clang_cuda_complex_builtins.h, so dropping that macro slightly simplifies
nvptx and avoids defining it on amdgcn (where it is likely to be harmful).
The cuda_complex_builtins file has already been updated to work with amdgcn.
Using _OPENMP instead of __OPENMP_NVPTX__ there means one fewer macro to define
and it will work on amdgpu openmp when the rest of math is enabled.
Finally dropped a cplusplus test from a C++ header as compilation will have
failed on cmath earlier if it was included from C.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D105221
Files:
clang/lib/Headers/__clang_cuda_complex_builtins.h
clang/lib/Headers/openmp_wrappers/complex
clang/lib/Headers/openmp_wrappers/complex.h
Index: clang/lib/Headers/openmp_wrappers/complex.h
===================================================================
--- clang/lib/Headers/openmp_wrappers/complex.h
+++ clang/lib/Headers/openmp_wrappers/complex.h
@@ -17,10 +17,8 @@
// We require math functions in the complex builtins below.
#include <math.h>
-#define __CUDA__
-#define __OPENMP_NVPTX__
#include <__clang_cuda_complex_builtins.h>
-#undef __OPENMP_NVPTX__
+
#endif
// Grab the host header too.
Index: clang/lib/Headers/openmp_wrappers/complex
===================================================================
--- clang/lib/Headers/openmp_wrappers/complex
+++ clang/lib/Headers/openmp_wrappers/complex
@@ -17,18 +17,12 @@
// We require std::math functions in the complex builtins below.
#include <cmath>
-#define __CUDA__
-#define __OPENMP_NVPTX__
#include <__clang_cuda_complex_builtins.h>
-#undef __OPENMP_NVPTX__
#endif
// Grab the host header too.
#include_next <complex>
-
-#ifdef __cplusplus
-
// If we are compiling against libc++, the macro _LIBCPP_STD_VER should be set
// after including <cmath> above. Since the complex header we use is a
// simplified version of the libc++, we don't need it in this case. If we
@@ -48,5 +42,3 @@
#pragma omp end declare variant
#endif
-
-#endif
Index: clang/lib/Headers/__clang_cuda_complex_builtins.h
===================================================================
--- clang/lib/Headers/__clang_cuda_complex_builtins.h
+++ 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_NVPTX__
+#ifdef _OPENMP
#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
// different but equivalent function versions. TODO: For OpenMP we currently
// select the native builtins as the overload support for templates is lacking.
-#if !defined(__OPENMP_NVPTX__)
+#if !defined(_OPENMP)
#define _ISNANd std::isnan
#define _ISNANf std::isnan
#define _ISINFd std::isinf
@@ -276,7 +276,7 @@
#undef _fmaxd
#undef _fmaxf
-#ifdef __OPENMP_NVPTX__
+#ifdef _OPENMP
#pragma omp end declare target
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105221.355652.patch
Type: text/x-patch
Size: 2322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210630/10489ae7/attachment.bin>
More information about the cfe-commits
mailing list