Skip to content

Commit

Permalink
Contextfix (#143)
Browse files Browse the repository at this point in the history
* tweaked native_llvm_module for multiple functions to use the same context

* added dispose

* added kwarg before name while calling native_job

* removed comments

* wrapped multi function compilation in GPUCompiler.JuliaContext
  • Loading branch information
ArbitRandomUser authored Oct 9, 2023
1 parent f552ce0 commit 1979264
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/StaticCompiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -595,13 +595,26 @@ end
#Return an LLVM module for multiple functions
function native_llvm_module(funcs::Union{Array,Tuple}; demangle=true, kwargs...)
f,tt = funcs[1]
mod = native_llvm_module(f,tt; demangle, kwargs...)
if length(funcs) > 1
for func in funcs[2:end]
f,tt = func
tmod = native_llvm_module(f,tt; demangle, kwargs...)
link!(mod,tmod)
end
mod = GPUCompiler.JuliaContext() do context
name_f = fix_name(f)
if !demangle
name_f = "julia_"*name_f
end
job, kwargs = native_job(f, tt, true; name = name_f, kwargs...)
mod,_ = GPUCompiler.codegen(:llvm, job; strip=true, only_entry=false, validate=false)
if length(funcs) > 1
for func in funcs[2:end]
f,tt = func
name_f = fix_name(f)
if !demangle
name_f = "julia_"*name_f
end
job, kwargs = native_job(f, tt, true; name = name_f, kwargs...)
tmod,_ = GPUCompiler.codegen(:llvm, job; strip=true, only_entry=false, validate=false)
link!(mod,tmod)
end
end
mod
end
# Just to be sure
for (modfunc, func) in zip(functions(mod), funcs)
Expand Down

0 comments on commit 1979264

Please sign in to comment.