Programming with CUDA I am facing a problem trying to copy some data from host to gpu.
I have 3 nested struct 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 includes some Cell elements.
Let's suppose I dynamically allocate the host memory in 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 Matrix of 100 Cells each.
- How could I now copy this data to the device memory using cudaMemCpy()?
- Is there any good way to perform a deep copy of "struct of struct" from host to device?
Thanks for your time.
Andrea
 
    