# Perplexing behavior when computing the matmul smoke test on GPU in Julia

**URL:** https://discourse.julialang.org/t/perplexing-behavior-when-computing-the-matmul-smoke-test-on-gpu-in-julia/106994
**Category:** Performance
**Tags:** question
**Created:** [December 1, 2023, 1:37pm UTC](https://discourse.julialang.org/t/perplexing-behavior-when-computing-the-matmul-smoke-test-on-gpu-in-julia/106994 "2023-12-01T13:37:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Aakhash\_Sundaresan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aakhash_sundaresan/32/202478_2.png) [@Aakhash\_Sundaresan](https://discourse.julialang.org/u/Aakhash_Sundaresan)
#### Post date: [December 1, 2023, 1:37pm UTC](https://discourse.julialang.org/t/perplexing-behavior-when-computing-the-matmul-smoke-test-on-gpu-in-julia/106994/1 "2023-12-01T13:37:08Z")

</div>

![Screenshot 2023-12-02 at 12.33.09 am](https://global.discourse-cdn.com/julialang/original/3X/1/7/1732bb9ecf2aeef0dfaf010381c8f0b46dbd70c0.png)  
@avikpal , @ChrisRackauckas Why is that when I compute the matmul smoke test for the first time and time it, it takes long time than the CPU computation, and also the allocations are huge. When I again try to compute the same operation, this time it is fast? What is the reason behind this? I have attached the scrrenshot of what I’m doing, for you to have a look at it…Please explain it to me?

Thanks in advance

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [December 1, 2023, 1:51pm UTC](https://discourse.julialang.org/t/perplexing-behavior-when-computing-the-matmul-smoke-test-on-gpu-in-julia/106994/2 "2023-12-01T13:51:20Z")

</div>

That’s just JIT compilation?

---

<div class="post-metadata">

### Author: ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)
#### Post date: [December 1, 2023, 2:36pm UTC](https://discourse.julialang.org/t/perplexing-behavior-when-computing-the-matmul-smoke-test-on-gpu-in-julia/106994/3 "2023-12-01T14:36:49Z")

</div>

It’s described at the beginning of the abstract here [Reducing Compilation Latency in the Julia Programming Language](https://dspace.mit.edu/handle/1721.1/151537)

---

<div class="post-metadata">

### Author: ![Aakhash\_Sundaresan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aakhash_sundaresan/32/202478_2.png) [@Aakhash\_Sundaresan](https://discourse.julialang.org/u/Aakhash_Sundaresan)
#### Post date: [December 1, 2023, 2:47pm UTC](https://discourse.julialang.org/t/perplexing-behavior-when-computing-the-matmul-smoke-test-on-gpu-in-julia/106994/4 "2023-12-01T14:47:54Z")

</div>

Thanks for pointing me and helping me out…I have one more question, when I do a GPU based computation, I get this error…  
ERROR: LoadError: GPU compilation of MethodInstance for (::GPUArrays.var"#broadcast\_kernel#26")(::CUDA.CuKernelContext, ::CuDeviceMatrix{Float32, 1}, ::Base.Broadcast.Broadcasted{CUDA.CuArrayStyle{2}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, typeof(-), Tuple{Base.Broadcast.Extruded{Matrix{Float32}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}, Base.Broadcast.Extruded{LinearAlgebra.Adjoint{Float32, CuDeviceVector{Float32, 1}}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}}}, ::Int64) failed  
KernelError: passing and using non-bitstype argument  
Argument 4 to your kernel function is of type Base.Broadcast.Broadcasted{CUDA.CuArrayStyle{2}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, typeof(-), Tuple{Base.Broadcast.Extruded{Matrix{Float32}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}, Base.Broadcast.Extruded{LinearAlgebra.Adjoint{Float32, CuDeviceVector{Float32, 1}}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}}}, which is not isbits:  
.args is of type Tuple{Base.Broadcast.Extruded{Matrix{Float32}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}, Base.Broadcast.Extruded{LinearAlgebra.Adjoint{Float32, CuDeviceVector{Float32, 1}}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}} which is not isbits.  
.1 is of type Base.Broadcast.Extruded{Matrix{Float32}, Tuple{Bool, Bool}, Tuple{Int64, Int64}} which is not isbits.  
.x is of type Matrix{Float32} which is not isbits.  
Can someone help me out with this error? I know to trace the error, you need the actual code, but can someone explain the reason for this error and what type of error in general is this?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [December 2, 2023, 3:03pm UTC](https://discourse.julialang.org/t/perplexing-behavior-when-computing-the-matmul-smoke-test-on-gpu-in-julia/106994/5 "2023-12-02T15:03:53Z")

</div>

What code is that error from? Your code above does not broadcast.

---

<div class="post-metadata">

### Author: ![Aakhash\_Sundaresan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aakhash_sundaresan/32/202478_2.png) [@Aakhash\_Sundaresan](https://discourse.julialang.org/u/Aakhash_Sundaresan)
#### Post date: [December 3, 2023, 3:33am UTC](https://discourse.julialang.org/t/perplexing-behavior-when-computing-the-matmul-smoke-test-on-gpu-in-julia/106994/6 "2023-12-03T03:33:51Z")

</div>

The error is when I’m trying to use the Lux framework in the NeuralPDE PINN setup on the GPU…
