perf: add 0-copy reduce-vcat specialization for VectorOfVectors#50
perf: add 0-copy reduce-vcat specialization for VectorOfVectors#50pfackeldey wants to merge 2 commits intoJuliaArrays:mainfrom
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.
Let's test the behavior
@test reduce(vcat, V1) == reduce(vcat, Array(V1))
instead.
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.
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 |
|
@pfackeldey can you enable "allow maintainer to push to this branch"? |
Hi @oschulz, this should be enabled already (the checkmark is set at least). However, I didn't forget about my 2 PRs, I was just a bit flooded with work the last days. I can try your suggestions soon, but feel free to push already to the PRs! |
No worries, I know how it is ... :-) |
|
Was checking out this package today and wanted this feature, glad to see the PR! Let me know if there's anything I can do to help. |
|
Update: still fiddling a bit with the changes necessary to fix #2, should be done soon. |
This PR adds a specialization for
reduce(vcat, VoV)specialization to directly return aflatview, this operation is zero-copy.