Skip to content

Fix deferred_codegen registration #711

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

vchuravy
Copy link
Member

According to @gbaraldi this was running into issues on 1.11 when code-coverage was enable (since Base dropped the registration of the ccallable)
and on 1.12 this is going to be broken by JuliaLang/julia#56987

Co-authored-by: Gabriel Baraldi <[email protected]>
Copy link
Contributor

Your PR requires formatting changes to meet the project's style guidelines.
Please consider running Runic (git runic master) to apply these changes.

Click here to view the suggested changes.
diff --git a/src/GPUCompiler.jl b/src/GPUCompiler.jl
index 6488496..76d39ba 100644
--- a/src/GPUCompiler.jl
+++ b/src/GPUCompiler.jl
@@ -68,13 +68,15 @@ function __init__()
     Tracy.@register_tracepoints()
 
     # Register deferred_codegen as a global function so that it can be called with `ccall("extern deferred_codegen"`
-    @dispose jljit=JuliaOJIT() begin
+    return @dispose jljit = JuliaOJIT() begin
         jd = JITDylib(jljit)
 
         address = LLVM.API.LLVMOrcJITTargetAddress(
-            reinterpret(UInt, @cfunction(deferred_codegen, Ptr{Cvoid}, (Ptr{Cvoid},))))
+            reinterpret(UInt, @cfunction(deferred_codegen, Ptr{Cvoid}, (Ptr{Cvoid},)))
+        )
         flags = LLVM.API.LLVMJITSymbolFlags(
-            LLVM.API.LLVMJITSymbolGenericFlagsExported, 0)
+            LLVM.API.LLVMJITSymbolGenericFlagsExported, 0
+        )
         name = mangle(jljit, "deferred_codegen")
         symbol = LLVM.API.LLVMJITEvaluatedSymbol(address, flags)
         map = if LLVM.version() >= v"15"

@vchuravy
Copy link
Member Author

@gbaraldi

With this change: @time_imports

               ┌ 24.8 ms GPUCompiler.__init__() 98.57% compilation time (100% recompilation)
     91.5 ms  GPUCompiler 26.69% compilation time (100% recompilation)

Before this change:

               ┌ 14.9 ms GPUCompiler.__init__() 97.75% compilation time (100% recompilation)
     83.2 ms  GPUCompiler 17.52% compilation time (100% recompilation)

Copy link

codecov bot commented Aug 18, 2025

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.43%. Comparing base (32b4fc8) to head (477be80).

Files with missing lines Patch % Lines
src/GPUCompiler.jl 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #711      +/-   ##
==========================================
+ Coverage   75.27%   75.43%   +0.15%     
==========================================
  Files          24       24              
  Lines        3523     3537      +14     
==========================================
+ Hits         2652     2668      +16     
+ Misses        871      869       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Successfully merging this pull request may close these issues.

1 participant