Repository navigation
Use multi-threading when calling mapreduce with multiple sources on CPU - #144
Merged
Merged
Conversation
A reduction over several arrays reduces a `Broadcasted` object, which has no views, so the threaded host reduction ran it on a single thread. Index it as a `LinearBroadcast` instead, which is a vector and gets chunked like any array, without decoding a Cartesian index per element. Co-authored-by: Tim Besard <tim.besard@gmail.com>
maleadt
force-pushed
the
iu/mapreduce-cpu
branch
from
October 26, 2026 19:21
68e9d0f to
4dd8a6d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mapreduceover several arrays (AK.mapreduce(f, op, a, b, c)) reduces aBroadcastedobject. The threaded host reduction can't take views of aBroadcasted, so it ran these reductions on a single thread, whatever-twas.This indexes the
Broadcastedas aLinearBroadcast(from #185) instead. That's a vector, so it gets chunked across tasks like any other array. Each argument is indexed with its own linear index, so no Cartesian index is decoded per element. Indexing a 2-DBroadcastedwith anIntis about 10× slower per element. A broadcast too long forLinearBroadcast's 32-bit index (over 2^32 elements) still runs serially.Timings, before (a serial
mapreduceover theBroadcasted) and after, measured in the same process. Ryzen 9 9950X, Julia 1.12, KA 0.10.3; minimum of 30 runs, on a shared machine:x * (y - z), 3 × 2^23Float64x * y, 2 × 2048×4096Float64sin(x) * cos(y), 2 × 2^23Float64The first two cases are limited by memory bandwidth from about two threads up; the third shows the scaling.
The PR also adds a test that runs a 3-D multi-source reduction across several tasks, and a multi-source case to
benchmark/mapreduce_1d.jl.