-
Notifications
You must be signed in to change notification settings - Fork 9
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
Hoist some getproperty calls inside broadcast expr #424
Conversation
bors try |
It is annoying that we have to do this but LGTM |
I wonder if we construct the property views directly (with Subarray bypassing all the checks) if that would help.... |
Yeah, at least the fix is easy, though. Also, one nice thing that I've found with doing this is that it helps decouple the structure of the state vector (
Maybe, I'm still looking through the JET results.. |
bors r+ |
We should just do it consistently in any case, I'll go through and make that change. |
bors r- |
Canceled. |
Could you try? diff --git a/src/DataLayouts/DataLayouts.jl b/src/DataLayouts/DataLayouts.jl
index 0ddeba0..20eb00d 100644
--- a/src/DataLayouts/DataLayouts.jl
+++ b/src/DataLayouts/DataLayouts.jl
@@ -869,13 +869,16 @@ end
data::VIFH{S, Ni, A},
::Val{Idx},
) where {S, Ni, A, Idx}
+ array = parent(data)
+ Nv = size(array, 1)
+ Nh = size(array, 4)
SS = fieldtype(S, Idx)
T = eltype(A)
offset = fieldtypeoffset(T, S, Idx)
nbytes = typesize(T, SS)
field_byterange = (offset + 1):(offset + nbytes)
return :(VIFH{$SS, $Ni}(
- @inbounds view(parent(data), :, :, $field_byterange, :)
+ @inbounds SubArray(parent(data), Base.Slice(Base.OneTo($Nv)), Base.Slice(Base.OneTo($Ni)), $field_byterange, Base.Slice(Base.OneTo($Nh)))
))
end |
80edbf5
to
13f679f
Compare
I'll try this in a follow up PR, so that we know what perf changes are attributed to. |
actually with a generated function, that doesn't work if we don't have the size extents in the type :-/. We could try it with the getproperty call that isn't a generated function by switching the impl at the top of that file. It might be good to revisit if we even need these again. |
bors r+ |
tryBuild failed: |
Releated: #11 (comment) |
438: Hoist some getproperty calls r=charleskawczynski a=charleskawczynski I missed a few in #424. Co-authored-by: Charles Kawczynski <[email protected]>
This PR should improve performance a bit via manual code hoisting, see #341.
I can confirm that this reduces the number of JET complaints.