[CUDA] Improve handling of math functions.
authorJustin Lebar <jlebar@google.com>
Thu, 18 Aug 2016 20:43:13 +0000 (20:43 +0000)
committerJustin Lebar <jlebar@google.com>
Thu, 18 Aug 2016 20:43:13 +0000 (20:43 +0000)
commitcb20a09f54efc4dc90852365f4301785ffab4c56
tree27fe34a6c7fcaa583fc87b8605b610a57237f52b
parent40e8ca46ad4a02c3cd2b29347ae340e7fd1be1aa
[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

llvm-svn: 279140
clang/lib/Headers/__clang_cuda_cmath.h
clang/lib/Headers/__clang_cuda_math_forward_declares.h