I have a CUDA kernel that process a lot of data. As I cannot transfer all the data at once I have to split them into chunks and process them chuck by chunk and update the output on the GPU. I am parsing the input data from a file. I was thinking if i could overlap the chunks' memory transfers by having two buffers both in the host and in the GPU. While processing one chuck, I could read the other, transfer it to the GPU and launch the kernel to the same stream. My problem is that the kernel's execution time is slower than parsing the data and transferring them to the GPU. How can I ensure that the memcpys won't write over the data that the kernel uses given the fact that memcpys are no blocking?
//e.g. Pseudocode
//for every chunk
//parse data
//cudaMemcpyAsync ( dev, host, size, H2D )
//launch kernel
//switch_buffer
//copy result from device to host
Thank you in advance.
cudaMemcpyAsync, too. - hubs