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

Accelerate minimum(A; dims = 1) for cartesian indexed cases. #43618

Closed
wants to merge 3 commits into from

Conversation

N5N3
Copy link
Member

@N5N3 N5N3 commented Dec 31, 2021

Our mapreduce use mapreduce_impl for linear-indexable inputs to accelerate min/max related calls, which is critical to Float cases especially when dim1 is included in reduction.
But the optimization is missing for cartesian cases.

This PR try to fuse more mapreduce_impl for free speed:
minimum Benchmark (combined with #43604, which widen the optimizaiton to much shorten length):

using Random, BenchmarkTools                   
Random.seed!(0);
a = view(rand(128,128),1:128,1:128);# PR 43604      This PR
@btime minimum($a, dims = 1);       #28.100 μs  --> 9.400 μs 
@btime minimum($a, dims = 2);       #4.071 μs   --> 4.086 μs 
@btime minimum($a, dims = (1,2));   #26.700 μs  --> 9.700 μs
@btime minimum($a);                 #30.400 μs  --> 9.100 μs

N5N3 added 3 commits January 1, 2022 21:19
Test-fix: `Broadcasted` should behave like a cartesian-indexed Array. (we don't always call `foldl` for performance)

Update reduce.jl

Update reduce.jl

Update reduce.jl

Update reduce.jl
@dkarrasch dkarrasch added the performance Must go faster label Jan 1, 2022
@N5N3 N5N3 marked this pull request as draft January 9, 2022 02:09
@N5N3 N5N3 closed this Jun 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants