# cudaMemcpyDeviceToHost taking much time?

**URL:** <https://forums.developer.nvidia.com/t/cudamemcpydevicetohost-taking-much-time/10805>\
**Category:** CUDA Programming and Performance\
**Created:** [July 11, 2009, 12:43pm UTC](https://forums.developer.nvidia.com/t/cudamemcpydevicetohost-taking-much-time/10805 "2009-07-11T12:43:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CUDAkk](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@CUDAkk](https://forums.developer.nvidia.com/u/CUDAkk)\
**Post date:** [July 11, 2009, 12:43pm UTC](https://forums.developer.nvidia.com/t/cudamemcpydevicetohost-taking-much-time/10805/1 "2009-07-11T12:43:34Z")

</div>

Hi All,

Is any time difference between cudaMemcpyHostToDevice and cudaMemcpyDeviceToHost cudaMemcpy?

---

<div class="post-metadata">

**Author:** ![seibert](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/seibert/32/520688_2.png) [@seibert](https://forums.developer.nvidia.com/u/seibert)\
**Post date:** [July 11, 2009, 2:00pm UTC](https://forums.developer.nvidia.com/t/cudamemcpydevicetohost-taking-much-time/10805/2 "2009-07-11T14:00:50Z")

</div>

There can be a difference between those two copy directions, but it depends on the motherboard. On the systems I have access to, pageable memory copies are 15% slower in the DeviceToHost direction, compared to HostToDevice.

---

<div class="post-metadata">

**Author:** ![CUDAkk](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@CUDAkk](https://forums.developer.nvidia.com/u/CUDAkk)\
**Post date:** [July 12, 2009, 6:34am UTC](https://forums.developer.nvidia.com/t/cudamemcpydevicetohost-taking-much-time/10805/3 "2009-07-12T06:34:59Z")

</div>

But in my case cudaMemcpy( ) function is taking 0.332 ms for a size of 800_600_8 data copying from host to device and same function is taking 21.3ms for a size of 2400_1800_8 data copying from device to host( which should not be accepted in CUDA).

Hardware details: Quadro CX, CUDA2.2 Drivers, Toolkit and SDK.

Is it because of large memory size? or what could be the reason?

I am expecting answer from nvidia member’s side?

---

<div class="post-metadata">

**Author:** ![k9quaint](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@k9quaint](https://forums.developer.nvidia.com/u/k9quaint)\
**Post date:** [July 15, 2009, 9:19pm UTC](https://forums.developer.nvidia.com/t/cudamemcpydevicetohost-taking-much-time/10805/4 "2009-07-15T21:19:00Z")

</div>

> [@](#):
>
> But in my case cudaMemcpy( ) function is taking 0.332 ms for a size of 800_600_8 data copying from host to device and same function is taking 21.3ms for a size of 2400_1800_8 data copying from device to host( which should not be accepted in CUDA).
> 
> **Hardware details** : Quadro CX, CUDA2.2 Drivers, Toolkit and SDK.
> 
> Is it because of large memory size? or what could be the reason?
> 
> **I am expecting answer from nvidia member’s side?**

Make sure you call cudaThreadSynchronize() after you launch your kernel and before you stop the timer for measurement. The kernel launch is asynchronous and will return very quickly, so you are probably only measuring the amount of time to launch the kernel. The memcpy from device to host has an implicit thread sync, so you might be measuring both kernel execution time & memcpy time.
