Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use CUDA C for object oriented programming?

Tags:

c

oop

cuda

Is it possible to use CUDA C for object oriented programming? Are there any classes in CUDA C like in C++?

like image 253
epaminonda nicu Avatar asked Oct 20 '25 14:10

epaminonda nicu


2 Answers

CUDA does support classes, however not all C++ features are available. CUDA C++ support has significantly evolved over the time. Here is a non-exhaustive list of supported features:

  • C++ standards supported
    • CUDA 11 introduced C++17 support (see release notes)
    • CUDA 12 now supports C++20 (see release notes)
  • Standard library support
    • libcu++ has many standard library functions available (non-exhaustive list here)
    • NVCC option --expt-relaxed-constexpr allows to use any constexpr host code in device code (powerful tool to reuse existing C++ code)
  • Alternative compilers
    • NVIDIA offers nvc++, a compiler that allows to write parallel C++ code using C++17 execution policies (more information on this page)
like image 189
Anis Ladram Avatar answered Oct 22 '25 05:10

Anis Ladram


nvcc since version 3.0 uses g++ (in Linux) for compiling host code, so you can use the whole set of C++ features for the host part.

For the device code it supports restricted set of C++. But I think in the future releases of CUDA it will be more complete.

like image 31
mikithskegg Avatar answered Oct 22 '25 04:10

mikithskegg