-
Notifications
You must be signed in to change notification settings - Fork 9
perf: add 0-copy reduce-vcat specialization for VectorOfVectors #50
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
base: main
Are you sure you want to change the base?
perf: add 0-copy reduce-vcat specialization for VectorOfVectors #50
Conversation
test/vector_of_arrays.jl
Outdated
V3 = VectorOfVectors(ref_AoA1(Float32, 3)) | ||
V4 = VectorOfVectors(ref_AoA1(Float32, 4)) | ||
|
||
@test reduce(vcat, V1) == flatview(V1) |
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.
Let's test the behavior
@test reduce(vcat, V1) == reduce(vcat, Array(V1))
instead.
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.
See other comments.
is there some forgotten comments due to Github UI? |
No, I meant the change comment, I just had clicked "approve" by default, so I needed to add another review with "request changes". |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #50 +/- ##
=======================================
Coverage 96.20% 96.21%
=======================================
Files 8 8
Lines 527 528 +1
=======================================
+ Hits 507 508 +1
Misses 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@pfackeldey are you going to add reduce for |
Ah, I didn't know this reduce + vcat specialization can also be done here for |
V1 = VectorOfVectors(ref_AoA1(Float32, 1)) | ||
V2 = VectorOfVectors(ref_AoA1(Float32, 2)) | ||
V3 = VectorOfVectors(ref_AoA1(Float32, 3)) | ||
V4 = VectorOfVectors(ref_AoA1(Float32, 4)) | ||
|
||
@test reduce(vcat, V1) == reduce(vcat, Array(V1)) | ||
@test reduce(vcat, V2) == reduce(vcat, Array(V2)) | ||
@test reduce(vcat, V3) == reduce(vcat, Array(V3)) | ||
@test reduce(vcat, V4) == reduce(vcat, Array(V4)) | ||
|
||
@test (@allocated reduce(vcat, V1)) == 0 | ||
@test (@allocated reduce(vcat, V2)) == 0 | ||
@test (@allocated reduce(vcat, V3)) == 0 | ||
@test (@allocated reduce(vcat, V4)) == 0 |
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.
You can shorten this as
V1 = VectorOfVectors(ref_AoA1(Float32, 1)) | |
V2 = VectorOfVectors(ref_AoA1(Float32, 2)) | |
V3 = VectorOfVectors(ref_AoA1(Float32, 3)) | |
V4 = VectorOfVectors(ref_AoA1(Float32, 4)) | |
@test reduce(vcat, V1) == reduce(vcat, Array(V1)) | |
@test reduce(vcat, V2) == reduce(vcat, Array(V2)) | |
@test reduce(vcat, V3) == reduce(vcat, Array(V3)) | |
@test reduce(vcat, V4) == reduce(vcat, Array(V4)) | |
@test (@allocated reduce(vcat, V1)) == 0 | |
@test (@allocated reduce(vcat, V2)) == 0 | |
@test (@allocated reduce(vcat, V3)) == 0 | |
@test (@allocated reduce(vcat, V4)) == 0 | |
for n in [1, 2, 3, 4] | |
V = VectorOfVectors(ref_AoA1(Float32, n)) | |
@test reduce(vcat, V) == reduce(vcat, Array(1)) | |
@test (@allocated reduce(vcat, V)) == 0 | |
end |
This PR adds a specialization for
reduce(vcat, VoV)
specialization to directly return aflatview
, this operation is zero-copy.