Can not let __global__ function be class member function?

I have a bunch of CUDA kernel functions, Can I put them all in one class as class member functions?

I tried a little bit, The error message is: illegal combination of memory qualifiers.

Is there a way that I can make my kernel functions object oriented?

Thank you in advance.

I’m afraid the answer is “no”.

__ global__ is used for CUDA functions that are invoked by the host and are executed on the device.

Suppose now you create a class with a global member function. Then, if you instantiate the class object on the device, the device will not be able to call the global function since it is only callable from the host. On the other side, the CUDA C Programming Guide says that “Static member functions cannot be global functions”, see

My suggestion is to create a class with objects instantiated on the host and with member functions containing invokations of the kernel functions inside.

If there is actually no shared state, then you might as well just put the global functions into a C++ namespace. (Note: I haven’t tried this yet.)