I am currently using CUDA for supplementing my CPU in calculation of several numerical integrations. For this purpose, I have only a small amount of data, which has to be transferred between the host and the device, i.e. 7 floats from h2d and the results (~30 integral values) from d2h.
During benchmark of my program I realized the time for copying the data seems to be quite relevant. To check this timing (latency + copy time) I wrote a small program - it just copies 336 bytes from d2h (non async). So these are my results:
After some reading I noticed time mentioned for latency in small data copies should be around 10us. Does anybody have any suggestion why the latencies are that large in my case? I already tried different memory copy options (with and without âunifiedâ memory, page lock and non page locked, other GPU (GTX650)) but timings do not vary much. I guess it is some kind of Windows driver problem, but am not sure about that.
Following is my setup:
Windows 7 64 Bit
CUDA 6
GTX 750Ti @PCIe 16x
Intel i7 2600K
Gigabyte Z68AP-D3
cudaMemcpy2D is going to be slower than an ordinary cudaMemcpy in many cases, for the same amount of data transferred. cudaMemcpy2D is scheduling multiple (NO_OF_VARIABLES) DMA operations under the hood, whereas an ordinary cudaMemcpy with the same amount of data to be transferred can schedule the entire operation with a single DMA transfer, because the data is contiguous. The magic performed by cudaMemcpy2D is not free, in terms of timing. If itâs only a few values, and itâs convenient to do so, you will probably see better results if you can group those values contiguously to facilitate an ordinary cudaMemcpy to the host.
And yes, windows may be interfering, due to batching of WDDM commands. If you search elsewhere on this board, youâll find comments from Greg@NV about this effect and possible workarounds for WDDM devices. If you use the latest nsight VSE, you can get an idea of the WDDM command queue at any point in time.
Thanks for the fast response! Honestly, I feel a littlebit like a newbee not recognizing the WDDM facts :( Anyway, I replaced the cudaMemcpy2D by cudaMemcpy not really resulting in a better performance. I guess WDDM (in combination with queuing) is responsible for large delays. Is there any chance to get rid of these problems (w/o explicit triggering of events) except buying a Quadro or Tesla card?
As an alternative, one could surely use Linux - does anyone have checked the latencies of memory copies for this OS?
Have many thanks! I will try to port my programm to linux in the next days - after some further investigations I saw the batch queue was filled in my original program and such I will suffer from delays in ~100us to 1ms, which is not acceptable for my application. I will post results as soon as I collected them!
Of course, that is right - but unfortunately this does not really solve my problem. Transferring the floats as parameters seems to be a suitable idea at the moment, but I do not know how many parameters this will be in the future⊠Anyway, thanks for the cudaStreamQuery hint, I read something about cudaStreamQuery before and wondered why this did not work.
in the meantime I installed Linux and ported my project, resulting in dramatically reduced latencies. I now have app. 10”s per memory/kernel access, which seems acceptable to me. Drivers and IDE are working without problems, I was astonished how easy the porting process was!