transferring array of structures to device memory

Goodafternoon every one

I have the following structure.
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;
};

I declare the structure in the host memory as

struct rngen ** new;

This array of structures i need to transfer to the device memory.

Questions are 1) how to allocate memory in the device memory
2) how to copy data from new to devnew(memory allocated in device)

can some body can help me with sample code of allocating and copying the structures into the device memory

Advance thanks

for your first question

rngen *devnew = NULL;

cudaMalloc((void**)&devnew, sizeof(rngen) * numOfElements);

for your second question

you can not copy data from a pointer of pointer (in host memory) to device memory, but you can copy a 2D array (static allocated in host memory) to device memory with normal method.

assume that you have 2D array on host

rngen new[y];

and you want copy data to device memory

cudaMemcpy(devnew, new, sizeof(rngen) * numOfElements, cudaMemcpyHostToDevice);

but if you use pointer of pointer in host memory

rgnen **new;

new = (rgnen**)malloc(sizeof(rgnen*) * y);

for (int i = 0; i < x; i++)

new[i] = (rgnen)malloc(sizeof(rgnen) * x);

and you try to copy data from host memory to device memory, the only first row of new[0] is correctly, another rows are not correctly, because when allocated with dynamic method, all the elements are not contiguous.