# Broadcast question

**URL:** <https://discourse.julialang.org/t/broadcast-question/87210>\
**Category:** GPU\
**Created:** [September 13, 2022, 12:06pm UTC](https://discourse.julialang.org/t/broadcast-question/87210 "2022-09-13T12:06:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [September 13, 2022, 12:06pm UTC](https://discourse.julialang.org/t/broadcast-question/87210/1 "2022-09-13T12:06:39Z")

</div>

I got this off CUDA.jl…/test/texture.jl (altered a bit)

```julia
Tex = @pipe rand(Float32,10) |> CuTextureArray |> CuTexture(_, interpolation=CUDA.LinearInterpolation())
Idx = rand(Float32,10) .+1 |> CuArray
out = CuArray{Float32}(undef, 10)

broadcast!(out, Idx, Ref(Tex)) do idx, tex
    tex[idx...]
end

```

Is it possible to simplify the `broadcast` block ?  
In non-gpu Julia I’d just write `Tex.(Ind)`

Or does the kernel construction require everything to be passed through the broadcast. ?  
I notice even the below small simplifications give errors.

```julia
broadcast( Idx, Ref(Tex)) do idx, tex #without specifying output variable
    tex[idx...]
end

broadcast!(out, Idx, ) do idx #without passing Texture through broadcast
      Tex[idx...]
end

```

---

<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 14, 2022, 7:52am UTC](https://discourse.julialang.org/t/broadcast-question/87210/2 "2022-09-14T07:52:09Z")

</div>

The broadcast support for texture objects is a bit of a gimmick, better to put it in a kernel: [CUDA.jl 1.1 ⋅ JuliaGPU](https://juliagpu.org/post/2020-07-07-cuda_1.1/#experimental_texture_support)

---

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [September 19, 2022, 3:09am UTC](https://discourse.julialang.org/t/broadcast-question/87210/3 "2022-09-19T03:09:04Z")

</div>

Thanks Tim.  
guess I have to bite the bullet and learn Kernel programming 🙂
