# How to get the kernel computation time?

**URL:** <https://forums.developer.nvidia.com/t/how-to-get-the-kernel-computation-time/4379>\
**Category:** CUDA Programming and Performance\
**Created:** [July 1, 2008, 6:01pm UTC](https://forums.developer.nvidia.com/t/how-to-get-the-kernel-computation-time/4379 "2008-07-01T18:01:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![enjoygpu](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@enjoygpu](https://forums.developer.nvidia.com/u/enjoygpu)\
**Post date:** [July 1, 2008, 6:01pm UTC](https://forums.developer.nvidia.com/t/how-to-get-the-kernel-computation-time/4379/1 "2008-07-01T18:01:07Z")

</div>

Hi,  
I want to get the kernel computation time.  
unsigned int timer1;  
cutCreateTimer(&timer1);  
cutStartTimer(timer1);  
Muld\<\<\<dimGrid, dimBlock\>\>\>(Ad, Bd, wA, wB, Cd);  
cudaMemcpy(C, Cd, size, cudaMemcpyDeviceToHost);  
cutStopTimer(timer1);

Since the kernel call is asynchronous I have to put cutStopTimer behind cudaMemcpy.  
Is there another way to get the kernel time?

Best,  
Yixun

---

<div class="post-metadata">

**Author:** ![MisterAnderson42](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@MisterAnderson42](https://forums.developer.nvidia.com/u/MisterAnderson42)\
**Post date:** [July 1, 2008, 6:16pm UTC](https://forums.developer.nvidia.com/t/how-to-get-the-kernel-computation-time/4379/2 "2008-07-01T18:16:44Z")

</div>

Call cudaThreadSynchronize() before any timer measurement.

---

<div class="post-metadata">

**Author:** ![paulius](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@paulius](https://forums.developer.nvidia.com/u/paulius)\
**Post date:** [July 1, 2008, 6:35pm UTC](https://forums.developer.nvidia.com/t/how-to-get-the-kernel-computation-time/4379/3 "2008-07-01T18:35:19Z")

</div>

Better yet, use CUDA events for timing. See, for example, simpleStreams sample in the SDK. Events won’t include driver overhead, since they are recorded on the GPU. Resolution is the period of a GPU clock tick, so works much better for short kernels.

Paulius
