Skip to content
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

Merged
merged 1 commit into from
Jan 13, 2022
Merged

Hoist some getproperty calls inside broadcast expr #424

merged 1 commit into from
Jan 13, 2022

Conversation

charleskawczynski
Copy link
Member

@charleskawczynski charleskawczynski commented Jan 13, 2022

This PR should improve performance a bit via manual code hoisting, see #341.

I can confirm that this reduces the number of JET complaints.

@charleskawczynski
Copy link
Member Author

bors try

bors bot added a commit that referenced this pull request Jan 13, 2022
@jakebolewski
Copy link
Contributor

It is annoying that we have to do this but LGTM

@jakebolewski
Copy link
Contributor

jakebolewski commented Jan 13, 2022

I wonder if we construct the property views directly (with Subarray bypassing all the checks) if that would help....

@charleskawczynski
Copy link
Member Author

charleskawczynski commented Jan 13, 2022

It is annoying that we have to do this but LGTM

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 (Y), which is nice.

I wonder if we construct the property views directly (with Subarray bypassing all the checks) if that would help....

Maybe, I'm still looking through the JET results..

@charleskawczynski
Copy link
Member Author

bors r+

@jakebolewski
Copy link
Contributor

jakebolewski commented Jan 13, 2022

We should just do it consistently in any case, I'll go through and make that change.

@charleskawczynski
Copy link
Member Author

bors r-

@bors
Copy link
Contributor

bors bot commented Jan 13, 2022

Canceled.

@jakebolewski
Copy link
Contributor

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

@charleskawczynski
Copy link
Member Author

Could you try? ...

I'll try this in a follow up PR, so that we know what perf changes are attributed to.

@jakebolewski
Copy link
Contributor

jakebolewski commented Jan 13, 2022

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.

@charleskawczynski
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Jan 13, 2022

try

Build failed:

@jakebolewski
Copy link
Contributor

Releated: #11 (comment)

@bors bors bot merged commit af808d8 into main Jan 13, 2022
@bors bors bot deleted the ck/hoist branch January 13, 2022 23:52
bors bot added a commit that referenced this pull request Jan 16, 2022
438: Hoist some getproperty calls r=charleskawczynski a=charleskawczynski

I missed a few in #424.

Co-authored-by: Charles Kawczynski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants