libcudacxx
libcudacxx copied to clipboard
Add support for cmath
trafficstars
We should add support for cmath
https://en.cppreference.com/w/cpp/header/cmath
I would like to do this after the NVC++ rework. Currently we have the bare minimum exposed for complex.
We'll need to coordinate with the CUDA math libraries team. I'll tentatively set it as a goal for 2.2.0, which would be early 2022.
Usage of (present) cmath functions in Windows nvcc 11.2 causes error.
nvcc -std=c++17 cmath_test.cu --expt-relaxed-constexpr
cmath_test.cu(4): error: calling a __host__ function("exp<int, (int)0> ") from a __global__ function("kernel") is not allowed
cmath_test.cu(4): error: identifier "exp<int, (int)0> " is undefined in device code
Code:
#include <cuda/std/cmath>
__global__ void kernel() {
cuda::std::exp(int{0});
}
int main() {
kernel<<<1,1>>>();
}
Right now, libcudacxx cmath uses std cmath. in Linux, functions in gnu std cmath are constexpr. In MSVC cmath, it's not.