SimplifyC++ Article

The Floating-Point Race — How the GPU Became the Engine of AI

By Ayman AlherakiReads: 12Today: 12

The NVIDIA H100 SXM has a published peak of approximately 67 TFLOP/s in FP32. Give it two large vectors and ask it to multiply the elements of one by a constant and add the results to the other, and its memory bandwidth imposes a theoretical ceiling of about 0.56 TFLOP/s, even under ideal data-transfer conditions. The processor and the precision are the same, yet the two theoretical ceilings differ by a factor of about 120. That gap helps explain how GPUs evolved. A specification sheet tells us how much arithmetic a chip can perform. The algorithm determines how much of that capacity the program can use. NVIDIA H100 specifications · The Roofline model, UC Berkeley

Floating-point arithmetic is central to understanding performance in graphics, scientific simulation, and artificial intelligence. All three involve substantial numerical work, with different requirements for precision, memory, and parallelism. In other programs, performance is governed by integer comparisons, branches, and data access. How we evaluate a processor depends on the work we want it to do.

1. What Does a Processor Do When It Performs Floating-Point Arithmetic?

Floating-point numbers are represented much like scientific notation, using base two. The three components of a normalized binary floating-point number are its sign, exponent, and significand. The exponent sets the scale, and the significand determines how much detail the representation can retain. FP32 has eight exponent bits and 23 stored fraction bits. With the implicit leading bit for normal numbers, the significand has 24 bits of precision. In FP64 it has 53. IEEE 754 specifies rounding rules and the handling of subnormal values, infinities, NaNs, and signed zeros. IEEE 754-2019 · Floating-point arithmetic under IEEE 754

The cost of this flexibility becomes apparent in addition. If the operands have different exponents, the arithmetic unit aligns their significands before adding or subtracting them. It then adjusts the result and rounds it to the target format. For multiplication, it adds the exponents and multiplies the significands before adjusting and rounding the result. The cost of these operations varies by architecture. A peak calculated from multiply and add instructions describes the throughput of those instructions. Division, square root, and functions such as sine and logarithm each have their own performance and accuracy characteristics. Floating-point addition, Carnegie Mellon University · CUDA arithmetic instruction throughput · Accuracy of mathematical functions

2. The Instruction at the Heart of Numerical Computing

The expression a × b + c appears in dot products, matrix multiplication, and polynomial evaluation. A fused multiply-add (FMA) computes the entire expression with one rounding step. If multiplication and addition are performed as separate FP32 instructions, the product is rounded first and the final result is rounded again. In performance calculations, an FMA counts as two floating-point operations per element because it performs a multiplication and an addition. Fused multiply-add and rounding

Take a = 1 + 2⁻²³, b = 1 − 2⁻²³, and c = −1. All three inputs are exactly representable in FP32. The exact product of a and b is 1 − 2⁻⁴⁶. With separate operations and round-to-nearest, the product rounds to 1, and the addition returns zero. With FMA, the subtraction happens before rounding, preserving the result −2⁻⁴⁶. This matters when subtracting nearly equal values, because intermediate rounding can erase the very difference we are trying to calculate.

3. How Do CPUs Speed Up Arithmetic?

Modern processors pipeline execution, and many cores can execute independent instructions out of order while preserving the behavior visible to the program. This gives rise to two distinct measures. Latency is the number of cycles before an instruction's result is ready to use. Throughput is the rate at which independent instructions can start or complete in steady state. In a loop that updates a single running sum, each step depends on the previous one. When the algorithm and its rounding rules allow the sum to be split into partial sums, the core can advance several independent chains at once. The Roofline model and architectural performance limits · LLVM floating-point reassociation rules

SIMD instructions add another layer of parallelism. On x86-64, a 256-bit vector FMA processes eight FP32 elements or four FP64 elements. With every lane active, that is 16 or 8 floating-point operations, respectively. A hypothetical core running at 3 GHz that can start two such instructions per cycle would have a theoretical peak of 96 GFLOP/s in FP32. How closely a real core approaches that rate depends on its design, the availability of independent instructions, and whether data arrives in time. Intel Intrinsics Guide

4. Why Do GPUs Excel When the Same Operation Runs Across Millions of Elements?

Early GPUs used fixed-function hardware to accelerate stages of 3D rendering. Programmable graphics stages followed, and platforms such as CUDA made GPU hardware available for general-purpose computing. The same property that made GPUs effective for rendering also proved valuable for simulation and matrix multiplication. These workloads contain many elements whose calculations can run in parallel. The evolution of GPU computing in the CUDA Programming Guide

NVIDIA hardware schedules threads in groups of 32 called warps, following the SIMT execution model. When one warp waits for data, the scheduler can issue instructions from another ready warp, hiding part of the memory latency. If threads within the same warp take different branches, the paths may run in succession, with threads outside the current path temporarily inactive. Memory addresses matter as well. When neighboring threads access adjacent, suitably aligned elements, the hardware can coalesce their requests into fewer memory transactions. The layout of the data directly affects the performance of the calculation. SIMT execution and branch divergence · Coalesced memory access

5. Why Does Memory Determine How Many Teraflops We Can Use?

The Roofline model describes performance in terms of two ceilings. The first is peak compute throughput for the numerical format and execution units in use. The second is memory bandwidth × arithmetic intensity. Here, arithmetic intensity is the number of floating-point operations performed per byte actually transferred to or from main memory. The lower of the two is the approximate performance ceiling. When a program reuses data in registers or caches, it performs more arithmetic per byte that travels through main memory. The original Roofline paper

That gives us the numbers from the opening example. Suppose we have two large FP32 vectors and compute y[i] = a × x[i] + y[i], with the constant held in a register. Each element takes two floating-point operations, one read from x, one read from y, and one write to y. Our optimistic estimate assumes 12 bytes of traffic per element and a large working set with no useful cache reuse. The intensity is therefore 2 ÷ 12 = ⅙ FLOP per byte. At the H100 SXM's published bandwidth of 3.35 TB/s, that yields 3.35 × ⅙ ≈ 0.56 TFLOP/s. The same model shows that the workload needs about 20 FLOPs per byte for the bandwidth ceiling to reach the FP32 compute peak of 67 TFLOP/s. These are theoretical estimates based on published bandwidth. Sustained bandwidth can be lower in practice. H100 SXM specifications · Measuring effective memory bandwidth in CUDA

Matrix multiplication offers much greater scope for reuse. A single input element can contribute to many output elements. An optimized kernel therefore loads tiles of the matrices into shared memory or registers and reuses them across a series of multiply-add operations. Increasing compute throughput can pay off here because each tile remains useful for many operations after it is loaded. Tiled matrix multiplication in the CUDA Best Practices Guide

Consider multiplying two square FP32 matrices of dimension N. The conventional operation count is approximately 2N³. If every input element is read once and every output element is written once, the ideal memory traffic is 12N² bytes, for an intensity of N ÷ 6 FLOPs per byte. At N = 1024, that ideal case amounts to about 171 FLOPs per byte. Actual intensity can be lower if some tiles have to be fetched more than once.

6. Tensor Cores Changed the Unit of Work the Hardware Performs

Tensor Cores specialize in operations such as D = A × B + C on small blocks of matrices. This fits operations at the heart of neural networks, such as matrix multiplication in linear layers. Some execution paths support mixed precision, representing inputs in a lower-precision format and accumulating the products in a higher-precision format such as FP32. Higher-precision accumulation preserves more detail as products are added together. The initial rounding of the inputs still contributes to the numerical error. PTX matrix multiply-accumulate instructions · How TF32 works

Format Exponent bits Fraction bits Practical implication
FP64 1152 Double precision for problems that require low numerical error
FP32 823 General-purpose single precision, also used for mixed-precision accumulation
TF32 810 NVIDIA Tensor Core computation format with FP32's exponent range and fewer fraction bits
FP16 510 Finer significand precision than BF16, with a narrower exponent range
BF16 87 The same exponent range as FP32, with fewer fraction bits

The table excludes the implicit leading bit of normal numbers from the fraction column. In the TF32 path described in NVIDIA's documentation, inputs can remain stored as FP32 and be rounded to TF32 for multiplication. Storing data in a 16-bit format reduces the number of bytes transferred when the data remains in that format during transfer. IEEE 754 · Floating-point formats and TF32 in NVIDIA Ampere

The H100 SXM specifications show how strongly the format and execution unit affect throughput. The published peaks are 34 TFLOP/s for general-purpose FP64, 67 TFLOP/s for Tensor Core FP64, and 67 TFLOP/s for general-purpose FP32. Tensor Core throughput for TF32 reaches 989 TFLOP/s under NVIDIA's supported structured sparsity conditions. Comparing the expected runtimes of two programs therefore requires knowing the input format, the operation, and whether the workload meets the sparsity requirement. H100 SXM peak performance specifications

The same specialization extends to FP8 formats. In NVIDIA's Hopper architecture, for example, E4M3 allocates four bits to the exponent and three to the fraction, while E5M2 allocates five to the exponent and two to the fraction. E4M3 distinguishes nearby values more finely within its range, while E5M2 covers a wider range. Even with eight bits, how those bits are allocated changes the representation error and the range of values the hardware can process. FP8 formats in NVIDIA Hopper

7. When Is It Worth Changing the Arithmetic for Speed?

Changing the order of floating-point addition can change the result. In FP32, with each addition rounded to nearest, (2³⁰ − 2³⁰) + 1 evaluates to 1, while 2³⁰ + (−2³⁰ + 1) evaluates to 0. The one is lost in the inner expression because it is too small relative to the distance between representable values at that magnitude. Compiler contraction into an FMA, regrouping additions in a parallel reduction, and using faster approximations for certain functions can all affect both the result and the runtime. A scientific application may require high precision only at particularly sensitive steps. In some iterative refinement methods for solving linear systems, much of the calculation can be performed in lower precision and the residual computed in higher precision, subject to numerical conditions that govern the method's success. LLVM floating-point rules · Carson and Higham on iterative refinement in three precisions

8. What Actually Measures Processor Efficiency?

Each of the following tests measures a different aspect of performance.

  • An FMA benchmark with register-resident inputs measures execution-unit throughput with independent accumulators. A chain in which each operation depends on its predecessor measures latency.
  • A streaming benchmark over large vectors measures the memory bandwidth the program can sustain, typically reported in gigabytes per second alongside the arithmetic rate.
  • An application benchmark measures the time required to produce a result within an acceptable error tolerance. When comparing a CPU and a GPU, it helps to measure both compute time and end-to-end time, including data transfers and synchronization when they occur in real use. For energy efficiency, the most direct measure is the energy in joules required to solve the problem within the same error tolerance. CUDA timing and bandwidth measurement · Performance analysis with Nsight Compute

The GPU became suitable for training large models because much of the work could be expressed as parallel matrix multiplication, and the execution units, memory system, and number formats evolved around that work. The same processor may spend most of its time waiting for memory in a far simpler program. After reading the teraflop rating, the question worth asking is how many useful operations can my program perform per byte it moves, at what precision, and in how many seconds?

Actual visitors 207,225
Visitors today 1,928
Total page views 1,926,645
Page views today 2,377
Book downloads 52,511