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.

Five small drawings of 16 nodes: a ring, a 4 by 4 mesh, a 4 by 4 torus with wraparound links, a 4-dimensional hypercube drawn as two linked cubes, and a fat tree with hosts at the bottom and three levels of switches. Under each: ring 16 links, diameter 8, bisection 2; mesh 24, 6, 4; torus 32, 4, 8; hypercube 32, 4, 8; fat tree 48, 6, 8.
More links buy fewer hops and a wider middle: the ring is cheapest, but its far side is 8 hops away and 2 cut links split it in half.

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.
NetworkLinksDegreeDiameterAvg hopsBisection
Ring16284.272
2D mesh 4×4242–462.674
2D torus 4×432442.138
Hypercube 4-D32442.138
Fat tree k = 4484 per switch65.478

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.

Left: a 4 by 4 mesh with the XY route from node 0 to node 15 in red, first along the top row 0, 1, 2, 3, then down the right column 7, 11, 15, 6 hops. Right: the e-cube route in the hypercube from 0011 to 1100 as a row of boxes 0011, 0010, 0000, 0100, 1100, with the flipped bit of each hop marked: bit 0, bit 1, bit 2, bit 3, 4 hops.
Both rules fix one dimension at a time: XY changes x, then y; e-cube changes bit 0, then bit 1, and so on, which gives a shortest path.

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).

Three columns. Two bits: 00, 01, 11, 10. Three bits: the same four with a 0 in front, then the four in reverse order with a 1 in front: 000, 001, 011, 010, 110, 111, 101, 100. Four bits: the 8 with 0 in front, then the 8 reversed with 1 in front, ending in 1000. Next to each column the flipped bit between neighbours is marked; every step flips exactly one bit.
Reflect the list and put a 1 in front: neighbours, including last and first, still differ in exactly one bit.

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:

NetworkLinksDiameterBisectionp = 1024: diameter / bisection
Ringpp / 22512 / 2
2D mesh √p × √p2(p − √p)2(√p − 1)√p62 / 32
2D torus √p × √p2p2⌊√p / 2⌋2√p32 / 64
Hypercube(p log₂ p) / 2log₂ pp / 210 / 512
Fat tree, 3 levels, k-port switches3p6p / 26 / 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.

On the mind map

Open the Computer Architecture mind mapComputerArchitectureAbstraction and numbers: layers and bit patternsAbstraction and numbersCombinational logic: output depends only on inputsCombinational logicSequential logic: state held by a clockSequential logicMIPS software: how C becomes machine wordsMIPS softwareThe processor: datapath plus controlThe processorPipelines and parallelism: more instructions at oncePipelines and parallelismMemory and I/O: small fast near, big slow farMemory and I/OMIPS pipelineMIPS pipelineforward data, stall on load-useBranch predictionBranch prediction2-bit counters guess, flush if wrongOut-of-order executionOut-of-order executionrenaming removes WAR and WAW hazardsSIMD, threads, multicoreSIMD, threads, multicoreAmdahl's law caps the speedupAmdahl vs GustafsonAmdahl vs Gustafsonfixed job caps at 1/s; scaled growsMPI Send/Recv & CollectivesMPI Send/Recv & CollectivesTrees: log₂ p rounds; Send may blockData-Parallel TrainingData-Parallel TrainingRing all-reduce keeps every copy equalJacobi halo exchangeJacobi halo exchangeGhost rows refreshed before every sweepInterconnect topologiesHypercube: hops = bits that differParallel Prefix SumParallel Prefix SumBlelloch: 2(n−1) work, 2 log n spanOpenMP loop schedulesOpenMP loop schedulesUneven costs: dynamic beats static blocksGPU and SIMT warpsGPU and SIMT warps32 lanes, one instruction; branches splitOpen the Computer Architecture mind mapComputer Architecturemore instructions at oncePipelines and parallelismMIPS pipelineMIPS pipelineforward data, stall on load-useBranch predictionBranch prediction2-bit counters guess, flush if wrongOut-of-order executionOut-of-order executionrenaming removes WAR and WAW hazardsSIMD, threads, multicoreSIMD, threads, multicoreAmdahl's law caps the speedupAmdahl vs GustafsonAmdahl vs Gustafsonfixed job caps at 1/s; scaled growsMPI Send/Recv & CollectivesMPI Send/Recv & CollectivesTrees: log₂ p rounds; Send may blockData-Parallel TrainingData-Parallel TrainingRing all-reduce keeps every copy equalJacobi halo exchangeJacobi halo exchangeGhost rows refreshed before every sweepInterconnect topologiesHypercube: hops = bits that differParallel Prefix SumParallel Prefix SumBlelloch: 2(n−1) work, 2 log n spanOpenMP loop schedulesOpenMP loop schedulesUneven costs: dynamic beats static blocksGPU and SIMT warpsGPU and SIMT warps32 lanes, one instruction; branches split
This page on the Computer Architecture mind map · 76 pages in 7 branches · open it to see the whole map and test yourself in recall mode.