[PATCH] D23627: [CUDA] Improve handling of math functions.

Justin Lebar via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 17 14:44:32 PDT 2016


jlebar created this revision.
jlebar added a reviewer: tra.
jlebar added a subscriber: cfe-commits.

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.

https://reviews.llvm.org/D23627

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23627.68427.patch
Type: text/x-patch
Size: 12509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160817/b4ae98bb/attachment.bin>


More information about the cfe-commits mailing list