ArticleslgStudy

computer science

Hypercube (communication pattern)

Hypercube (communication pattern) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Hypercube (communication pattern) rather than just read about it. In short: d-dimensional hypercube is a network topology for parallel computers with 2d processing elements. The topology allows for an efficient implementation of some basic communication primitives such as Broadcast, All-Reduce, and Prefix sum.

Hypercube (communication pattern) — main illustration
Hypercube (communication pattern) — illustration

Key takeaways

  • Hypercube (communication pattern) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Hypercube (communication pattern) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Hypercube (communication pattern) from memory before moving on to harder problems.

Reference excerpt

d-dimensional hypercube is a network topology for parallel computers with 2d processing elements. The topology allows for an efficient implementation of some basic communication primitives such as Broadcast, All-Reduce, and Prefix sum. The processing elements are numbered 0 through 2d−1. Each processing element is adjacent to processing elements whose numbers differ in one and only one bit. The algorithms described in this page utilize this structure efficiently.

Algorithm outline Most of the communication primitives presented in this article share a common template. Initially, each processing element possesses one message that must reach every other processing element during the course of the algorithm. The following pseudo code sketches the communication steps necessary. Hereby, Initialization, Operation, and Output are placeholders that depend on the given communication primitive (see next section).

Input: message m. Output: depends on Initialization, Operation and Output. Initialization s:=m for 0≤k<d do y:=i XOR 2k Send s to y Receive m from y Operation(s,m) endfor Output

Each processing element iterates over its neighbors (the expression i XOR 2k negates the k-th bit in i's binary representation, therefore obtaining the numbers of its neighbors). In each iteration, each processing element exchanges a message with the neighbor and processes the received message afterwards. The processing operation depends on the communication primitive.

Communication primitives

Prefix sum In the beginning of a prefix sum operation, each processing element i owns a message mi. The goal is to compute ⨁0≤j≤imj, where ⊕ is an associative operation. The following pseudo code describes the algorithm.

Input: message mi of processor i. Output: prefix sum ⨁0≤j≤imj of processor i. x:=mi σ:=mi for 0≤k≤d−1 do y:=i XOR 2k Send σ to y Receive m from y σ:=σ⊕m if bit k in i is set then x:=x⊕m endfor

The algorithm works as follows. Observe that hypercubes of dimension d can be split into two hypercubes of dimension d−1. Refer to the sub cube containing nodes with a leading 0 as the 0-sub cube and the sub cube consisting of nodes with a leading 1 as 1-sub cube. Once both sub cubes have calculated the prefix sum, the sum over all elements in the 0-sub cube has to be added to the every element in the 1-sub cube, since every processing element in the 0-sub cube has a lower rank than the processing elements in the 1-sub cube. The pseudo code stores the prefix sum in variable x and the sum over all nodes in a sub cube in variable σ. This makes it possible for all nodes in 1-sub cube to receive the sum over the 0-sub cube in every step. This results in a factor of log⁡p for Tstart and a factor of nlog⁡p for Tbyte: T(n,p)=(Tstart+nTbyte)log⁡p.

All-gather / all-reduce All-gather operations start with each processing element having a message mi. The goal of the operation is for each processing element to know the messages of all other processing elements, i.e. x:=m0⋅m1…mp where ⋅ is concatenation. The operation can be implemented following the algorithm template.

Input: message x:=mi at processing unit i. Output: all messages m1⋅m2…mp. x:=mi for 0≤k<d do y:=i XOR 2k Send x to y Receive x′ from y x:=x⋅x′ endfor

With each iteration, the transferred message doubles in length. This leads to a runtime of T(n,p)≈∑j=0d−1(Tstart+n⋅2jTbyte)=log⁡(p)Tstart+(p−1)nTbyte. The same principle can be applied to the all-reduce operations, but instead of concatenating the messages, it performs a reduction operation on the two messages. So it is a reduce operation, where all processing units know the result. Compared to a normal reduce operation followed by a broadcast, all-reduce in hypercubes reduces the number of communication steps.

All-to-all Here every processing element has a unique message for all other processing elements.

Input: message mij at processing element i to processing element j. for d>k≥0 do Receive from processing element i XOR 2k: all messages for my k-dimensional sub cube Send to processing element i XOR 2k: all messages for its k-dimensional sub cube endfor

With each iteration a messages comes closer to its destination by one dimension, if it hasn't arrived yet. Hence, all messages have reached their target after at most d=log⁡p steps. In every step, p/2 messages are sent: in the first iteration, half of the messages aren't meant for the own sub cube. In every following step, the sub cube is only half the size as before, but in the previous step exactly the same number of messages arrived from another processing element. This results in a run-time of T(n,p)≈log⁡p(Tstart+p2nTbyte).

ESBT-broadcast The ESBT-broadcast (Edge-disjoint Spanning Binomial Tree) algorithm is a pipelined broadcast algorithm with optimal runtime for clusters with hypercube network topology. The algorithm embeds d edge-disjoint binomial trees in the hypercube, such that each neighbor of processing element 0 is the root of a spanning binomial tree on 2d−1 nodes. To broadcast a message, the source node splits its message into k chunks of equal size and cyclically sends them to the roots of the binomial trees. Upon receiving a chunk, the binomial trees broadcast it.

Runtime In each step, the source node sends one of its k chunks to a binomial tree. Broadcasting the chunk within the binomial tree takes d steps. Thus, it takes k steps to distribute all chunks and additionally d steps until the last binomial tree broadcast has finished, resulting in k+d steps overall. Therefore, the runtime for a message of length n is T(n,p,k)=(nkTbyte+Tstart)(k+d). With the optimal chunk size k∗=nd⋅TbyteTstart, the optimal runtime of the algorithm is T∗(n,p)=n⋅Tbyte+log⁡(p)⋅Tstart+nlog⁡(p)⋅Tstart⋅Tbyte.

Construction of the binomial trees

This section describes how to construct the binomial trees systematically. First, construct a single binomial spanning tree von 2d nodes as follows. Number the nodes from 0 to 2d−1 and consider their binary representation. Then the children of each nodes are obtained by negating single leading zeroes. This results in a single binomial spanning tree. To obtain d edge-disjoint copies of the tree, translate and rotate the nodes: for the k-th copy of the tree, apply a XOR operation with 2k to each node. Subsequently, right-rotate all nodes by k digits. The resulting binomial trees are edge-disjoint and therefore fulfill the requirements for the ESBT-broadcasting algorithm.

… excerpt ends here. Continue reading the full article.

Illustrations

Hypercube (communication pattern): Example for a prefix sum calculation. Upper number: tentatetive prefix sum (variable x). Lower number: sum over all elements in the sub cube (variable σ).
Example for a prefix sum calculation. Upper number: tentatetive prefix sum (variable x). Lower number: sum over all elements in the sub cube (variable σ).
Hypercube (communication pattern): A 3-dimensional hypercubes with three ESBT embedded.
A 3-dimensional hypercubes with three ESBT embedded.

Worked examples

Example 1 — a first encounter with Hypercube (communication pattern)

Start with the simplest possible case. Write down what Hypercube (communication pattern) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Hypercube (communication pattern) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Hypercube (communication pattern) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Hypercube (communication pattern)

In research
Hypercube (communication pattern) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Hypercube (communication pattern) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Hypercube (communication pattern) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Parallel computing, so understanding it makes those chapters shorter.
In everyday life
Look for Hypercube (communication pattern) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Hypercube (communication pattern)” →

How to study Hypercube (communication pattern) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Hypercube (communication pattern) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Hypercube (communication pattern) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Hypercube (communication pattern) in simple terms?

d-dimensional hypercube is a network topology for parallel computers with 2d processing elements. The topology allows for an efficient implementation of some basic communication primitives such as Broadcast, All-Reduce, and Prefix sum.

Why does Hypercube (communication pattern) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Hypercube (communication pattern)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Hypercube (communication pattern).

Tags

  • Parallel computing

Keep exploring