Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propagate_julia_addrsp! is not defined #531

Closed
YingboMa opened this issue Nov 9, 2023 · 8 comments
Closed

propagate_julia_addrsp! is not defined #531

YingboMa opened this issue Nov 9, 2023 · 8 comments

Comments

@YingboMa
Copy link

YingboMa commented Nov 9, 2023

propagate_julia_addrsp!(pm)

The function propagate_julia_addrsp! is not defined.

@YingboMa
Copy link
Author

YingboMa commented Nov 9, 2023

The propagate_julia_addrsp! is defined in https://github.com/maleadt/LLVM.jl/blob/v6.4.0/src/interop.jl#L13 but it's no longer available for a more recent Julia.

@maleadt
Copy link
Member

maleadt commented Nov 9, 2023

Can you be more specific how you're running into this? That function is expected to not be defined anymore; Julia 1.11 only has newpm, and the newpm version of things in GPUCompiler doesn't call that function.

@YingboMa
Copy link
Author

YingboMa commented Nov 9, 2023

Running following script runs into the issue. See also tshort/StaticCompiler.jl#145

using RecursiveFactorization, StrideArraysCore, StaticCompiler, Static, LinearAlgebra
function _linsolve!(A::Ptr{T}, b::Ptr{T}, ::Val{N}) where {N, T}
    piv = Ref{NTuple{N, Int}}()
    D = static(N)
    GC.@preserve piv begin
        F = RecursiveFactorization.lu!(PtrArray(A, (D, D)),
            PtrArray(Base.unsafe_convert(Ptr{Int}, piv), (D,)))
        ldiv!(F, PtrArray(b, (D,)))
    end
    return b
end
linsolve!(n::Val{N}) where N = (A, b) -> _linsolve!(A, b, n)

N = 10
path = compile_shlib(linsolve!(Val(N)), (Ptr{Float64}, Ptr{Float64}), "./", filename="linsolve$N")

@maleadt
Copy link
Member

maleadt commented Nov 9, 2023

That's a bug with StaticCompiler.jl then, which defines its own pipeline: https://github.com/tshort/StaticCompiler.jl/blob/19792647310852ab18d00b25569517444f549078/src/optimize.jl#L10C36-L10C36

For some context: Base Julia has removed these passes as part of the Legacy PM removal. Users of those passes should migrate to the New PM, which LLVM.jl provides, and GPUCompiler has migrated to. StaticCompiler hasn't.

@maleadt maleadt closed this as completed Nov 9, 2023
@MasonProtter
Copy link

StaticCompiler.jl only hits that pipeline if you use the compile machinery, not the stuff made for standalone compilation.

@maleadt
Copy link
Member

maleadt commented Nov 10, 2023

Without a reproducer or even a backtrace, it's hard to tell what's happening here. It's definitely possible that GPUCompiler somehow erroneously triggers the Legacy PM functionality, feel free to open an issue about that with more details.

@YingboMa
Copy link
Author

Here's the stack trace.

julia> path = compile_shlib(linsolve!(Val(N)), (Ptr{Float64}, Ptr{Float64}), "./", filename="linsolve$N")
ERROR: UndefVarError: `propagate_julia_addrsp!` not defined in `GPUCompiler`
Suggestion: check for spelling errors or missing imports. No global of this name exists in this module.
Stacktrace:
  [1] addOptimizationPasses!(pm::LLVM.ModulePassManager, opt_level::Int64)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/YO8Uj/src/optim.jl:49
  [2] addOptimizationPasses!
    @ GPUCompiler ~/.julia/packages/GPUCompiler/YO8Uj/src/optim.jl:24 [inlined]
  [3] macro expansion
    @ GPUCompiler ~/.julia/packages/GPUCompiler/YO8Uj/src/optim.jl:183 [inlined]
  [4] macro expansion
    @ GPUCompiler ~/.julia/packages/LLVM/vIbji/src/base.jl:98 [inlined]
  [5] optimize!(job::GPUCompiler.CompilerJob, mod::LLVM.Module)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/YO8Uj/src/optim.jl:181
  [6] macro expansion
    @ ~/.julia/packages/TimerOutputs/RsWnF/src/TimerOutput.jl:251 [inlined]
  [7] macro expansion
    @ ~/.julia/packages/GPUCompiler/YO8Uj/src/driver.jl:299 [inlined]
  [8] macro expansion
    @ ~/.julia/packages/TimerOutputs/RsWnF/src/TimerOutput.jl:237 [inlined]
  [9] macro expansion
    @ ~/.julia/packages/GPUCompiler/YO8Uj/src/driver.jl:295 [inlined]
 [10] emit_llvm(job::GPUCompiler.CompilerJob; libraries::Bool, toplevel::Bool, optimize::Bool, cleanup::Bool, only_entry::Bool, validate::Bool)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/YO8Uj/src/utils.jl:89
 [11] emit_llvm
    @ ~/.julia/packages/GPUCompiler/YO8Uj/src/utils.jl:83 [inlined]
 [12] codegen(output::Symbol, job::GPUCompiler.CompilerJob; libraries::Bool, toplevel::Bool, optimize::Bool, cleanup::Bool, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/YO8Uj/src/driver.jl:129
 [13] codegen
    @ ~/.julia/packages/GPUCompiler/YO8Uj/src/driver.jl:110 [inlined]
 [14] #45
    @ ~/.julia/packages/StaticCompiler/LMT2M/src/StaticCompiler.jl:590 [inlined]
 [15] JuliaContext(f::StaticCompiler.var"#45#46"{GPUCompiler.CompilerJob{StaticCompiler.ExternalNativeCompilerTarget, StaticCompiler.StaticCompilerParams}})
    @ GPUCompiler ~/.julia/packages/GPUCompiler/YO8Uj/src/driver.jl:47
 [16] native_llvm_module(f::Function, tt::Tuple{DataType, DataType}, name::String; demangle::Bool, kwargs::@Kwargs{})
    @ StaticCompiler ~/.julia/packages/StaticCompiler/LMT2M/src/StaticCompiler.jl:589
 [17] native_llvm_module(funcs::Tuple{Tuple{var"#1#2"{Val{10}}, Tuple{DataType, DataType}}}; demangle::Bool, kwargs::@Kwargs{})
    @ StaticCompiler ~/.julia/packages/StaticCompiler/LMT2M/src/StaticCompiler.jl:598
 [18] native_llvm_module
    @ ~/.julia/packages/StaticCompiler/LMT2M/src/StaticCompiler.jl:596 [inlined]
 [19] generate_obj(funcs::Tuple{Tuple{var"#1#2"{Val{10}}, Tuple{DataType, DataType}}}, external::Bool, path::String, filenamebase::String; demangle::Bool, strip_llvm::Bool, strip_asm::Bool, opt_level::Int64, kwargs::@Kwargs{})
    @ StaticCompiler ~/.julia/packages/StaticCompiler/LMT2M/src/StaticCompiler.jl:706
 [20] generate_obj
    @ ~/.julia/packages/StaticCompiler/LMT2M/src/StaticCompiler.jl:697 [inlined]
 [21] generate_shlib(funcs::Tuple{Tuple{var"#1#2"{Val{10}}, Tuple{DataType, DataType}}}, external::Bool, path::String, filename::String; demangle::Bool, cflags::Cmd, kwargs::@Kwargs{})
    @ StaticCompiler ~/.julia/packages/StaticCompiler/LMT2M/src/StaticCompiler.jl:559
 [22] generate_shlib
    @ ~/.julia/packages/StaticCompiler/LMT2M/src/StaticCompiler.jl:551 [inlined]
 [23] compile_shlib(funcs::Tuple{Tuple{var"#1#2"{Val{10}}, Tuple{DataType, DataType}}}, path::String; filename::String, demangle::Bool, cflags::Cmd, kwargs::@Kwargs{})
    @ StaticCompiler ~/.julia/packages/StaticCompiler/LMT2M/src/StaticCompiler.jl:352
 [24] compile_shlib(f::Function, types::Tuple{DataType, DataType}, path::String, name::String; filename::String, kwargs::@Kwargs{})
    @ StaticCompiler ~/.julia/packages/StaticCompiler/LMT2M/src/StaticCompiler.jl:332
 [25] top-level scope
    @ REPL[5]:1

julia> VERSION
v"1.11.0-DEV.868"

@maleadt
Copy link
Member

maleadt commented Nov 13, 2023

Decoding the YO8Uj, you seem to be using GPUCompiler v0.21.4, which is months old and does not contain the necessary fixes for Julia 1.11. Please always test with latest master, especially when using unsupported/unreleased versions of Julia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants