# How to use \`copy!\`(or other array operations) inside a CUDA kernel?

**URL:** <https://discourse.julialang.org/t/how-to-use-copy-or-other-array-operations-inside-a-cuda-kernel/55762>\
**Category:** GPU\
**Tags:** cuda\
**Created:** [February 22, 2021, 7:02am UTC](https://discourse.julialang.org/t/how-to-use-copy-or-other-array-operations-inside-a-cuda-kernel/55762 "2021-02-22T07:02:01Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![marius311](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marius311/32/3953_2.png) [@marius311](https://discourse.julialang.org/u/marius311)\
**Post date:** [February 22, 2021, 9:54pm UTC](https://discourse.julialang.org/t/how-to-use-copy-or-other-array-operations-inside-a-cuda-kernel/55762/4 "2021-02-22T21:54:38Z")

</div>

Note that there is some level of broadcasting that works in kernels if you use StaticArrays, e.g.

```julia-auto
Y = CUDA.rand(10,2)
 
function kernel(Y)
    X = @SVector zeros(10)
    Y[:,1] .= X .+ 1
    nothing
end

@cuda kernel(Y)

```

although I couldn’t get exactly your example working. Based on:

> [@Recent developments in StaticArrays.jl land](https://discourse.julialang.org/t/recent-developments-in-staticarrays-jl-land/47778/1):
>
> You can make anything sized, I’ve even managed to make a GPU kernel in CUDA.jl broadcast with `SizedArray` views of parts of `CuArray` s.

maybe its possible? Perhaps @mateuszbaran can comment further, I’m curious myself too.

---

_[View the full topic](https://discourse.julialang.org/t/how-to-use-copy-or-other-array-operations-inside-a-cuda-kernel/55762)._
