-
Notifications
You must be signed in to change notification settings - Fork 237
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
@gcsafe_ccall
breaks inlining of ccall wrappers
#2347
Comments
Hm I wonder if the inline meta survives... I remember some code that scans he top of he function and if there is anything before that it might not see it? |
Good suggestion, but doesn't seem to help. To make sure it's very much the first expression: macro gcsafe_ccall(expr)
ex = ccall_macro_lower(Base.ccall_macro_parse(expr)...)
pushfirst!(ex.args, Expr(:meta, :inline))
println(ex)
return ex
end ... which gives
... still allocates. EDIT: wait, it did make me 'discover' that adding an |
e49197b... Not particularly happy with all the explicit inlining going on there, but yeah... |
After experimenting a bit, it appears that this issue no longer occurs in versions 1.12 and above, probably thanks to some slight advancements in effect analysis. However, since these are quite delicate adjustments, I believe it's very beneficial to explicitly use the |
Thanks! |
#2262 introduced a regression: Using
@gcsafe_ccall
instead of plain@ccall
apparently makes it so that ourccall
wrappers aren't fully inlined anymore, resulting in simpleRef
boxes (which we need a ton of with the CUDA C APIs) start allocating.MWE:
Ways to 'make' this inline again (and get 0 allocated bytes):
@gcsafe_ccall
with plain@ccall
@gcsafe_ccall
, remove the call to jl_gc_safe_leavecuCtxGetCurrent
I can understand how the added calls in the
@gcsafe_ccall
body push the function over the inlining limit, but it's very surprising to me that I can only force inlining by using a call-site@inline
, and not by annotating the generated code or function with@inline
. @aviatesk, is that expected behavior?cc @vchuravy
The text was updated successfully, but these errors were encountered: