c++ class and GPU how to include class in GPU ?

Hi everybody,

Currently, I have a code that use C++ class.

I create one class : MyClass, which quite complex (contains template class, new type I defined and boost vector and matrix)

To allow multithreading I create a (boost) vector of objet of MyClass.

For instance to run 4 threads and a vector of 4 MyClass object, and run each thread on one object.

I would like to do the same with a GPU. Is it possible to define one object by CUDA cores ?

and how to compile the program with boost ? (I have Ubuntu 8.04)

Thank you

Classes work with CUDA - you just have to define the methods with the “device” keyword. However, you’ll have to write the entire contents of the class from scratch - libraries such as boost aren’t going to work (in device code - the host code can still use Boost just fine). You may also need to rethink your parallelism. From your description, it’s impossible to be sure, but your current implementation is probably far too coarse to work on the GPU. GPU threads are much lighter weight than CPU threads - on a CPU, it would be insane to launch a thread to add a pair of numbers together; on a GPU, that’s The Way It’s Done.

I would like to know if there is a significant overhead using classes rather than structs.

Well, in C++, the only difference between a class and a struct is whether the contents are default-private or default-public…