a question about cudaMallocManaged()

I have a puzzle about whether need to allocate memory on GPU when using cudaMallocManaged().Please answer,thank you!

If you study this introduction:


you should be able to answer the question for yourself.

sorry, just like as follow:
cudaHostAlloc((void **)&h_A, nBytes, cudaHostAllocMapped);
cudaHostGetDevicePointer((void **)&d_A, (void *)h_A, 0);

is this just need to allocate memory on cpu not on device?

cudaHostAlloc returns a pointer to host memory, but that pointer can also be used in device code. Device code can access it using a “zero-copy” mechanism. Furthermore, host data allocated this way can be used with cudaMemcpyAsync for overlap of copy and compute operations.

This has nothing to do with cudaMallocManaged

thank you ,i see