how to convert host address to device address

Hi, all.

I am wondering about how to convert host address to device address in CUDA.
This kind of question is asked several times but I didn’t get the answer.
I just get the main issue (i.e., different address between host and device).

I use structure to array. There is a pointer in the structure.
It means the program uses address.
So I think when I copy from host to device, it incurs copying not right memory address.

Is there any copying method to convert from host address to device address?
Thank you for helping, and hoping that you guy are be happy!

For an ordinary host address, you can’t just “convert” it to a device address. You must create a device allocation, and use the address returned by the device allocator.

If you are copying a structure with an embedded pointer that currently points to a host address, you will need to use a deep-copy mechanism to replace that host pointer with a device pointer, obtained from a device allocator, such as cudaMalloc.

Thank you for kind your answer.

Well, deep-copy mechanism is such as cudaMalloc.
So if I use cudaMalloc, that structure pointer automatically convert from host address to device address, right?