diff options
| author | Justin Lebar <jlebar@google.com> | 2017-11-17 01:15:43 +0000 |
|---|---|---|
| committer | Justin Lebar <jlebar@google.com> | 2017-11-17 01:15:43 +0000 |
| commit | 370c766e407ae1b44e568d55bc1f2a6aa1b12aeb (patch) | |
| tree | 00b08ff60acd1ce5c22d6951a064cd0d184de52f /clang/lib | |
| parent | 5a440d323a5baa51b6b2fa569ac14e96fe65312e (diff) | |
| download | bcm5719-llvm-370c766e407ae1b44e568d55bc1f2a6aa1b12aeb.tar.gz bcm5719-llvm-370c766e407ae1b44e568d55bc1f2a6aa1b12aeb.zip | |
[CUDA] Remove implementations of nexttoward.
Summary:
__builtin_nexttoward lowers to a libcall, e.g. nexttowardf(), that CUDA
does not have.
Rather than try to implement it, we simply remove these functions --
nvcc doesn't support them either, and nextafter, which does work, does
essentially the same thing on GPUs, because GPUs don't have long double.
Reviewers: tra
Subscribers: cfe-commits, sanjoy
Differential Revision: https://reviews.llvm.org/D40152
llvm-svn: 318494
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Headers/__clang_cuda_cmath.h | 23 | ||||
| -rw-r--r-- | clang/lib/Headers/__clang_cuda_math_forward_declares.h | 8 |
2 files changed, 8 insertions, 23 deletions
diff --git a/clang/lib/Headers/__clang_cuda_cmath.h b/clang/lib/Headers/__clang_cuda_cmath.h index 9bef82611aa..5331ba401a9 100644 --- a/clang/lib/Headers/__clang_cuda_cmath.h +++ b/clang/lib/Headers/__clang_cuda_cmath.h @@ -131,15 +131,6 @@ __DEVICE__ float ldexp(float __arg, int __exp) { __DEVICE__ float log(float __x) { return ::logf(__x); } __DEVICE__ float log10(float __x) { return ::log10f(__x); } __DEVICE__ float modf(float __x, float *__iptr) { return ::modff(__x, __iptr); } -__DEVICE__ float nexttoward(float __from, double __to) { - return __builtin_nexttowardf(__from, __to); -} -__DEVICE__ double nexttoward(double __from, double __to) { - return __builtin_nexttoward(__from, __to); -} -__DEVICE__ float nexttowardf(float __from, double __to) { - return __builtin_nexttowardf(__from, __to); -} __DEVICE__ float pow(float __base, float __exp) { return ::powf(__base, __exp); } @@ -157,6 +148,10 @@ __DEVICE__ float sqrt(float __x) { return ::sqrtf(__x); } __DEVICE__ float tan(float __x) { return ::tanf(__x); } __DEVICE__ float tanh(float __x) { return ::tanhf(__x); } +// Notably missing above is nexttoward. We omit it because +// libdevice doesn't provide an implementation, and we don't want to be in the +// business of implementing tricky libm functions in this header. + // Now we've defined everything we promised we'd define in // __clang_cuda_math_forward_declares.h. We need to do two additional things to // fix up our math functions. @@ -295,13 +290,6 @@ ldexp(__T __x, int __exp) { return std::ldexp((double)__x, __exp); } -template <typename __T> -__DEVICE__ typename __clang_cuda_enable_if<std::numeric_limits<__T>::is_integer, - double>::type -nexttoward(__T __from, double __to) { - return std::nexttoward((double)__from, __to); -} - template <typename __T1, typename __T2> __DEVICE__ typename __clang_cuda_enable_if< std::numeric_limits<__T1>::is_specialized && @@ -388,7 +376,6 @@ using ::lrint; using ::lround; using ::nearbyint; using ::nextafter; -using ::nexttoward; using ::pow; using ::remainder; using ::remquo; @@ -456,8 +443,6 @@ using ::lroundf; using ::modff; using ::nearbyintf; using ::nextafterf; -using ::nexttowardf; -using ::nexttowardf; using ::powf; using ::remainderf; using ::remquof; diff --git a/clang/lib/Headers/__clang_cuda_math_forward_declares.h b/clang/lib/Headers/__clang_cuda_math_forward_declares.h index 49c805151d6..c31b1f4cda3 100644 --- a/clang/lib/Headers/__clang_cuda_math_forward_declares.h +++ b/clang/lib/Headers/__clang_cuda_math_forward_declares.h @@ -149,9 +149,6 @@ __DEVICE__ double nearbyint(double); __DEVICE__ float nearbyint(float); __DEVICE__ double nextafter(double, double); __DEVICE__ float nextafter(float, float); -__DEVICE__ double nexttoward(double, double); -__DEVICE__ float nexttoward(float, double); -__DEVICE__ float nexttowardf(float, double); __DEVICE__ double pow(double, double); __DEVICE__ double pow(double, int); __DEVICE__ float pow(float, float); @@ -185,6 +182,10 @@ __DEVICE__ float tgamma(float); __DEVICE__ double trunc(double); __DEVICE__ float trunc(float); +// Notably missing above is nexttoward, which we don't define on +// the device side because libdevice doesn't give us an implementation, and we +// don't want to be in the business of writing one ourselves. + // We need to define these overloads in exactly the namespace our standard // library uses (including the right inline namespace), otherwise they won't be // picked up by other functions in the standard library (e.g. functions in @@ -255,7 +256,6 @@ using ::nan; using ::nanf; using ::nearbyint; using ::nextafter; -using ::nexttoward; using ::pow; using ::remainder; using ::remquo; |

