i have this struct:
struct Node
{
int *ptr;
int k;
}*d_ptr;
how can i declare an array of Node and pass it to the GPU? the problem is that i have to allocate memory for ptr first and then Node!
i have this till now:
int N=100;
int NumbOfNodes=5;
cudaMalloc((void **) &d_NodeArr, sizeof(Node)*NumbOfNodes);
for(int i=0;i<NumbOfNodes;i++)
cudaMalloc((void **) d_NodeArr[i].Degree, sizeof(int)*N);
would it be faster if i allocated everything within a single array like this:
int N=100;
int NumbOfNodes=5;
int SIZE=(100*5)+5;//the +5 is for the k
cudaMalloc((void **) &d_ptr,sizeof(int)*SIZE);