When using cudaMalloc, how to specify an address of a variable?

232 views Asked by At

I'm trying to do the checkpoint/restart(CR) of CUDA applications using DMTCP.

When restoring, the memory address of a device memory region reallocated after checkpointing must be the same as that before checkpointing.

int Nbytes = 40;
void **A_d;

int address = 0;

*A_d = (void*)0x7ffe69da6f80;

CHECK(cudaMalloc(A_d, Nbytes));
printf("address is: %p\n", *A_d);
CHECK(cudaFree(*A_d));


return 0;

I have tried for several times, the pointer address are totally different.

Does anyone have any idea for this?

1

There are 1 answers

4
Robert Crovella On

You cannot specify the address, nor do you have any control over the address returned by any CUDA allocator:

cudaMalloc, cudaMallocHost, cudaHostAlloc, cudaMallocManaged, etc.