Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for cmath #983

Open
mnicely opened this issue Jun 15, 2021 · 4 comments
Open

Add support for cmath #983

mnicely opened this issue Jun 15, 2021 · 4 comments
Assignees
Labels
libcu++ For all items related to libcu++

Comments

@mnicely
Copy link

mnicely commented Jun 15, 2021

We should add support for cmath
https://en.cppreference.com/w/cpp/header/cmath

@wmaxey wmaxey self-assigned this Jun 15, 2021
@wmaxey
Copy link
Member

wmaxey commented Jun 15, 2021

I would like to do this after the NVC++ rework. Currently we have the bare minimum exposed for complex.

@brycelelbach
Copy link
Collaborator

brycelelbach commented Jun 16, 2021

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.

@karthikeyann
Copy link
Contributor

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.

@jrhemstad jrhemstad added thrust For all items related to Thrust. libcu++ For all items related to libcu++ and removed thrust For all items related to Thrust. labels Feb 22, 2023
@jarmak-nv jarmak-nv transferred this issue from NVIDIA/libcudacxx Nov 8, 2023
@github-project-automation github-project-automation bot moved this to Todo in CCCL Nov 8, 2023
@cliffburdick
Copy link

To be more clear on the ask here, CCCL has since added support for cmath where it no longer requires --relaxed-constexpr to use the functions. However, many of the implementations in libstdc++ are inefficient on a GPU and may be better suited to either default to a path using intrinsics, or having an option to do so. Several issues have been affected by this in the past, including trigonometric functions that have multiple NaN or Inf checks that may not be needed on the GPU.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libcu++ For all items related to libcu++
Projects
Status: Todo
Development

No branches or pull requests

6 participants