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

Feature: clang CUDA (device compilation) support #991

Closed
MatthiasKohl opened this issue Dec 16, 2021 · 9 comments
Closed

Feature: clang CUDA (device compilation) support #991

MatthiasKohl opened this issue Dec 16, 2021 · 9 comments
Assignees
Labels
libcu++ For all items related to libcu++

Comments

@MatthiasKohl
Copy link

This issue is similar to this one in cuCollections: NVIDIA/cuCollections#128

While working on RAFT (primitives for RADPIS, PR: rapidsai/raft#424), I noticed that libcudacxx doesn't support having its device code compiled with clang.

It would be great to support this, if possible.
If test coverage is good enough, it's usually good enough to simply transform nvcc commands to clang for which I have a somewhat usable script in the above mentioned PR for RAFT, and apply those commands to the entire test suite.

@wmaxey wmaxey self-assigned this Dec 17, 2021
@wmaxey
Copy link
Member

wmaxey commented Dec 17, 2021

We'll place this on a milestone once we get gpuCI, that's a prerequisite to this as we don't have the capacity on DVS.

@gonzalobg
Copy link
Collaborator

This was supported a year ago. @MatthiasKohl what error are you encountering?

@MatthiasKohl
Copy link
Author

Responded with PM, the error comes from using cuCollections and in particular, the static map implementation.

@upsj
Copy link

upsj commented Jul 6, 2022

I am having the same kind of issue trying to compile cuDF with clang as device compiler. The specific error I'm observing occurs in type_traits:

In file included from /home/tribizel/cudf/cpp/build/_deps/libcudacxx-src/include/cuda/std/limits:16:
In file included from /home/tribizel/cudf/cpp/build/_deps/libcudacxx-src/include/cuda/std/type_traits:24:
/home/tribizel/cudf/cpp/build/_deps/libcudacxx-src/include/cuda/std/detail/libcxx/include/type_traits:520:12: error: CUDA device code does not support variadic functions
false_type __sfinae_test_impl(...);
           ^
/home/tribizel/cudf/cpp/build/_deps/libcudacxx-src/include/cuda/std/detail/libcxx/include/type_traits:1059:69: error: CUDA device code does not support variadic functions
    template <class _Tp> _LIBCUDACXX_INLINE_VISIBILITY static __two __test(...);
                                                                    ^
/home/tribizel/cudf/cpp/build/_deps/libcudacxx-src/include/cuda/std/detail/libcxx/include/type_traits:1171:5: error: CUDA device code does not support variadic functions
    __any(...);
    ^
/home/tribizel/cudf/cpp/build/_deps/libcudacxx-src/include/cuda/std/detail/libcxx/include/type_traits:1848:16: error: CUDA device code does not support variadic functions
   static void __test(...);
               ^
/home/tribizel/cudf/cpp/build/_deps/libcudacxx-src/include/cuda/std/detail/libcxx/include/type_traits:2272:18: error: CUDA device code does not support variadic functions
    static __two __test (...);
                 ^
/home/tribizel/cudf/cpp/build/_deps/libcudacxx-src/include/cuda/std/detail/libcxx/include/type_traits:4332:16: error: CUDA device code does not support variadic functions
  static __nat __try_call(...);

This is running clang 14.0.6 compiled using spack based on CUDA 10.2

@maddyscientist
Copy link

For clang you probably need to enable the use of variadic functions with -fcuda-allow-variadic-functions

@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 assigned alliepiper and unassigned wmaxey Feb 23, 2023
@alliepiper alliepiper assigned jrhemstad and unassigned alliepiper Feb 23, 2023
@Artem-B
Copy link
Contributor

Artem-B commented Apr 5, 2023

A word of caution. Clang currently does not have support for GPU-side variadic functions but in this case it's benign, as this is only a declaration used as a low-priority overload candidate for which we will not need to generate any code. That said, when the option is in effect, it may lead to a miscompilation or compiler crash if you try to compile an actual variadic function for a GPU. There's been some progress on this (llvm/llvm-project#58410). LLVM support has been added recently, but it's not been plumbed through to the CUDA front-end yet)

If you run into clang issues, please do file an issue in LLVM's repo. libcudacxx is getting more users and it would be useful to know what features are actually needed. Otherwise we end up in a bit of a catch-22 situation -- people can't use clang for CUDA compilation because feature X is missing, and the feature X is missing because nobody asks for it.

@jrhemstad
Copy link
Collaborator

Clang currently does not have support for GPU-side variadic functions

This is news to me. So the -fcuda-allow-variadic-functions flag will just emit garbage if you actually use a variadic function in device code?

@Artem-B
Copy link
Contributor

Artem-B commented Apr 10, 2023

will just emit garbage

I do not think so. You will probably run into and error if there's a real attempt to use varargs via va_start/va_arg. E.g. https://godbolt.org/z/3qa5dn88c

Most of the required functionality is already in place, we're missing a bit of glue to tie it all together.

@jarmak-nv jarmak-nv transferred this issue from NVIDIA/libcudacxx Nov 8, 2023
@jrhemstad
Copy link
Collaborator

closed by #493

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
Archived in project
Development

No branches or pull requests

8 participants