Skip to content

Commit

Permalink
refine to llvmcall instead
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed May 15, 2024
1 parent 12163f9 commit b515f11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/driver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ function codegen(output::Symbol, @nospecialize(job::CompilerJob);
error("Unknown compilation output $output")
end

@noinline function var"gpuc.deferred"(f, args...) end
@noinline function var"gpuc.lookup"(mi, f, args...) end
# GPUCompiler intrinsic that marks deferred compilation
function var"gpuc.deferred" end

# primitive mechanism for deferred compilation, for implementing CUDA dynamic parallelism.
# this could both be generalized (e.g. supporting actual function calls, instead of
Expand Down
18 changes: 11 additions & 7 deletions src/jlgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,6 @@ function CC.abstract_call_known(interp::GPUInterpreter, @nospecialize(f),
return CC.CallMeta(Ptr{Cvoid}, Union{}, CC.Effects(), callinfo)
end
end
if f === var"gpuc.lookup"
error("Unimplemented")
end
return @invoke CC.abstract_call_known(interp::CC.AbstractInterpreter, f,
arginfo::CC.ArgInfo, si::CC.StmtInfo, sv::CC.AbsIntState,
max_methods::Int)
Expand All @@ -504,10 +501,17 @@ function CC.handle_call!(todo::Vector{Pair{Int,Any}},
@assert case isa CC.InvokeCase
@assert stmt.head === :call

# rewrite the marker function
stmt.args[1] = var"gpuc.lookup"
# insert the mi
insert!(stmt.args, 2, case.invoke)
args = Any[
"extern gpuc.lookup",
Ptr{Cvoid},
Core.svec(Any, Any, match.spec_types.parameters[2:end]...), # Must use Any for MethodInstance or ftype
0,
QuoteNode(:llvmcall),
case.invoke,
stmt.args[2:end]...
]
stmt.head = :foreigncall
stmt.args = args
return nothing
end

Expand Down

0 comments on commit b515f11

Please sign in to comment.