Explanation of CUDA C and C++

前端 未结 5 1062
时光说笑
时光说笑 2021-01-30 14:38

Can anyone give me a good explanation as to the nature of CUDA C and C++? As I understand it, CUDA is supposed to be C with NVIDIA\'s GPU libraries. As of right now CUDA C suppo

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-30 14:57

    CUDA is a platform (architecture, programming model, assembly virtual machine, compilation tools, etc.), not just a single programming language. CUDA C is just one of a number of language systems built on this platform (CUDA C, C++, CUDA Fortran, PyCUDA, are others.)

    CUDA C++

    Currently CUDA C++ supports the subset of C++ described in Appendix D ("C/C++ Language Support") of the CUDA C Programming Guide.

    To name a few:

    • Classes
    • __device__ member functions (including constructors and destructors)
    • Inheritance / derived classes
    • virtual functions
    • class and function templates
    • operators and overloading
    • functor classes

    Edit: As of CUDA 7.0, CUDA C++ includes support for most language features of the C++11 standard in __device__ code (code that runs on the GPU), including auto, lambda expressions, range-based for loops, initializer lists, static assert, and more.

    Examples and specific limitations are also detailed in the same appendix linked above. As a very mature example of C++ usage with CUDA, I recommend checking out Thrust.

    Future Plans

    (Disclosure: I work for NVIDIA.)

    I can't be explicit about future releases and timing, but I can illustrate the trend that almost every release of CUDA has added additional language features to get CUDA C++ support to its current (In my opinion very useful) state. We plan to continue this trend in improving support for C++, but naturally we prioritize features that are useful and performant on a massively parallel computational architecture (GPU).

提交回复
热议问题