[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-08-12 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I'm not sure about this diff. I think it's breaking  and . 
Raised bug https://bugs.llvm.org/show_bug.cgi?id=42972


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-17 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC361066: [OpenMP][bugfix] Add missing math functions variants 
for log and abs. (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62046?vs=200048=200076#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h


Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -42,6 +42,14 @@
 __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__ 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);
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -51,6 +51,11 @@
 __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: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -42,6 +42,14 @@
 __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__ 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);
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -51,6 +51,11 @@
 __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); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-17 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

I'd add a comment with a brief explanation for the const variant and a TODO() 
to remove it.

Looks OK to me otherwise.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-17 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

@tra I eliminated the long double definition for log and only left the 
declaration.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-17 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 200048.
gtbercea added a comment.

- update patch


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_math_forward_declares.h


Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -42,6 +42,10 @@
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 #endif
+#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 +148,9 @@
 __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);
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -51,6 +51,10 @@
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 #endif
+#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: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -42,6 +42,10 @@
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 #endif
+#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 +148,9 @@
 __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);
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -51,6 +51,10 @@
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 #endif
+#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); }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-17 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

This LGTM me, @tra or @efriedma any objections?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-16 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: lib/Headers/__clang_cuda_cmath.h:55-56
+#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

efriedma wrote:
> gtbercea wrote:
> > tra wrote:
> > > Where do these functions come from?  
> > > https://en.cppreference.com/w/cpp/numeric/math/fabs does not seem to show 
> > > any `abs` functions with const args.
> > What's happening is that when including the random header file, this header 
> > file uses abs with const arguments:
> > 
> > 
> > ```
> > const double __n = _M_nd(__urng);
> > const double __y = -std::abs(__n) * __param._M_sm - 1;
> > ```
> > 
> > And without there functions here the error I get is:
> > 
> > 
> > ```
> > In file included from test.c:8:
> > In file included from 
> > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/random:52:
> > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/random.tcc:1476:27:
> >  error: call to 'abs' is ambiguous
> > const double __y = -std::abs(__n) * __param._M_sm - 1;
> > ^~~~
> > /usr/include/stdlib.h:770:12: note: candidate function
> > extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
> >^
> > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
> >  note: candidate function
> >   abs(long __i) { return __builtin_labs(__i); }
> >   ^
> > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
> >  note: candidate function
> >   abs(long long __x) { return __builtin_llabs (__x); }
> >   ^
> > /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:179:3:
> >  note: candidate function
> >   abs(__int128 __x) { return __x >= 0 ? __x : -__x; }
> >   ^
> > ```
> Overloading ignores the "const"; `float abs(float)` is the same thing.  So 
> probably clearer to declare it without the extra "const" modifiers, and then 
> clean up the redundant definitions.
> 
> That said, I'm not sure how you managed to pick up the declarations from 
> cstdlib, but not cmath. What files are getting included when this fails?
> 
> (Actually, in C++17, both cmath and cstdlib are supposed to declare all the 
> float and integer overloads of abs, but that's only implemented in newer 
> versions of libstdc++.)
> That said, I'm not sure how you managed to pick up the declarations from 
> cstdlib, but not cmath. What files are getting included when this fails?

Until we get support for OpenMP `omp declare variant begin/end` support in 
clang (X), we will only provide the CUDA declarations & definitions for math 
functions, not the host ones. It is one of these problems that arises when the 
single source language needs both, device and host definitions. (In CUDA the 
`__device__` overload is the way out, in OpenMP it will be `variant` with an 
appropriate device context.)

(X) I'm right now working on integrating this into OpenMP 5.1 but we can 
implement it as soon as the design is decided on.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-16 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Headers/__clang_cuda_cmath.h:55-56
+#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

gtbercea wrote:
> tra wrote:
> > Where do these functions come from?  
> > https://en.cppreference.com/w/cpp/numeric/math/fabs does not seem to show 
> > any `abs` functions with const args.
> What's happening is that when including the random header file, this header 
> file uses abs with const arguments:
> 
> 
> ```
> const double __n = _M_nd(__urng);
> const double __y = -std::abs(__n) * __param._M_sm - 1;
> ```
> 
> And without there functions here the error I get is:
> 
> 
> ```
> In file included from test.c:8:
> In file included from 
> /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/random:52:
> /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/random.tcc:1476:27:
>  error: call to 'abs' is ambiguous
> const double __y = -std::abs(__n) * __param._M_sm - 1;
> ^~~~
> /usr/include/stdlib.h:770:12: note: candidate function
> extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
>^
> /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
>  note: candidate function
>   abs(long __i) { return __builtin_labs(__i); }
>   ^
> /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
>  note: candidate function
>   abs(long long __x) { return __builtin_llabs (__x); }
>   ^
> /usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:179:3:
>  note: candidate function
>   abs(__int128 __x) { return __x >= 0 ? __x : -__x; }
>   ^
> ```
Overloading ignores the "const"; `float abs(float)` is the same thing.  So 
probably clearer to declare it without the extra "const" modifiers, and then 
clean up the redundant definitions.

That said, I'm not sure how you managed to pick up the declarations from 
cstdlib, but not cmath. What files are getting included when this fails?

(Actually, in C++17, both cmath and cstdlib are supposed to declare all the 
float and integer overloads of abs, but that's only implemented in newer 
versions of libstdc++.)


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-16 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/Headers/__clang_cuda_device_functions.h:1604
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ double log(long double __a) { return __nv_log((double)__a); }
+#endif

tra wrote:
> Should the return type also be `long double` ?
> In general long double is not supported by CUDA. I'd provide a declaration 
> here, if it's absolutely needed, but no definition, so if someone  attempts 
> to actually use it, the application will fail to link.
> 
> Silently reducing precision by falling back to double is the wrong thing to 
> do, IMO.
Agreed.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-16 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: lib/Headers/__clang_cuda_cmath.h:55-56
+#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

tra wrote:
> Where do these functions come from?  
> https://en.cppreference.com/w/cpp/numeric/math/fabs does not seem to show any 
> `abs` functions with const args.
What's happening is that when including the random header file, this header 
file uses abs with const arguments:


```
const double __n = _M_nd(__urng);
const double __y = -std::abs(__n) * __param._M_sm - 1;
```

And without there functions here the error I get is:


```
In file included from test.c:8:
In file included from 
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/random:52:
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/random.tcc:1476:27:
 error: call to 'abs' is ambiguous
const double __y = -std::abs(__n) * __param._M_sm - 1;
^~~~
/usr/include/stdlib.h:770:12: note: candidate function
extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
   ^
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:166:3:
 note: candidate function
  abs(long __i) { return __builtin_labs(__i); }
  ^
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:174:3:
 note: candidate function
  abs(long long __x) { return __builtin_llabs (__x); }
  ^
/usr/lib/gcc/ppc64le-redhat-linux/4.8.5/../../../../include/c++/4.8.5/cstdlib:179:3:
 note: candidate function
  abs(__int128 __x) { return __x >= 0 ? __x : -__x; }
  ^
```


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-16 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: lib/Headers/__clang_cuda_cmath.h:55-56
+#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

Where do these functions come from?  
https://en.cppreference.com/w/cpp/numeric/math/fabs does not seem to show any 
`abs` functions with const args.



Comment at: lib/Headers/__clang_cuda_device_functions.h:1604
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ double log(long double __a) { return __nv_log((double)__a); }
+#endif

Should the return type also be `long double` ?
In general long double is not supported by CUDA. I'd provide a declaration 
here, if it's absolutely needed, but no definition, so if someone  attempts to 
actually use it, the application will fail to link.

Silently reducing precision by falling back to double is the wrong thing to do, 
IMO.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62046/new/

https://reviews.llvm.org/D62046



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62046: [OpenMP][bugfix] Add missing math functions variants for log and abs.

2019-05-16 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: jdoerfert, hfinkel, tra, caomhin.
Herald added subscribers: cfe-commits, guansong.
Herald added a project: clang.

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.


Repository:
  rC Clang

https://reviews.llvm.org/D62046

Files:
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_math_forward_declares.h


Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -42,6 +42,10 @@
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 #endif
+#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 +148,9 @@
 __DEVICE__ float log2(float);
 __DEVICE__ double logb(double);
 __DEVICE__ float logb(float);
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ double log(long double);
+#endif
 __DEVICE__ double log(double);
 __DEVICE__ float log(float);
 __DEVICE__ long lrint(double);
Index: lib/Headers/__clang_cuda_device_functions.h
===
--- lib/Headers/__clang_cuda_device_functions.h
+++ lib/Headers/__clang_cuda_device_functions.h
@@ -1600,6 +1600,9 @@
 __DEVICE__ long long llrintf(float __a) { return __nv_llrintf(__a); }
 __DEVICE__ long long llround(double __a) { return __nv_llround(__a); }
 __DEVICE__ long long llroundf(float __a) { return __nv_llroundf(__a); }
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ double log(long double __a) { return __nv_log((double)__a); }
+#endif
 __DEVICE__ double log(double __a) { return __nv_log(__a); }
 __DEVICE__ double log10(double __a) { return __nv_log10(__a); }
 __DEVICE__ float log10f(float __a) { return __nv_log10f(__a); }
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -51,6 +51,10 @@
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 #endif
+#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: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -42,6 +42,10 @@
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
 #endif
+#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 +148,9 @@
 __DEVICE__ float log2(float);
 __DEVICE__ double logb(double);
 __DEVICE__ float logb(float);
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ double log(long double);
+#endif
 __DEVICE__ double log(double);
 __DEVICE__ float log(float);
 __DEVICE__ long lrint(double);
Index: lib/Headers/__clang_cuda_device_functions.h
===
--- lib/Headers/__clang_cuda_device_functions.h
+++ lib/Headers/__clang_cuda_device_functions.h
@@ -1600,6 +1600,9 @@
 __DEVICE__ long long llrintf(float __a) { return __nv_llrintf(__a); }
 __DEVICE__ long long llround(double __a) { return __nv_llround(__a); }
 __DEVICE__ long long llroundf(float __a) { return __nv_llroundf(__a); }
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ double log(long double __a) { return __nv_log((double)__a); }
+#endif
 __DEVICE__ double log(double __a) { return __nv_log(__a); }
 __DEVICE__ double log10(double __a) { return __nv_log10(__a); }
 __DEVICE__ float log10f(float __a) { return __nv_log10f(__a); }
Index: lib/Headers/__clang_cuda_cmath.h
===
--- lib/Headers/__clang_cuda_cmath.h
+++ lib/Headers/__clang_cuda_cmath.h
@@ -51,6 +51,10 @@
 __DEVICE__ float abs(float __x) { return ::fabsf(__x); }
 __DEVICE__ double abs(double __x) { return ::fabs(__x); }
 #endif
+#if defined(_OPENMP) && defined(__cplusplus)
+__DEVICE__ const float abs(const float __x) { return ::fabsf((float)__x); }
+__DEVICE__ const double abs(const