Friday, 2 June 2017

What is the use of cudaMemcpy() function and what arguments does it accept?

                     Function cudaMemcpy() is provided by header file cuda.h. It is used to transfer some contents from one memory location to another memory location.

Syntax: cudaMemcpy(Destination Pointer Variable, Source Pointer Variable, size of memory, cudaMemcpyHostToDevice / cudaMemcpyDeviceToHost)

e.g. cudaMemcpy(d,a,sizeof(int),cudaMemcpyHostToDevice);

1. cudaMemcpyHostToDevice is used to transfer values from Host (CPU) to Device (GPU).
2. cudaMemcpyDeviceToHost is used to transfer values from Device (GPU) to Host (CPU).

No comments:

Post a comment