# Passing a wrapped array to a kernel

**URL:** <https://discourse.julialang.org/t/passing-a-wrapped-array-to-a-kernel/40254>\
**Category:** GPU\
**Created:** [May 27, 2020, 1:37pm UTC](https://discourse.julialang.org/t/passing-a-wrapped-array-to-a-kernel/40254 "2020-05-27T13:37:57Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![emiwar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/emiwar/32/215517_2.png) [@emiwar](https://discourse.julialang.org/u/emiwar)\
**Post date:** [May 27, 2020, 1:37pm UTC](https://discourse.julialang.org/t/passing-a-wrapped-array-to-a-kernel/40254/1 "2020-05-27T13:37:58Z")

</div>

Hi,

I’m trying to pass an object with a wrapped CuArray to a kernel:

```julia
import CUDA
struct MyStruct
    arrayField::CUDA.CuArray{Float32, 1, Nothing}
end

function f!(obj::MyStruct)
    id = CUDA.threadIdx().x
    if id <= length(a)
        obj.arrayField[id] = id
    end
    nothing
end

myObj = MyStruct(CUDA.fill(0.0, 5))
CUDA.@cuda threads = length(myObj) f!(myObj)

```

This fails with error message

```julia
GPU compilation of kernel f!(MyStruct) failed
KernelError: recursion is currently not supported

```

Is this a bug or am I doing something wrong?

Thanks

---

_[View the full topic](https://discourse.julialang.org/t/passing-a-wrapped-array-to-a-kernel/40254)._
