]> granicus.if.org Git - clang/commitdiff
[OpenMP][bugfix] Add missing math functions variants for log and abs.
authorGheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com>
Fri, 17 May 2019 19:15:53 +0000 (19:15 +0000)
committerGheorghe-Teodor Bercea <gheorghe-teod.bercea@ibm.com>
Fri, 17 May 2019 19:15:53 +0000 (19:15 +0000)
Summary: When including the random header in C++, some of the math functions it relies on are not present in the CUDA headers. We include this variants in this case.

Reviewers: jdoerfert, hfinkel, tra, caomhin

Reviewed By: tra

Subscribers: efriedma, guansong, cfe-commits

Tags: #clang

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

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

lib/Headers/__clang_cuda_cmath.h
lib/Headers/__clang_cuda_math_forward_declares.h

index c570451c77f7aec3020a06f3052caf1b3e67bc64..834a2e3fd134cc8dbcb996dc6a5f765994462399 100644 (file)
@@ -51,6 +51,11 @@ __DEVICE__ long abs(long __n) { return ::labs(__n); }
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 #endif
+// TODO: remove once variat is supported.
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const float abs(const float __x) { return ::fabsf((float)__x); }
+__DEVICE__ const double abs(const double __x) { return ::fabs((double)__x); }
+#endif
 __DEVICE__ float acos(float __x) { return ::acosf(__x); }
 __DEVICE__ float asin(float __x) { return ::asinf(__x); }
 __DEVICE__ float atan(float __x) { return ::atanf(__x); }
index c94c3b7518fde08347f9527a9911ebe1f1645da4..0afe4db556dbc00843246fd1d551bbded71be993 100644 (file)
@@ -42,6 +42,14 @@ __DEVICE__ long long abs(long long);
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 #endif
+// While providing the CUDA declarations and definitions for math functions,
+// we may manually define additional functions.
+// TODO: Once variant is supported the additional functions will have
+// to be removed.
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const double abs(const double);
+__DEVICE__ const float abs(const float);
+#endif
 __DEVICE__ int abs(int) __NOEXCEPT;
 __DEVICE__ double acos(double);
 __DEVICE__ float acos(float);
@@ -144,6 +152,9 @@ __DEVICE__ double log2(double);
 __DEVICE__ float log2(float);
 __DEVICE__ double logb(double);
 __DEVICE__ float logb(float);
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ long double log(long double);
+#endif
 __DEVICE__ double log(double);
 __DEVICE__ float log(float);
 __DEVICE__ long lrint(double);