Hey all,
In my host code I have an array of structs that themselves contain an array of another type of struct. The last thing that I tried was:
[codebox]
List* list_D;
List* list_H;
int numItems = fillList(list_H);
cutilSafeCall(cudaMalloc((void**) &list_D, sizeof(List)*numItems));
cutilSafeCall(cudaMemcpy(list_D, list_H, sizeof(List)*numItems, cudaMemcpyHostToDevice));
for(int i = 0; i < numItems; i++)
{
cutilSafeCall(cudaMalloc((void**) &list_D[i].pList, sizeof(Point)*list_H[i].numPoints));
cutilSafeCall(cudaMemcpy(list_D[i].pList, list_H[i].pList, sizeof(Point)*list_H[i].numPoints, cudaMemcpyHostToDevice));
}
[/codebox]
This code works in emulation mode but does not work on the device (I can’t wait for Nexus). I have also tried to copy the whole array in one call by changing the allocation and memcpy sizes but in my mind that shouldn’t work (which it didn’t) because the memory region won’t be contiguous. What is the best way of transfering nested arrays to device memory?
-Travis