Collective operations are building blocks for interaction patterns, that are often used in SPMD algorithms in the parallel programming context. Hence, there is an interest in efficient realizations of these operations. A realization of the collective operations is provided by the Message Passing Interface (MPI).
Definitions In all asymptotic runtime functions, we denote the latency α (or startup time per message, independent of message size), the communication cost per word β, the number of processing units p and the input size per node n. In cases where we have initial messages on more than one node we assume that all local messages are of the same size. To address individual processing units we use pi∈{p0,p1,…,pp−1}. If we do not have an equal distribution, i.e. node pi has a message of size ni, we get an upper bound for the runtime by setting n=max(n0,n1,…,np−1). A distributed memory model is assumed. The concepts are similar for the shared memory model. However, shared memory systems can provide hardware support for some operations like broadcast (§ Broadcast) for example, which allows convenient concurrent read. Thus, new algorithmic possibilities can become available.
Broadcast
The broadcast pattern is used to distribute data from one processing unit to all processing units, which is often needed in SPMD parallel programs to dispense input or global values. Broadcast can be interpreted as an inverse version of the reduce pattern (§ Reduce). Initially only root r with id 0 stores message m. During broadcast m is sent to the remaining processing units, so that eventually m is available to all processing units. Since an implementation by means of a sequential for-loop with p−1 iterations becomes a bottleneck, divide-and-conquer approaches are common. One possibility is to utilize a binomial tree structure with the requirement that p has to be a power of two. When a processing unit is responsible for sending m to processing units i..j, it sends m to processing unit ⌈(i+j)/2⌉ and delegates responsibility for the processing units ⌈(i+j)/2⌉..j to it, while its own responsibility is cut down to i..⌈(i+j)/2⌉−1. Binomial trees have a problem with long messages m. The receiving unit of m can only propagate the message to other units, after it received the whole message. In the meantime, the communication network is not utilized. Therefore pipelining on binary trees is used, where m is split into an array of k packets of size ⌈n/k⌉. The packets are then broadcast one after another, so that data is distributed fast in the communication network. Pipelined broadcast on balanced binary tree is possible in 𝒪(αlogp+βn), whereas for the non-pipelined case it takes 𝒪((α+βn)logp) cost.
Reduce
The reduce pattern is used to collect data or partial results from different processing units and to combine them into a global result by a chosen operator. Given p processing units, message mi is on processing unit pi initially. All mi are aggregated by ⊗ and the result is eventually stored on p0. The reduction operator ⊗ must be associative at least. Some algorithms require a commutative operator with a neutral element. Operators like sum, min, max are common. Implementation considerations are similar to broadcast (§ Broadcast). For pipelining on binary trees the message must be representable as a vector of smaller object for component-wise reduction. Pipelined reduce on a balanced binary tree is possible in 𝒪(αlogp+βn).
All-Reduce
The all-reduce pattern (also called allreduce) is used if the result of a reduce operation (§ Reduce) must be distributed to all processing units. Given p processing units, message mi is on processing unit pi initially. All mi are aggregated by an operator ⊗ and the result is eventually stored on all pi. Analog to the reduce operation, the operator ⊗ must be at least associative. All-reduce can be interpreted as a reduce operation with a subsequent broadcast (§ Broadcast). For long messages a corresponding implementation is suitable, whereas for short messages, the latency can be reduced by using a hypercube (Hypercube (communication pattern) § All-Gather/ All-Reduce) topology, if p is a power of two. All-reduce can also be implemented with a butterfly algorithm and achieve optimal latency and bandwidth. All-reduce is possible in 𝒪(αlogp+βn), since reduce and broadcast are possible in 𝒪(αlogp+βn) with pipelining on balanced binary trees. All-reduce implemented with a butterfly algorithm achieves the same asymptotic runtime.
Prefix-Sum/Scan
The prefix-sum or scan operation is used to collect data or partial results from different processing units and to compute intermediate results by an operator, which are stored on those processing units. It can be seen as a generalization of the reduce operation (§ Reduce). Given p processing units, message mi is on processing unit pi. The operator ⊗ must be at least associative, whereas some algorithms require also a commutative operator and a neutral element. Common operators are sum, min and max. Eventually processing unit pi stores the prefix sum ⊗i′<=imi′. In the case of the so-called exclusive prefix sum, processing unit pi stores the prefix sum ⊗i′<imi′. Some algorithms require to store the overall sum at each processing unit in addition to the prefix sums. For short messages, this can be achieved with a hypercube topology if p is a power of two. For long messages, the hypercube (Hypercube (communication pattern) § Prefix sum, Prefix sum § Distributed memory: Hypercube algorithm) topology is not suitable, since all processing units are active in every step and therefore pipelining can't be used. A binary tree topology is better suited for arbitrary p and long messages (Prefix sum § Large Message Sizes: Pipelined Binary Tree). Prefix-sum on a binary tree can be implemented with an upward and downward phase. In the upward phase reduction is performed, while the downward phase is similar to broadcast, where the prefix sums are computed by sending different data to the left and right children. With this approach pipelining is possible, because the operations are equal to reduction (§ Reduce) and broadcast (§ Broadcast). Pipelined prefix sum on a binary tree is possible in 𝒪(αlogp+βn).
Barrier
… excerpt ends here. Continue reading the full article.





