8888q8888
8888q8888

Reputation: 55

CUDA and C++ for host and device code

I started to integrate CUDA into my C++ applications weeks ago. I've been doing my own research about integrating CUDA and C++. However, I still feel uncomfortable about this topic.

Can somebody help me to clarify some questions based on the latest Toolkit 3.2 or 4.0 RC?

  1. It says Fermi fully support C++ in Fermi's white paper. Does that mean it support C++ in both host and device code or just host code?

  2. What kind of C++ features I can use in kernel code? I know templates are supported. What about classes or structs?

  3. Can I pass a user-defined class instance (which holds some pointers to device memory) into a kernel, and call its member function in the kernel code? Do classes and structs make any differences?

Any helps are appreciated! Thanks!

Upvotes: 4

Views: 3535

Answers (1)

karlphillip
karlphillip

Reputation: 93410

  1. Your host already supports C++, doesn't it? But now the GeForce 400 Series (codename Fermi) supports C++ code on the device.

  2. Classes too, with some restrictions. See appendix D of the programming guide for details.

  3. You can pass a reference of the class. Check section D.6.2 of the programming guide.

In general, appendix D shows the supported C++ constructs and pieces of code. It's worth reading it.

Upvotes: 6

Related Questions