Skip to content

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

@github-actions
Copy link
Contributor

github-actions bot commented Aug 18, 2025

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 ec33e9a..8f2cf75 100644
--- a/src/GPUCompiler.jl
+++ b/src/GPUCompiler.jl
@@ -66,7 +66,7 @@ function __init__()
     global compile_cache = dir
 
     Tracy.@register_tracepoints()
-    register_deferred_codegen()
+    return register_deferred_codegen()
 end
 
 end # module
diff --git a/src/driver.jl b/src/driver.jl
index 8dbff91..7b0c318 100644
--- a/src/driver.jl
+++ b/src/driver.jl
@@ -154,13 +154,15 @@ end
 # Called from __init__
 # On 1.11+ this is needed due to a Julia bug that drops the pointer when code-coverage is enabled.
 function register_deferred_codegen()
-    @dispose jljit=JuliaOJIT() begin
+    @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)

@codecov
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.

@vchuravy vchuravy requested a review from gbaraldi September 24, 2025 17:08
LLVM.define(jd, mu)
addr = lookup(jljit, "deferred_codegen")
@assert addr != C_NULL "Failed to register deferred_codegen"
end
Copy link
Member

@gbaraldi gbaraldi Sep 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we ccall it here just to check if it's working? I guess the address is enough but not sure. I guess the test is enough

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think the ccall would not add more information, and if failed lead to a more confusing error.

@gbaraldi
Copy link
Member

This isn't pretty, but it's also not very different from what was there before.

@vchuravy vchuravy merged commit 246b761 into master Sep 24, 2025
18 of 22 checks passed
@vchuravy vchuravy deleted the vc/deffered_codegen branch September 24, 2025 17:29
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.

3 participants