cudamemcpy and pointers to structs of pointers

I have a struct which I have malloc’ed (and cudamalloc’ed) that looks something like this:

typedef struct

{

  double *data_pointer

} struct_pointer

I tried this to transfer data:

cudaMemcpy(struct_pointer_device->data_pointer, struct_pointer_host->data_pointer, sizeof(double)*domain_size,cudaMemcpyHostToDevice);

But it fails with an unhandled exception, but no cuda errors. The following code however works as expected:

cudaMemcpy(data_pointer_device, data_pointer_host, sizeof(double)*domain_size,cudaMemcpyHostToDevice);

Could anyone explain to me why the first example compiles but does not work?

Hi,
Just a guess here:
struct_pointer_device is a pointer to memory living on the device, right? So using struct_pointer_device->data_pointer implies de-referencing it, to obtain the data stored inside one instance of struct_pointer. But since it lives on the device, you cannot de-reference the pointer from the host, right?
And where do you think cudaMemcpy’s arguments are evaluated?
Here again, it’s just a guess…

This is sort of what I thought was going on, but I also assumed there must be a way around this…

Edit: and I’ve just realized the exact same thing happens with double pointers.