简体   繁体   English

是否可以将CUDA C用于面向对象的编程?

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

Is it possible to use CUDA C for object oriented programming? 是否可以将CUDA C用于面向对象的编程? Are there any classes in CUDA C like in C++? 像C ++中一样,CUDA C中是否有任何类?

CUDA compiler supports classes, inheritance, constructors, destructors, for all devices, although for some this support is not official. CUDA编译器支持所有设备的类,继承,构造函数,析构函数,尽管对于某些设备而言,这种支持不是官方的。

Not all devices support (not inlined) function calls, recursion, virtual function calls, and even if if they do, that is a rather slow operation and I would strongly suggest you to avoid this unless it is rare in your code. 并非所有设备都支持(不内联)函数调用,递归,虚拟函数调用,即使它们支持,这也是一个相当慢的操作,我强烈建议您避免这种情况,除非在您的代码中很少使用。

If I am not mistaken, there is no support for exceptions. 如果我没记错的话,不支持例外。

Similar, but a bit more broad question: What are the real C++ language constructs supported by CUDA device code? 相似但更广泛的问题: CUDA设备代码支持哪些真正的C ++语言构造?

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. nvcc从3.0版开始就使用g ++(在Linux中)编译主机代码,因此您可以在主机部分使用整套C ++功能。

For the device code it supports restricted set of C++. 对于设备代码,它支持受限的C ++集。 But I think in the future releases of CUDA it will be more complete. 但是我认为在CUDA的未来版本中,它将更加完善。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM