-
Notifications
You must be signed in to change notification settings - Fork 57
New interface: process_linked_module!
#727
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
Conversation
Your PR requires formatting changes to meet the project's style guidelines. Click here to view the suggested changes.diff --git a/src/driver.jl b/src/driver.jl
index 950ea27..7808667 100644
--- a/src/driver.jl
+++ b/src/driver.jl
@@ -284,7 +284,7 @@ const __llvm_initialized = Ref(false)
end
# minimal optimization to convert the inttoptr/call into a direct call
- @dispose pb=NewPMPassBuilder() begin
+ @dispose pb = NewPMPassBuilder() begin
add!(pb, NewPMFunctionPassManager()) do fpm
add!(fpm, InstCombinePass())
end
@@ -355,7 +355,7 @@ const __llvm_initialized = Ref(false)
# which also need to happen _after_ regular optimization.
# XXX: make these part of the optimizer pipeline?
if has_deferred_jobs
- @dispose pb=NewPMPassBuilder() begin
+ @dispose pb = NewPMPassBuilder() begin
add!(pb, NewPMFunctionPassManager()) do fpm
add!(fpm, InstCombinePass())
end
diff --git a/src/irgen.jl b/src/irgen.jl
index 2d36315..39e2e54 100644
--- a/src/irgen.jl
+++ b/src/irgen.jl
@@ -950,6 +950,7 @@ function add_input_arguments!(@nospecialize(job::CompilerJob), mod::LLVM.Module,
error("Don't know how to check uses of $candidate. Please file an issue.")
end
end
+ return
end
for f in worklist
scan_uses(f) |
process_linked_module!
process_linked_module!
Also get rid of unused metadata during argument conversions so that we only have to handle instructions.
This makes it possible to use intrinsics in deferred compilations.
eb462aa
to
b19f241
Compare
partially by making use of JuliaGPU/GPUCompiler.jl#727
partially by making use of JuliaGPU/GPUCompiler.jl#727
0aff8bb
to
1722ae3
Compare
This looks great, thanks! I can make use of this in JuliaGPU/OpenCL.jl#365 as well and simplify some things |
The whole set of interfaces is becoming a bit of a mess though. Probably warrants a breaking release at some point to clean some things up, but seeing how this PR is nonbreaking I propose we do that another time. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #727 +/- ##
==========================================
- Coverage 75.00% 73.73% -1.28%
==========================================
Files 24 24
Lines 3613 3636 +23
==========================================
- Hits 2710 2681 -29
- Misses 903 955 +52 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Here I've added yet another interface method to intercept the module before optimization, but after deferred codegen. I use that to postpone the Metal kernel conversions until all modules are collected, making it possible to link deferred modules that use intrinsics rewritten by said conversions.
I'm considering doing this for more back-ends, because it saves us from rewriting the module multiple times. This would mean that more back-ends would start relying on the
julia.kernel
metadata to discover kernels in the linked module, rather than the interface method being called multiple times with each time a differententry::LLVM.Function
being passed.cc @vchuravy
@simeonschaub: this is so that
initialize_rng_state
can simply call intrinsics likethread_position_in_threadgroup_1d()
instead of having to do the ugly argument decoding.