diff options
author | Justin Lebar <jlebar@google.com> | 2016-08-18 20:43:13 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-08-18 20:43:13 +0000 |
commit | c8c64a2013c7ce4bb3c3fb6d989d8e1309217340 (patch) | |
tree | e4feb2051c0e3b4aae75598560df8b63d8add619 /lib/Headers/__clang_cuda_math_forward_declares.h | |
parent | 2b5693d1fd9f0257ba6ce8d03810f73b859de228 (diff) |
[CUDA] Improve handling of math functions.
Summary:
A bunch of related changes here to our CUDA math headers.
- The second arg to nexttoward is a double (well, technically, long
double, but we don't have that), not a float.
- Add a forward-declare of llround(float), which is defined in the CUDA
headers. We need this for the same reason we need most of the other
forward-declares: To prevent a constexpr function in our standard
library from becoming host+device.
- Add nexttowardf implementation.
- Pull "foobarf" functions defined by the CUDA headers in the global
namespace into namespace std. This lets you do e.g. std::sinf.
- Add overloads for math functions accepting integer types. This lets
you do e.g. std::sin(0) without having an ambiguity between the
overload that takes a float and the one that takes a double.
With these changes, we pass testcases derived from libc++ for cmath and
math.h. We can check these testcases in to the test-suite once support
for CUDA lands there.
Reviewers: tra
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D23627
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@279140 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Headers/__clang_cuda_math_forward_declares.h')
-rw-r--r-- | lib/Headers/__clang_cuda_math_forward_declares.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Headers/__clang_cuda_math_forward_declares.h b/lib/Headers/__clang_cuda_math_forward_declares.h index 3f2834d950..0a605e1956 100644 --- a/lib/Headers/__clang_cuda_math_forward_declares.h +++ b/lib/Headers/__clang_cuda_math_forward_declares.h @@ -140,6 +140,7 @@ __DEVICE__ long lrint(double); __DEVICE__ long lrint(float); __DEVICE__ long lround(double); __DEVICE__ long lround(float); +__DEVICE__ long long llround(float); // No llround(double). __DEVICE__ double modf(double, double *); __DEVICE__ float modf(float, float *); __DEVICE__ double nan(const char *); @@ -149,7 +150,8 @@ __DEVICE__ float nearbyint(float); __DEVICE__ double nextafter(double, double); __DEVICE__ float nextafter(float, float); __DEVICE__ double nexttoward(double, double); -__DEVICE__ float nexttoward(float, float); +__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); @@ -235,6 +237,7 @@ using ::log2; using ::logb; using ::lrint; using ::lround; +using ::llround; using ::modf; using ::nan; using ::nanf; |