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

Artem Belevich via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 16 17:03:05 PDT 2019


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





More information about the cfe-commits mailing list