Hey guys. I can’t get any GPU specific variables into structs or classes. I get the following error if I try:
struct cuda_var_t
{
device float *buffer_dev;
}
leads to the following error:
error: memory qualifier on data member is not allowed
With a bare bones program and no other code, I still get the same error. How can I throw these variables into structs/classes?
Hey guys. I can’t get any GPU specific variables into structs or classes. I get the following error if I try:
struct cuda_var_t
{
device float *buffer_dev;
}
leads to the following error:
error: memory qualifier on data member is not allowed
With a bare bones program and no other code, I still get the same error. How can I throw these variables into structs/classes?
You simply can’t. What is the structure supposed to contain? Where is it supposed to reside? On host or GPU? May be you want something like this:
struct cuda_var_t
{
float *buffer;
int *bla;
...
int thing;
}
__device__ struct cuda_var_t yourStructVariable_on_device;
int main(...)
{
...
}
Well, I want the structure to reside on the CPU, but the variables to reside on the GPU… does that make sense?
Basically, I need multiple instances of those variables… and so I NEED a class or struct to house them in - globals only have one instance! I’m very confused about this right now…
That’s nonsense ;-)
You can’t put a box (structure) into the green cupboard and expect the contents of the box to be in the yellow cupboard :wacko:
I think you want
struct cuda_struct_t
{
float *buffer; /* buffer points to device memory */
}
Then buffer itself resides in host memory. But you may allocate memory on the device and store its adress in buffer.
struct cuda_struct_t myStructVar;
cudaMalloc((void**)&(myStructVar.buffer), N*sizeof(float));