The idea: the same 16 computers, wired in different ways
A parallel computer is many processors that send each other messages. The wires between them form the interconnection network. You cannot link every processor to every other one: with 1024 processors that would be more than half a million links. So real machines use a pattern, a topology, where each node has a few links and messages travel over several links, or hops, to reach the far side.
The canvas draws one network at a time, always with 16 nodes numbered 0 to 15. The table on the right gives the five numbers for all five networks, and the row of the network on screen is blue. Route sends a message from one node to another and shows each hop. Cut in Half splits the nodes into two groups of 8 and counts the links that cross.
The five numbers
- Links: how many wires there are. This is most of the cost.
- Degree: links per node, so how many ports each node or switch needs.
- Diameter: the most hops any message needs, taking the shortest path. Each hop adds delay, so this is the worst-case latency.
- Average hops: the mean over all 16 × 15 = 240 ordered pairs. This is what a typical message pays.
- Bisection width: the fewest links you must cut to split the nodes into two halves of 8. When every node in one half sends to the other half at once, all that traffic squeezes through these links. A small bisection makes all-to-all work slow.
| Network | Links | Degree | Diameter | Avg hops | Bisection |
|---|---|---|---|---|---|
| Ring | 16 | 2 | 8 | 4.27 | 2 |
| 2D mesh 4×4 | 24 | 2–4 | 6 | 2.67 | 4 |
| 2D torus 4×4 | 32 | 4 | 4 | 2.13 | 8 |
| Hypercube 4-D | 32 | 4 | 4 | 2.13 | 8 |
| Fat tree k = 4 | 48 | 4 per switch | 6 | 5.47 | 8 |
The ring is the cheapest, but node 0 needs 8 hops to reach node 8 (Demo 1), and cutting 2 links splits it in half (Demo 6). The mesh adds links in a grid: corner to corner is 3 + 3 = 6 hops (Demo 2), and one link per row crosses the middle, so its bisection is 4. The fat tree has the most links and is the only one here with switches; its hop count includes the two links between hosts and their switches.
Routing: XY on a mesh, wraparound on a torus
A router must pick the next link quickly, from the destination address alone. On a mesh, node number 4y + x sits at column x and row y. XY routing (dimension-order routing) first moves along x until the column is right, then along y. From node 0 at (0,0) to node 15 at (3,3) that is 0 → 1 → 2 → 3, then 3 → 7 → 11 → 15: 6 hops, the shortest possible (Demo 2). Because every message turns from x to y and never back, the paths cannot form a loop of messages waiting on each other, which is why real meshes use it.
A torus is a mesh with a wraparound link at the end of every row and column, so each row and column is a ring of 4. The page draws each wraparound link as two short stubs labelled with the node at the other end: a message leaves on one side and comes back in on the other. XY routing still works, but in each dimension it goes the shorter way round. From 0 to 15 it goes left from x = 0 to x = 3 over one wraparound link, then up from y = 0 to y = 3 over another: 2 hops instead of 6 (Demo 3). The wraparound links also double the bisection, from 4 to 8, because each row now crosses the middle twice.
The hypercube and e-cube routing
In a hypercube with 16 = 24 nodes, each node has a 4-bit number, and two nodes are linked exactly when their numbers differ in one bit. So each node has 4 links, one per bit, and 16 × 4 / 2 = 32 links in all. On the canvas each bit has its own colour. A 4-D cube is two 3-D cubes whose matching corners are joined by the bit-3 links.
The number of hops between two nodes is the number of bits in which they differ. E-cube routing finds them with XOR: 0011 XOR 1100 = 1111, so all four bits differ. It flips them in a fixed order, bit 0 first: 0011 → 0010 → 0000 → 0100 → 1100, 4 hops, which is the diameter (Demo 4). Like XY routing, the fixed order keeps the paths free of waiting loops. The hypercube's numbers match the torus's because, for 16 nodes, they are the same network: a ring of 4 is also a square, a 2-D cube, so a 4 × 4 torus is a 2-D cube times a 2-D cube, which is a 4-D cube. They part ways as the machine grows: the torus keeps 4 links per node, while the hypercube needs log₂ p.
The same bit pattern shows up in software: MPI's recursive doubling has rank r exchange with rank r XOR 1, then r XOR 2, then r XOR 4, which are exactly the hypercube's links.
A ring inside the hypercube: Gray codes
Many programs pass data around a ring: node i to node i + 1. On a hypercube, node 1 (0001) and node 2 (0010) are 2 hops apart, so the plain order is slow. A Gray code fixes this by listing the 16 numbers so that each one differs from the next in one bit. Build it by reflecting: start with 0, 1; write the list backwards with a new 1 bit in front, giving 0, 1, 3, 2; do it again: 0, 1, 3, 2, 6, 7, 5, 4; and again for all 16: 0, 1, 3, 2, 6, 7, 5, 4, 12, 13, 15, 14, 10, 11, 9, 8. The last, 8 = 1000, also differs from 0 in one bit, so the list closes into a ring. Every ring link is one hypercube link, which is called an embedding with dilation 1 (Demo 5).
The fat tree
The other networks are direct: every node is also a router. A fat tree is indirect: the 16 hosts hang below a tree of switches. In a plain tree the links near the top would carry everyone's traffic and become the bottleneck. A fat tree makes them "fatter" by adding parallel links and switches, so each switch has as many links going up as going down. The page uses the k = 4 fat tree used in data centres (Al-Fares and others): 4 pods, each with 2 edge switches and 2 aggregation switches, and 4 core switches on top; every switch has 4 ports, and there are 48 links.
A message goes up only as far as it must: 2 hops to a host on the same edge switch, 4 inside the pod, 6 through a core switch to another pod. Going up, there are several equally short paths. The page chooses the up links from the destination's number (aggregation switch d mod 2, then core switch 2 × (d mod 2) + (d/2 mod 2)), so traffic to different hosts spreads over all 4 cores. From host 0 to host 15: 0 → e0 → a1 → c3 → a7 → e7 → 15 (Demo 7). The fat tree's average hop count (5.47) is the highest here, but its bisection is full: 8 links for 16 hosts, so any 8 hosts can send to the other 8 at once.
Growing to 1024 nodes
The differences grow with the machine. With p nodes:
| Network | Links | Diameter | Bisection | p = 1024: diameter / bisection |
|---|---|---|---|---|
| Ring | p | p / 2 | 2 | 512 / 2 |
| 2D mesh √p × √p | 2(p − √p) | 2(√p − 1) | √p | 62 / 32 |
| 2D torus √p × √p | 2p | 2⌊√p / 2⌋ | 2√p | 32 / 64 |
| Hypercube | (p log₂ p) / 2 | log₂ p | p / 2 | 10 / 512 |
| Fat tree, 3 levels, k-port switches | 3p | 6 | p / 2 | 6 / 512 (k = 16) |
The hypercube and the fat tree keep the hop count small and the bisection at p / 2, but the hypercube needs 10 ports per node at p = 1024 and the fat tree needs 320 switches. Meshes and tori keep 4 ports per node and short wires that fit on a chip or a board, which is why many-core chips and several supercomputers use them. The speedup such a machine can reach with a fixed amount of communication is the subject of Amdahl's and Gustafson's laws, and the processors themselves are on Parallel Hardware. Sorting networks use the word "network" for something else, a fixed pattern of compare-exchange steps; in bitonic sort each step pairs positions that differ in one bit, so it maps onto hypercube links.
See also Jacobi with Halo Exchange, where 2D blocks of a grid swap edges only with their mesh neighbours.
See also AMBA Buses for the buses inside a single chip, drawn clock by clock.
See also On-Chip Interconnect, where a 2×2 mesh with XY routing and wormhole flits connects the blocks inside one chip and is compared with a bus and a crossbar.
What the page leaves out
Hops are not the whole cost. A message's time is roughly a start-up cost, plus a small delay per hop, plus its size divided by the link bandwidth; with cut-through or wormhole switching the packet streams through the routers, so the hop count matters less than with store-and-forward. The page sends one message at a time, so there is no contention (two messages wanting the same link) and no deadlock; real tori need virtual channels to stop messages on wraparound rings waiting on each other in a circle. Left out: adaptive routing, which picks a less busy link; 3-D and higher tori (k-ary n-cubes), dragonflies and butterflies; dynamic networks such as buses and crossbars; and the many other ways to embed one network in another (meshes in hypercubes, trees in meshes). The fat tree here is the switch-based data-centre kind; Leiserson's original fat tree is a binary tree whose links get wider towards the root.