# Problem with @avx and LoopVectorization: UndefVarError

**URL:** <https://discourse.julialang.org/t/problem-with-avx-and-loopvectorization-undefvarerror/62279>\
**Category:** General Usage\
**Tags:** loops, loopvectorization\
**Created:** [June 2, 2021, 3:24pm UTC](https://discourse.julialang.org/t/problem-with-avx-and-loopvectorization-undefvarerror/62279 "2021-06-02T15:24:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmcastro2109](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmcastro2109/32/38427_2.png) [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Post date:** [June 2, 2021, 3:24pm UTC](https://discourse.julialang.org/t/problem-with-avx-and-loopvectorization-undefvarerror/62279/1 "2021-06-02T15:24:36Z")

</div>

Hello,

I am running the following code using LoopVectorization,

```julia
using Random, BenchmarkTools, LoopVectorization

J = 1000
T = 100

Mat1 = rand(J,J)
vec1 = rand(J)

Mat2= rand(J,J)
vec2 = rand(J)

Mat3 = rand(J,J,T)
vec3 = rand(J,T)

function f1(X,Y,Z,params,Mat1,Mat2,vec2,vec1,vec3,Mat3)
    (J,T) = size(X)
    (γoᴱ,γgᴱ,ψgᴱ,κgᴱ,γlᴱ,ψlᴱ,κlᴱ,γaᴱ,ψaᴱ,κaᴱ)=params
    eⱼX = zeros(Float32,J,T)
    eⱼY = zeros(Float32,J,T)
    eⱼZ = zeros(Float32,J,T)

    E1 = zeros(Float32, J, J)
    E2 = zeros(Float32, J, J)
    E3 = zeros(Float32, J, J, T)

    @avx E1 .=exp.(Mat1.*(-κgᴱ))
    @avx E2 .=exp.(Mat2.*(-κlᴱ))
    @avx E3 .=exp.(Mat3.*(-κaᴱ))

    for t=1:T
      for l=1:J
        @avx for j=1:J
            ejl = γoᴱ+γgᴱ*(1+ψgᴱ*vec1[j])*E1[j,l]+γlᴱ*(1+ψlᴱ*vec2[j])*E2[j,l]+γaᴱ*(1+ψaᴱ*vec3[j,t])*E3[j,l,t]
            elj = γoᴱ+γgᴱ*(1+ψgᴱ*vec1[l])*E1[j,l]+γlᴱ*(1+ψlᴱ*vec2[l])*E2[j,l]+γaᴱ*(1+ψaᴱ*vec3[l,t])*E3[j,l,t]
            eⱼX[j,t] =eⱼX[j,t] + X[l,t]*(ejl+elj)*(l!=j)
            eⱼY[j,t] =eⱼY[j,t] + Y[l,t]*(ejl+elj)*(l!=j)
            eⱼZ[j,t] =eⱼZ[j,t] + Z[l,t]*(ejl+elj)*(l!=j)
        end
      end
    end
    return eⱼX, eⱼY, eⱼZ
end

params = [0.0,
22.504883,
0.00010256348,
0.0021472168,
28.549805,
1.4460449,
23.164062,
29.42871,
1.4924316,
79.72656]

TEST1res = f1(zeros(Int8,J,60),ones(Int8,J,60),ones(Int8,J,60),params,Mat1,Mat2,vec2,vec1,vec3,Mat3)

```

and I get the following error code

```julia
ERROR: UndefVarError: ###tempload###21### not defined
Stacktrace:
 [1] f1(::Array{Int8,2}, ::Array{Int8,2}, ::Array{Int8,2}, ::Array{Float64,1}, ::Array{Float64,2}, ::Array{Float64,2}, ::Array{Float64,1}, ::Array{Float64,1}, ::Array{Float64,2}, ::Array{Float64,3}) at ./REPL[53]:19
 [2] top-level scope at REPL[56]:1

```

I am running this on a server with Julia 1.5.0, The version of LoopVectorization is LoopVectorization v0.12.28. The same code works on another machine.

The version is

> Julia Version 1.5.0  
> Commit 96786e22cc (2020-08-01 23:44 UTC)  
> Platform Info:  
> OS: Linux (x86\_64-pc-linux-gnu)  
> CPU: Intel(R) Xeon(R) Gold 6142 CPU @ 2.60GHz  
> WORD\_SIZE: 64  
> LIBM: libopenlibm  
> LLVM: libLLVM-9.0.1 (ORCJIT, skylake)

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [June 2, 2021, 3:26pm UTC](https://discourse.julialang.org/t/problem-with-avx-and-loopvectorization-undefvarerror/62279/2 "2021-06-02T15:26:40Z")

</div>

Can you post `versioninfo()`?

---

<div class="post-metadata">

**Author:** ![jmcastro2109](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmcastro2109/32/38427_2.png) [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Post date:** [June 2, 2021, 3:31pm UTC](https://discourse.julialang.org/t/problem-with-avx-and-loopvectorization-undefvarerror/62279/3 "2021-06-02T15:31:01Z")

</div>

Sure, edited Original post

---

<div class="post-metadata">

**Author:** ![jmcastro2109](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmcastro2109/32/38427_2.png) [@jmcastro2109](https://discourse.julialang.org/u/jmcastro2109)\
**Post date:** [June 2, 2021, 5:13pm UTC](https://discourse.julialang.org/t/problem-with-avx-and-loopvectorization-undefvarerror/62279/4 "2021-06-02T17:13:17Z")

</div>

Solved [https://github.com/JuliaSIMD/LoopVectorization.jl/issues/277](https://github.com/JuliaSIMD/LoopVectorization.jl/issues/277)
