libcudacxx icon indicating copy to clipboard operation
libcudacxx copied to clipboard

Make CUDA annotated functions available in usual std namespace

Open krzikalla opened this issue 2 years ago • 3 comments

What are the chances that one day I will be able to write the following:

#include <complex>

#ifdef __NVCC__
#define FN_PREFIX __host__ __device__
#else
#define FN_PREFIX
#endif

FN_PREFIX void flexible_foo(std::complex<double> x)
{
  std::complex<double> y = x+x;
}

In the current state the library is barely usable for me, since I still have to write my kernels and includes either with macros all over the place or without the STL at all.

krzikalla avatar Oct 29 '21 13:10 krzikalla

We have a tentative goal to be compatible with source that is not compiled under NVCC. Is that something that's impacting you currently? If so I would be happy to attempt to fix it.

What you may be asking for however is not an immediate goal of ours. We aren't prepared to ship anything that would replace the standard library that comes with your toolchain.

wmaxey avatar Oct 29 '21 19:10 wmaxey

Eventually you will be able to write the following with NVC++:

#include <complex>

void flexible_foo(std::complex<double> x)
{
  std::complex<double> y = x+x;
}

and have it run on your CPU or GPU. __host__ __device__ isn't needed with NVC++.

brycelelbach avatar Nov 01 '21 20:11 brycelelbach

Ah, that's even better. I always wondered, why the __host__ __device__ was necessary, since the compiler is already able to complain about missing those prefixes. When will NVC++ arrive?

krzikalla avatar Nov 02 '21 06:11 krzikalla

Given that NVC++ is available with the HPC SDK I believe we can close this issue

miscco avatar Feb 23 '23 10:02 miscco