Barrier Synchronization is the parallel-computing primitive that blocks every participating thread or process at a synchronization point until all have arrived — guaranteeing that all preceding work is complete, and visible, before any thread proceeds, which makes it the backbone of phase-separated algorithms, iterative solvers, and collective communication.
A barrier's contract is simple: nobody crosses until everybody arrives. Beyond that ordering guarantee, a global barrier also acts as a memory fence, so every write issued before the barrier is visible to every read after it. Named or group barriers relax the first rule by synchronizing only a subset of threads, which cuts idle time when independent teams have no reason to wait on each other. A split-phase barrier separates the *arrive* signal from the *wait* block, letting a thread announce completion and then do useful independent work before it finally blocks. The simplest implementation, a counting barrier, tracks arrivals with a single atomic counter, but that shared counter becomes a contention hotspot as thread counts climb.
The implementation algorithms trade space against contention. A centralized barrier uses one shared counter that each arriving thread increments atomically; the last to arrive resets it and releases all waiters. It costs $O(1)$ space but suffers $O(P)$ contention on that counter, which serializes badly past a few dozen threads. A tree barrier arranges threads as the leaves of a binary or $k$-ary tree: each thread signals its parent, the signal reaches the root in $O(\log P)$ steps, and the release propagates back down, holding contention to $O(\log P)$ sequential atomic operations. A tournament barrier pairs threads in rounds like a bracket, combining reduction and broadcast in a single $O(\log P)$ traversal using only point-to-point communication. A butterfly barrier goes further: in round $k$, thread $i$ exchanges with thread $i \mathbin{\text{XOR}} 2^k$, so all threads finish simultaneously in $O(\log P)$ rounds with full all-to-all information exchange.
Barrier cost is dominated by the slowest arriver, not the mechanism. Barrier overhead, the span from the first arrival to the last departure, needs both fast notification and efficient wakeup; typical software barriers on multi-core CPUs run 1-10 microseconds. The deeper danger is load-imbalance amplification: because a barrier forces every fast thread to wait for the slowest, even a 1% imbalance repeated across thousands of barriers per iteration compounds into serious lost time. On NUMA machines, barrier variables touched by all threads generate cross-node coherence traffic, so NUMA-aware designs use per-node local barriers with a thin global coordination layer between node representatives. On GPUs, `__syncthreads()` is a hardware barrier within a single thread block that completes in essentially one cycle when all threads reach it together, but it cannot synchronize across blocks; that requires ending the kernel.
Read a barrier through a *slowest-arriver* lens rather than a *mechanism-overhead* lens: the clever tree or butterfly algorithm only shaves the notification cost, while the time actually lost at almost every barrier is the idle wait the straggler imposes on everyone else, which is why reducing load imbalance usually beats optimizing the barrier itself.