-
Notifications
You must be signed in to change notification settings - Fork 53
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
Replace current, not global logger in safe loggers #622
Conversation
This is a easy way to trigger the issue when using regular loggers: julia> GPUCompiler.@locked f() = @info "2"
f (generic function with 1 method)
julia> @sync begin
@async while true
@info 1
end
@async f()
end
[ Info: 1
[ Info: 2
Assertion failed: (ptls->locks.len == 0), function ctx_switch, file task.c, line 439.
[44424] signal 6: Abort trap: 6
in expression starting at REPL[10]:1
__pthread_kill at /usr/lib/system/libsystem_kernel.dylib (unknown line)
Allocations: 23403711 (Pool: 23398303; Big: 5408); GC: 52 i.e., it's not allowed to switch tasks (as done by Base I/O) when operating under the codegen lock. The |
Thanks! I added some tests that reliably segfault with the old safe loggers but pass with the fixed ones. I also added a test for I have second thoughts about forwarding Of course, if we're unlucky, the forwarded I'll push another commit with a simplified design that only forwards |
Looking at some implementations of |
In that case, let me know if you want me to make any edits to code, comments, or git log/history, otherwise, I think this is good to go if you want to have it. As a side note, I'm hitting this issue through Enzyme, but Enzyme is restricted to GPUCompiler <= 0.26. Any chance this could be backported to a 0.26.8 release? Alternatively, @wsmoses, do you foresee upgrading Enzyme to GPUCompiler 0.27 any time soon? Edit: never mind, I just realized the most recent Enzyme is already on GPUCompiler 0.27. Edit 2: Oh, but Enzyme is still incompatible with GPUCompiler 0.27 due to disjoint compat bounds for LLVM, so my question above still stands. |
We generally don't do backport releases here. If upgrading Enzyme.jl to the latest LLVM.jl/GPUCompiler.jl remains a problem, I'm happy to do one (you can create a PR for that if you want), but I know that @wsmoses is already working on upgrading Enzyme.jl to the latest versions of these packages, so it may be easier to wait a bit. |
Co-authored-by: Tim Besard <[email protected]>
Enzyme just released a version that's compatible with LLVM 9, so no backport needed. Do you know when you'll cut the next GPUCompiler release including this patch? |
I've tagged a new version. |
GPUCompiler's safe loggers temporarily replace the global logger with a simple non-yielding logger. But this does nothing if a different current logger is set, in which case the loggers are unsafe and will error if the custom logger yields, as seen in fonsp/Pluto.jl#3012. This PR changes the safe loggers to use
with_logger
instead ofglobal_logger
, to ensure that the yield-free logger is the one that's actually used.In addition, I made it so that the safe logger inherits
Logging.shouldlog
from the current logger, not justLogging.min_enabled_level
. The reasoning is that many loggers setmin_enabled_level
to the minimum possible value and rely onshouldlog
for filtering; Pluto's logger is a case in point. I implemented a dedicatedSafeLogger
type to achieve this. Let me know if this is too heavy and you'd rather stick to a more barebones design without a dedicated type (in which case I thinkmin_enabled_level
should inherit from the global logger rather than the current logger).I'm not sure how to write tests for this, since I'm not sure how to call the
@safe_<loglevel>
macros from a context where task switching raises an error. Suggestions or edits to the PR welcome.