-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add some precompiles #29
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
function _precompile_() | ||
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing | ||
for T in (Bool, Int, Float32, Float64) | ||
for A in (Vector, Matrix) | ||
precompile(stridedpointer, (A{T},)) | ||
end | ||
end | ||
function precompile_nt(@nospecialize(T)) | ||
for I ∈ (Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64) | ||
precompile(vload_quote, (Type{T}, Type{I}, Symbol, Int, Int, Int, Int, Bool, Bool)) | ||
end | ||
# precompile(vfmadd, (Vec{4, T}, Vec{4, T}, Vec{4, T})) # doesn't "take" (too bad, this is expensive) | ||
end | ||
U = NativeTypes | ||
while isa(U, Union) | ||
T, U = U.a, U.b | ||
precompile_nt(T) | ||
end | ||
precompile_nt(U) | ||
precompile(_pick_vector_width, (Type, Vararg{Type,100})) | ||
precompile(>=, (Int, MM{4, 1, Int})) | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any idea why it might not "take"?
Is there anything that can help?
The inference result for
vfmadd(::Vec{W,T}, ::Vec{W,T}, ::Vec{W,T})
should trivially beVec{W,T}
.Would defining the
llvmcall
functions to assert the return type in this manner help inference?And, it also seems like inference should be easy for
llvmcall(string_or_tuple, return_type, arg_types, args...)
(i.e.,return_type
is the return type), so perhaps this is a Julia issue?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish I knew. There are still some weird things about precompilation (e.g., JuliaLang/julia#38951) that need attention. This would be a prime candidate because this one
MethodInstance
(and its callees) costs you something like 200ms, which is quite a lot. (It looks like even more than that on the flamegraph, but that's because of other bits of codegen happening in the middle while this call-tree is being inferred.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, maybe the fact that codegen runs while the callees are being inferred could be related? No clue, really, just grasping for explanations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't know very little about Julia's internals, so it's hard for me to speculate what will/will not work.
E.g., if there's any inference short circuiting that could quickly tell the return type of a function like:
that could then avoid descending into
_muladd
and having to evaluatellvmcall_expr
to infer the (annotated) return type?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure. I would mostly just report this as an issue. I'm really hoping precompilation gets serious attention in Julia 1.7, we really are at the threshold of nuking the latency problem for many workloads.