Skip to content

Commit

Permalink
ix attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Dec 3, 2024
1 parent aca53ad commit 9ab8652
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
6 changes: 1 addition & 5 deletions src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4047,11 +4047,7 @@ end
)
end

if primal_job.config.target isa GPUCompiler.NativeCompilerTarget
target_machine = JIT.get_tm()
else
target_machine = GPUCompiler.llvm_machine(primal_job.config.target)
end
target_machine = GPUCompiler.llvm_machine(primal_job.config.target)

parallel = parent_job === nothing ? Threads.nthreads() > 1 : false
process_module = false
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -463,19 +463,19 @@ function optimize!(mod::LLVM.Module, tm::LLVM.TargetMachine)
ModulePassManager() do pm
add_library_info!(pm, triple(mod))
if tm.ref != C_NULL
add_transform_info!(pm, tm)
#add_transform_info!(pm, tm)
end
propagate_julia_addrsp_tm!(pm, tm)
#propagate_julia_addrsp_tm!(pm, tm)
scoped_no_alias_aa!(pm)
type_based_alias_analysis!(pm)
basic_alias_analysis!(pm)
cfgsimplification!(pm)
dce!(pm)
cpu_features_tm!(pm, tm)
#cpu_features_tm!(pm, tm)
scalar_repl_aggregates_ssa!(pm) # SSA variant?
mem_cpy_opt!(pm)
always_inliner!(pm)
alloc_opt_tm!(pm, tm)
#alloc_opt_tm!(pm, tm)
LLVM.run!(pm, mod)
end

Expand Down
17 changes: 10 additions & 7 deletions src/compiler/orcv2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function define_absolute_symbol(jd, name)
return false
end

function __init__()
function setup_globals()
opt_level = Base.JLOptions().opt_level
if opt_level < 2
optlevel = LLVM.API.LLVMCodeGenLevelNone
Expand All @@ -96,7 +96,6 @@ function __init__()
tempTM = LLVM.JITTargetMachine(LLVM.triple(), cpu_name(), cpu_features(); optlevel)
LLVM.asm_verbosity!(tempTM, true)
tm[] = tempTM
@show tm, tempTM

lljit = JuliaOJIT()

Expand All @@ -106,11 +105,6 @@ function __init__()
dg = LLVM.CreateDynamicLibrarySearchGeneratorForProcess(prefix)
LLVM.add!(jd_main, dg)

if Sys.iswindows() && Int === Int64
# TODO can we check isGNU?
define_absolute_symbol(jd_main, mangle(lljit, "___chkstk_ms"))
end

es = ExecutionSession(lljit)
try
lctm = LLVM.LocalLazyCallThroughManager(triple(lljit), es)
Expand All @@ -120,6 +114,15 @@ function __init__()
@warn "OrcV2 initialization failed with" err
jit[] = CompilerInstance(lljit, nothing, nothing)
end
end

function __init__()
setup_globals()

if Sys.iswindows() && Int === Int64
# TODO can we check isGNU?
define_absolute_symbol(jd_main, mangle(lljit, "___chkstk_ms"))
end

hnd = unsafe_load(cglobal(:jl_libjulia_handle, Ptr{Cvoid}))
for (k, v) in Compiler.JuliaGlobalNameMap
Expand Down
6 changes: 3 additions & 3 deletions src/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ using PrecompileTools: @setup_workload, @compile_workload
precompile_module = @eval module $(gensym())
f(x) = x^2
end

kernel() = nothing
Compiler.JIT.setup_globals()

@compile_workload begin
Enzyme.autodiff(Reverse, precompile_module.f, Active(2.0))
end
end
end

0 comments on commit 9ab8652

Please sign in to comment.