Pointers and Structs

I was wondering if there’s any recommendations on how to deal with structs that contain pointers. My situation is the following: I have an fairly large array (A) for a struct, within the struct I have a pointer to another array (B). Now multiple structs share the same pointer to a location within the other array.
What I currently do is that I copy B to the device and then adjust pointers for each and every struct to point to device memory and afterwards copy A to the device.
Now my questions is whether this really is the best approach to this? I don’t feel that this is a really good approach.
I also thought about just having all structs share a base pointer and then just give them an offset to point to the correct location in array B. However I wonder if there might be any problem between 32-bit and 64-bit addresses (currently using a 64-bit Linux)?

Any thoughts on this from the experts on this forum? :)

Regards,
Linny

PS: I’ve been searching through the forums but I haven’t really found a satisfying answer.

Not 100% sure what you mean by problems between 32-bit and 64-bit addresses. CUDA guarantees that pointer size on the device equals the pointer size on the host, whether the host is running a 32-bit or 64-bit operating system. That guarantee makes me think that this wouldn’t be a problem, but maybe I’m missing something.

So it that case the recommended approach would be to use a base address with an offset because the memory layout on the device will be identical to the host?

Yes. Someone can correct me if I’m wrong because I haven’t explored this super-thoroughly, but my understanding is that sizeof(struct) from a kernel = sizeof(struct) from the host that is running the kernel.

Yes the sizes for a struct are the same on host and device as far as I can tell, my problem was updating all the pointers within the structs enclosed in the first array. I will try the base address + offset tomorrow, 11 pm is no good time to be working ;)