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

bench mapreduce with array accesses #63

Merged
merged 10 commits into from
May 19, 2017
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/array/ArrayBenchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ for (A, str) in (arrays_iter..., ranges_iter...)
g["sumeach_view", str] = @benchmarkable perf_sumeach_view($A)
g["sumlinear_view", str] = @benchmarkable perf_sumlinear_view($A)
g["sumcartesian_view", str] = @benchmarkable perf_sumcartesian_view($A)
if ndims(A) == 2
g["mapr_access", str] = @benchmarkable perf_mapr_access(A, B, zz, n) setup = (B, zz, n = setup_mapr_access($A)) #20517
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argh, looks like you've discovered a new BenchmarkTools bug. I just posted an issue for it in the BenchmarkTools repo. Sorry about this.

You should be able to fix this by using begin...end instead of parens for setup, e.g. setup = begin B, zz, n = setup_mapr_access($A) end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, no worries for me -- thanks for your patience with this. Fix incoming

end
if ndims(A) <= 2
g["sumcolon", str] = @benchmarkable perf_sumcolon($A)
g["sumrange", str] = @benchmarkable perf_sumrange($A)
Expand Down
14 changes: 14 additions & 0 deletions src/array/sumindex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,20 @@ function perf_ind2sub(sz, lrange)
si, sj, sk
end

function setup_mapr_access(A)
z = zero(eltype(A))
zz = z*z
n = Base.LinAlg.checksquare(A)
B = Vector{typeof(zz)}(n)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the benchmark is testing the performance of mapreduce, it'd be better not to benchmark this setup step, no? See BenchmarkTools' setup/teardown phase functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?

B, zz, n
end
function perf_mapr_access(A, B, zz, n) #20517
@inbounds for j in 1:n
B[j] = mapreduce(k -> A[j,k]*A[k,j], +, zz, 1:j)
end
B
end

##########################
# supporting definitions #
##########################
Expand Down