Reputation: 1415
I have a base class:
template <class T>
class A{
public:
// some data
T data;
//some functions like constructs etc.
...
// one virtual function
virtual void evaluate() = 0;
}
and a derived class:
template <class T>
class B:public A<T>{
public:
// some functions like constructors etc.
virtual void evaluate();
__global__ void function2(); // **** error message
}
Also, I have
template <class T> void
B<T>::evaluate()
{
dim3 grid(1);dim3 block(1);
void function2<<<grid,block>>>();
}
and
template <class T> __global__ void B<T>::function2() // **** error message
{
// computation here
}
so essentially I have a member function of a derived class which I would like to execute in a parallel fashion on the device.
Unfortunately, I get the error:
error : illegal combination of memory qualifiers on the lines :
1> __global__ void function2(); // **** error message
2> template <class T> __global__ void B<T>::function2() // **** error message
I am new to CUDA. It would be very kind if someone points me to my error. I am developing on Visual Studio 2010.
Upvotes: 3
Views: 3313
Reputation: 72352
The template class definition in your first code snippet is illegal because it contains a __global__ function (CUDA kernel). As per the language documentation, __global__ functions cannot be static class member functions. The second templated class member function is illegal for the same reason.
Upvotes: 3