Hello all,
I am trying to write a toy-code in CUDA. Part of this code allocates a struct (lets call it ftest) in GPU and does some multidimensional array allocation.
This code works fine in emulation mode, but when i try to run it on the GPU i get an allocation error from cudaMalloc.
[codebox]struct ftest
{
float** ff;
};
…
ftest *f;
ierr=cudaMalloc( (void**)&f,sizeof(ftest));
if (ierr!=cudaSuccess) Stop("Error 1");
ierr=cudaMalloc( (void**)&(f->ff),5*sizeof(float*));
if (ierr!=cudaSuccess) Stop("Error 2");[/codebox]
The error appears on the second malloc statement.
I think the reason is because f->ff already resides on device, whereas cudaMalloc requires a variable residing on host?
So if that is true, how can i bypass it?
If I allocate locally (ie. malloc on tempff** on host)and then memcpy (tempff to f->ff) will the pointers be valid?
Thanks in advance,
Giannis