i have two dimensional structure in the host memory and i need to transfer it to the device memory by allocating memory in the device and then copying from host to device.
Can some one help me with a sample code of using cudamallocpitch .
my structure looks like this
struct rngen
{
int seed[2];
int seed[2];
int init_seed;
int prime;
int prime_position;
int prime_next;
char *gentype;
int parameter;
int *multiplier;
};
now i have declared struct rngen **new and allocated for new.This new i need to transfer to the device memory first by allocating and then copying it into the device memory.
As avidday mentioned, you cannot do that. You HAVE to do a ‘deep-copy’ on that structure, in order to transfer all the contents from CPU to GPU (and vice-versa).
Here’s an example on what I meant by deep-copy: (untested)
You copy both the elements of the struct, as well as malloc and cudaMemcpy all the pointers inside it.