Programming with CUDA I had a problem trying to copy some data from the host to gpu.
I have 3 nested structures like these:
typedef struct { char data[128]; short length; } Cell; typedef struct { Cell* elements; int height; int width; } Matrix; typedef struct { Matrix* tables; int count; } Container;
So Container "includes some Matrix elements, which, in turn, contain some Cell elements.
Suppose I dynamically allocate host memory this way:
Container c; c.tables = malloc(20 * sizeof(Matrix)); for(int i = 0;i<20;i++){ Matrix m; m.elements = malloc(100 * sizeof(Cell)); c.tables[i] = m; }
That is, a container of 20 matrices with 100 cells each.
- How can I now copy this data to the device memory using cudaMemCpy ()?
- Is there a good way to do a deep copy of "struct of struct" from host to device?
Thank you for your time.
Andrea
Andrea
source share