Memory Copy
Allows copying from source memory address to destination memory address.
Also be aware of memmove.
Resources
Usage
What happens under the hood when you call
memcpy
?Both hardware and software are involved.
- Software: The
memcpy
function requests the OS to allocate memory for the operation.- Hardware: Once the memory is allocated, the actual data transfer is handled by the CPU. The MMU in the CPU ensures that the data is physically moved from one memory location to another.
Note that modern CPUs can optimize such operations through techniques like Prefetching and efficient Caching.
Cuda
Use cudaMemcpy
.