LoopVectorization Pre-compilation error

Hi. First of all, this is my first post here and I apologize in advance should I have violated any of the usual “style rules” for this kind of question and also for it potentially being a bit naive.

The issue I am facing is the following: For a project, I have organized some code as a local package/module on my computer (I call it LOCAL_PACKAGE here). I think that some parts of said code could be speed up using the LoopVectorization.jl package. Now, trying to add it to the package results in the following:

(LOCAL_PACKAGE) pkg> add LoopVectorization
   Resolving package versions...
   Installed SnoopPrecompile ─── v1.0.1
   Installed PolyesterWeave ──── v0.1.9
   Installed SLEEFPirates ────── v0.6.35
   Installed VectorizationBase ─ v0.21.47
   Installed LoopVectorization ─ v0.12.125
   Installed ArrayInterface ──── v6.0.23
    Updating `C:\Users\matth\LOCAL_PACKAGE\Project.toml`
  [bdcacae8] + LoopVectorization v0.12.125
    Updating `C:\Users\matth\LOCAL_PACKAGE\Manifest.toml`
  [4fba245c] + ArrayInterface v6.0.23
  [015c0d05] + ArrayInterfaceOffsetArrays v0.1.6
  [b0d46f97] + ArrayInterfaceStaticArrays v0.1.4
  [dd5226c6] + ArrayInterfaceStaticArraysCore v0.1.0
  [62783981] + BitTwiddlingConvenienceFunctions v0.1.4
  [2a0fbf3d] + CPUSummary v0.1.25
  [fb6a15b2] + CloseOpenIntervals v0.1.10
  [adafc99b] + CpuId v0.3.1
  [3e5b6fbb] + HostCPUFeatures v0.1.8
  [615f187c] + IfElse v0.1.1
  [10f19ff3] + LayoutPointers v0.1.10
  [bdcacae8] + LoopVectorization v0.12.125
  [d125e4d3] + ManualMemory v0.1.8
  [6fe1bfb0] + OffsetArrays v1.12.7
  [1d0040c9] + PolyesterWeave v0.1.9
  [3cdde19b] + SIMDDualNumbers v0.1.1
  [94e857df] + SIMDTypes v0.1.0
  [476501e8] + SLEEFPirates v0.6.35
  [66db9d55] + SnoopPrecompile v1.0.1
  [aedffcd0] + Static v0.7.6
  [8290d209] + ThreadingUtilities v0.5.0
  [3d5dd08c] + VectorizationBase v0.21.47
Precompiling project...
  ✗ ArrayInterfaceStaticArrays
  ✗ LayoutPointers
  ✗ VectorizationBase
  ✗ SLEEFPirates
  ✗ LoopVectorization
  ✓ LOCAL_PACKAGE
  6 dependencies successfully precompiled in 27 seconds (203 already precompiled)
  1 dependency precompiled but a different version is currently loaded. Restart julia to access the new version
  5 dependencies errored. To see a full report either run `import Pkg; Pkg.precompile()` or load the packages

julia> import Pkg; Pkg.precompile()
Precompiling project...
  ✗ ArrayInterfaceStaticArrays
  ✗ LayoutPointers
  ✗ VectorizationBase
  ✗ SLEEFPirates
  ✗ LoopVectorization
  0 dependencies successfully precompiled in 14 seconds (209 already precompiled)

ERROR: The following 1 direct dependency failed to precompile:

LoopVectorization [bdcacae8-1622-11e9-2a5c-532679323890]

Failed to precompile LoopVectorization [bdcacae8-1622-11e9-2a5c-532679323890] to C:\Users\matth\.julia\compiled\v1.7\LoopVectorization\jl_6180.tmp.
ERROR: LoadError: UndefVarError: device not defined
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base .\Base.jl:35
 [2] top-level scope
   @ C:\Users\matth\.julia\packages\ArrayInterfaceStaticArrays\Yuans\src\ArrayInterfaceStaticArrays.jl:20
 [3] include
   @ .\Base.jl:418 [inlined]
 [4] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
   @ Base .\loading.jl:1318
 [5] top-level scope
   @ none:1
 [6] eval
   @ .\boot.jl:373 [inlined]
 [7] eval(x::Expr)
   @ Base.MainInclude .\client.jl:453
 [8] top-level scope
   @ none:1
in expression starting at C:\Users\matth\.julia\packages\ArrayInterfaceStaticArrays\Yuans\src\ArrayInterfaceStaticArrays.jl:1
ERROR: LoadError: Failed to precompile ArrayInterfaceStaticArrays [b0d46f97-bff5-4637-a19a-dd75974142cd] to C:\Users\matth\.julia\compiled\v1.7\ArrayInterfaceStaticArrays\jl_658E.tmp.
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
    @ Base .\loading.jl:1466
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base .\loading.jl:1410
  [4] _require(pkg::Base.PkgId)
    @ Base .\loading.jl:1120
  [5] require(uuidkey::Base.PkgId)
    @ Base .\loading.jl:1013
  [6] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:997
  [7] include
    @ .\Base.jl:418 [inlined]
  [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base .\loading.jl:1318
  [9] top-level scope
    @ none:1
 [10] eval
    @ .\boot.jl:373 [inlined]
 [11] eval(x::Expr)
    @ Base.MainInclude .\client.jl:453
 [12] top-level scope
    @ none:1
in expression starting at C:\Users\matth\.julia\packages\LayoutPointers\ssuuk\src\LayoutPointers.jl:1
ERROR: LoadError: Failed to precompile LayoutPointers [10f19ff3-798f-405d-979b-55457f8fc047] to C:\Users\matth\.julia\compiled\v1.7\LayoutPointers\jl_638B.tmp.      
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
    @ Base .\loading.jl:1466
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base .\loading.jl:1410
  [4] _require(pkg::Base.PkgId)
    @ Base .\loading.jl:1120
  [5] require(uuidkey::Base.PkgId)
    @ Base .\loading.jl:1013
  [6] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:997
  [7] include
    @ .\Base.jl:418 [inlined]
  [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::String)
    @ Base .\loading.jl:1318
  [9] top-level scope
    @ none:1
 [10] eval
    @ .\boot.jl:373 [inlined]
 [11] eval(x::Expr)
    @ Base.MainInclude .\client.jl:453
 [12] top-level scope
    @ none:1
in expression starting at C:\Users\matth\.julia\packages\VectorizationBase\gTlqN\src\VectorizationBase.jl:1
ERROR: LoadError: Failed to precompile VectorizationBase [3d5dd08c-fd9d-11e8-17fa-ed2836048c2f] to C:\Users\matth\.julia\compiled\v1.7\VectorizationBase\jl_6223.tmp.
Stacktrace:
  [1] error(s::String)
    @ Base .\error.jl:33
  [2] compilecache(pkg::Base.PkgId, path::String, internal_stderr::IO, internal_stdout::IO, ignore_loaded_modules::Bool)
    @ Base .\loading.jl:1466
  [3] compilecache(pkg::Base.PkgId, path::String)
    @ Base .\loading.jl:1410
  [4] _require(pkg::Base.PkgId)
    @ Base .\loading.jl:1120
  [5] require(uuidkey::Base.PkgId)
    @ Base .\loading.jl:1013
  [6] require(into::Module, mod::Symbol)
    @ Base .\loading.jl:997
  [7] include
    @ .\Base.jl:418 [inlined]
  [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
    @ Base .\loading.jl:1318
  [9] top-level scope
    @ none:1
 [10] eval
    @ .\boot.jl:373 [inlined]
 [11] eval(x::Expr)
    @ Base.MainInclude .\client.jl:453
 [12] top-level scope
    @ none:1
in expression starting at C:\Users\matth\.julia\packages\LoopVectorization\nkDac\src\LoopVectorization.jl:1
Stacktrace:
 [4] #precompile#220
   @ C:\Users\matth\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\API.jl:1011 [inlined]
 [5] precompile()   @ Pkg.API C:\Users\matth\AppData\Local\Programs\Julia-1.7.1\share\julia\stdlib\v1.7\Pkg\src\API.jl:1011
 [6] top-level scope
   @ REPL[10]:1

To be honest, I am not so sure what to make out of this. I interpret this to being connected to device not being defined for ArrayInterfaceStaticArrays, but it is somewhat obscure what how to resolve this. For what it’s worth, if I just open a Julia REPL on my PC without said module, there is no problem, e.g. I can do the following without problems:

using LoopVectorization

test = rand(50,50,10)

@tturbo exp.(test)

Could the issue be compatibility with some other dependency of my LOCAL_PACKAGE module?

Does the error re-occur if you close that REPL session, restart it, and run a fresh Pkg.precompile()?

You can also try a Pkg.resolve() within the project environment.

Thanks for answering! Unfortunately, restarting the REPL session does not appear to resolve the issue, and neither does doing a Pkg.resolve().

As an update, I managed to “resolve” the issue by rm-ing all dependencies from my LOCAL_PACKAGE and adding them again. When I did this, I got some error for some other package (MKL to be precise), which may or may not have been related but which I managed to resolve. Not sure why this worked, but it did and I can use LoopVectorization in my LOCAL_PACKAGE now.

1 Like

Not a bug then, I’ve deleted that post (ArrayInterface does import device into its scope, I just noticed).

Thank you for the update.