-
Notifications
You must be signed in to change notification settings - Fork 152
Define size more explicitly, helping the compiler
#145
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
Conversation
andyferris
left a comment
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.
| @pure size(::Type{SA}, d::Int) where {SA <: StaticArray} = Size(SA)[d] | ||
| @pure size(::Type{<:StaticArray{S}}) where S = tuple(S.parameters...) | ||
| @inline function size(t::Type{<:StaticArray}, d::Int) | ||
| S = size(t) |
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.
Is generated code better with Size(t)?
|
Yep, it's better. I didn't spend a lot of time on this, but I did check the the following using @Keno's original example: Without patch: julia> foo(A) = size(A,2)
julia> @code_llvm foo(ones(SMatrix{2,3}))
define i64 @julia_foo_60424(%SArray* nocapture readonly dereferenceable(48)) #0 !dbg !5 {
top:
%1 = call i64 @julia_size_60425(%SArray* nocapture nonnull readonly %0, i64 2)
ret i64 %1
}With patch: julia> foo(A) = size(A,2)
julia> @code_llvm foo(ones(SMatrix{2,3}))
define i64 @julia_foo_60360(%SArray* nocapture readonly dereferenceable(48)) #0 !dbg !5 {
top:
ret i64 3
}It'll be a bit of a grind, but we need to put some solid work into benchmarking StaticArrays. This kind of spot checking of the assembly is all very well, but I'm pretty sure we're going to fall into a massive performance hole sometime soon without realizing it :-/ |
|
I checked a few other things like |
|
This looks fine to me. |
|
Thanks guys!! |
* bypass constructor in getindex * special case tuples and named tuples * only bypass constructor for concrete types * test on internal constructor case * minor reorg * define struct outside testet
@Keno this is an updated version of your PR.
Resolves #137