# CUDA Array broadcasting: possible to use a different stream for a code block?

**URL:** https://discourse.julialang.org/t/cuda-array-broadcasting-possible-to-use-a-different-stream-for-a-code-block/46845
**Category:** GPU
**Created:** [September 18, 2020, 1:36pm UTC](https://discourse.julialang.org/t/cuda-array-broadcasting-possible-to-use-a-different-stream-for-a-code-block/46845 "2020-09-18T13:36:28Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![samo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samo/32/35398_2.png) [@samo](https://discourse.julialang.org/u/samo)
#### Post date: [September 18, 2020, 1:36pm UTC](https://discourse.julialang.org/t/cuda-array-broadcasting-possible-to-use-a-different-stream-for-a-code-block/46845/1 "2020-09-18T13:36:28Z")

</div>

I am wondering if it is possible somehow to specify the stream for a code block with array computations that rely on CuArray’s broadcasting capability as e.g. `A .= A .+ B` in this snippet:

```julia
using CUDA
A = CUDA.zeros(2,3)
B = CUDA.ones(2,3)
A .= A .+ B

```

Thanks!!

---

<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: [September 21, 2020, 6:35am UTC](https://discourse.julialang.org/t/cuda-array-broadcasting-possible-to-use-a-different-stream-for-a-code-block/46845/2 "2020-09-21T06:35:46Z")

</div>

There currently isn’t. We need to set-up some global but task-local state to set/get the stream, and make all functions (like `broadcast` use that). For now though, we’ve switched to using the implicit per-thread stream, so if you perform those computations on a separate thread you should get the same effect.

---

<div class="post-metadata">

### Author: ![samo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samo/32/35398_2.png) [@samo](https://discourse.julialang.org/u/samo)
#### Post date: [September 21, 2020, 8:31am UTC](https://discourse.julialang.org/t/cuda-array-broadcasting-possible-to-use-a-different-stream-for-a-code-block/46845/3 "2020-09-21T08:31:28Z")

</div>

Thanks @maleadt for the reply. However, we would like to run these computations on a **high priority stream** , whereas implicit per-thread streams are normal priority, I assume.
