# How to time CUDA Event

**URL:** <https://discourse.julialang.org/t/how-to-time-cuda-event/17530>\
**Category:** GPU\
**Created:** [November 14, 2018, 9:11pm UTC](https://discourse.julialang.org/t/how-to-time-cuda-event/17530 "2018-11-14T21:11:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cuchxq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cuchxq/32/3830_2.png) [@cuchxq](https://discourse.julialang.org/u/cuchxq)\
**Post date:** [November 14, 2018, 9:11pm UTC](https://discourse.julialang.org/t/how-to-time-cuda-event/17530/1 "2018-11-14T21:11:54Z")

</div>

Hi,

In CUDA C, you can time how long GPU ran by using event, this will record the time for just GPU running time, which does not include data transfer. Is there a similar functionality in CuArray or other GPU packages?

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [November 15, 2018, 6:47am UTC](https://discourse.julialang.org/t/how-to-time-cuda-event/17530/2 "2018-11-15T06:47:50Z")

</div>

CUDAdrv wraps the event API. You can use `CUDAdrv.@elapsed` to automatically enqueue events before and after code and return the elapsed time between both. Or manually construct `CuEvent`s and call `record`/`synchronize`/`elapsed` on them.

---

<div class="post-metadata">

**Author:** ![cuchxq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cuchxq/32/3830_2.png) [@cuchxq](https://discourse.julialang.org/u/cuchxq)\
**Post date:** [November 15, 2018, 7:08pm UTC](https://discourse.julialang.org/t/how-to-time-cuda-event/17530/3 "2018-11-15T19:08:48Z")

</div>

Thank you! Is there any difference in reporting between the two methods?

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [November 15, 2018, 9:34pm UTC](https://discourse.julialang.org/t/how-to-time-cuda-event/17530/4 "2018-11-15T21:34:47Z")

</div>

No, one is built on top of the other: [CUDAdrv.jl/events.jl at 2a77dff0eaad0df12abd8cf05e73b3f9d5968ad5 · JuliaGPU/CUDAdrv.jl · GitHub](https://github.com/JuliaGPU/CUDAdrv.jl/blob/2a77dff0eaad0df12abd8cf05e73b3f9d5968ad5/src/events.jl#L73-L87)
