# CUDA.jl - When to synchronize

**URL:** <https://discourse.julialang.org/t/cuda-jl-when-to-synchronize/115576>\
**Category:** General Usage\
**Tags:** cuda\
**Created:** [June 12, 2024, 9:20pm UTC](https://discourse.julialang.org/t/cuda-jl-when-to-synchronize/115576 "2024-06-12T21:20:30Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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 4, 2024, 4:27pm UTC](https://discourse.julialang.org/t/cuda-jl-when-to-synchronize/115576/6 "2024-11-04T16:27:28Z")

</div>

> [@ww1g11](#):
>
> `copyto!(y_cpu, y)`

Copying to CPU memory automatically synchronizes.

> [@ww1g11](#):
>
> ```julia
> kernel1!(backend)(x; ndrange=length(x))
>     
> KernelAbstractions.synchronize(backend) # sync1 
> 
> kernel2!(backend)(y, x; ndrange=length(x))
> 
> ```

Kernel execution is ordered on the task-local stream, so there’s no need to synchronize in between.

---

_[View the full topic](https://discourse.julialang.org/t/cuda-jl-when-to-synchronize/115576)._
