Search code examples
cudacpu-architectureflushpersistent-memoryclflush

Do I need to externally call flush if using cuda api to copy from GPU Memory to Persistent Memory?


I am using Cuda API: cudaMemcpyAsync ( void* dst, const void* src, size_t count, cudaMemcpyKind kind, cudaStream_t stream = 0 )

to copy data from GPU memory from CPU memory. In case copying the data from CPU memory to Persistent Memory using memcpy(), we need to explicitly call the flush operation(eg. clflush()) to make sure data is flushed from CPU caches. Do I need to call the flush operation when copying from GPU Memory to Persistent Memory using cudaMemcpyAsync();


Solution

  • Do I need to call the flush operation when copying from GPU Memory to Persistent Memory using cudaMemcpyAsync();

    No.

    However, you are calling a potentially asynchronous API, so you may need to use one of the synchronization APIs (stream or device scope) in order to ensure data consistency between operations that can potentially overlap and need to access the same memory area.