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

GPUCompiler code typed err #1528

Closed
wsmoses opened this issue Jun 10, 2024 · 2 comments
Closed

GPUCompiler code typed err #1528

wsmoses opened this issue Jun 10, 2024 · 2 comments

Comments

@wsmoses
Copy link
Member

wsmoses commented Jun 10, 2024

julia> fn = sprint() do io
          Enzyme.Compiler.enzyme_code_typed(io, Enzyme.Compiler.runtime_mixed_call, Const, Tuple{Const{Val{(false, true)}}, Const{typeof(Base.Threads.threading_run)}, Duplicated{Ref{typeof(m)}}})
       end^C

julia> Enzyme.Compiler.enzyme_code_typed(Enzyme.Compiler.runtime_mixed_call, Const, Tuple{Const{Val{(false, true)}}, Const{typeof(Base.Threads.threading_run)}, Duplicated{Ref{typeof(m)}}})
1-element Vector{Any}:
 CodeInfo(
1 ─ %1 = (isa)(arg_1, Base.RefValue{var"#2#threadsfor_fun#1"{Vector{Float64}, Float64, UnitRange{Int64}}})::Bool
└──      goto #3 if not %1
2 ─ %3 = π (arg_1, Base.RefValue{var"#2#threadsfor_fun#1"{Vector{Float64}, Float64, UnitRange{Int64}}})
│   %4 = Base.getfield(%3, :x)::var"#2#threadsfor_fun#1"{Vector{Float64}, Float64, UnitRange{Int64}}
└──      goto #4
3 ─ %6 = Base.getindex(arg_1)::Any
└──      goto #4
4 ┄ %8 = φ (#2 => %4, #3 => %6)::Any
│   %9 = (f)(%8)::Core.Const(nothing)
└──      return %9
) => Nothing

julia> Enzyme.Compiler.enzyme_code_lowered(Enzyme.Compiler.runtime_mixed_call, Const, Tuple{Const{Val{(false, true)}}, Const{typeof(Base.Threads.threading_run)}, Duplicated{Ref{typeof(m)}}})
ERROR: UndefVarError: enzyme_code_lowered not defined
Stacktrace:
 [1] getproperty(x::Module, f::Symbol)
   @ Base ./Base.jl:26
 [2] top-level scope
   @ REPL[14]:1

julia> @code_lowered Enzyme.Compiler.runtime_mixed_call(Val((false,true)), Base.Threads.threading_run, Ref(m))
CodeInfo(
    @ /home/wmoses/git/Enzyme.jl/src/rules/jitrules.jl:23 within `runtime_mixed_call'
   ┌ @ /home/wmoses/git/Enzyme.jl/src/rules/jitrules.jl:45 within `macro expansion'
1 ─│      nothing
│  └
│  ┌ @ /home/wmoses/git/Enzyme.jl/src/rules/jitrules.jl:46 within `macro expansion'
│  │ %2 = Base.getindex(arg_1)
│  │ %3 = (f)(%2)
└──│      return %3
   └
)

julia> @code_typed Enzyme.Compiler.runtime_mixed_call(Val((false,true)), Base.Threads.threading_run, Ref(m))
CodeInfo(
1 ─ %1 = Base.getfield(arg_1, :x)::var"#2#threadsfor_fun#1"{Vector{Float64}, Float64, UnitRange{Int64}}
│   %2 = invoke f(%1::Function)::Core.Const(nothing)
└──      return %2
) => Nothing

@wsmoses
Copy link
Member Author

wsmoses commented Jun 10, 2024

setup shenanigans:




z(x) = Base.unsafe_pointer_to_objref(Base.reinterpret(Ptr{Cvoid}, x))
@generated function make()
     return quote
         Base.@_inline_meta
         $(Expr(:new, z(138254807239984), ones(10), 1.0, UnitRange{Int64}(1:3)))
     end
end
m = make()

Enzyme.Compiler.runtime_mixed_call(Val((false,true)), Base.Threads.threading_run, Ref(m))




Enzyme.Compiler.enzyme_code_typed(Enzyme.Compiler.runtime_mixed_call, Const, Tuple{Const{Val{(false, true)}}, Const{typeof(Base.Threads.threading_run)}, Duplicated{Ref{typeof(m)}}})

 fn = sprint() do io
    Enzyme.Compiler.enzyme_code_llvm(io, Enzyme.Compiler.runtime_mixed_call, Const, Tuple{Const{Val{(false, true)}}, Const{typeof(Base.Threads.threading_run)}, Duplicated{Ref{typeof(m)}}})
 end


 fn = sprint() do io
    Enzyme.Compiler.enzyme_code_llvm(io, Enzyme.Compiler.runtime_mixed_call, Const, Tuple{Const{Val{(false, true)}}, Duplicated{Ref{typeof(m)}}}; dump_module=true, run_enzyme=false)
 end

@wsmoses
Copy link
Member Author

wsmoses commented Jun 10, 2024

Moved here: JuliaGPU/GPUCompiler.jl#587

@wsmoses wsmoses closed this as completed Jun 10, 2024
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

1 participant