AVX2
How it works
AVX2 operates on sixteen 256-bit YMM registers (in x86-64 mode), each holding e.g. 8 float32, 4 float64 or 32 int8 values. Unlike AVX, which limited integer operations to 128 bits, AVX2 extends most vector-integer instructions to the full 256 bits. The gather instruction loads vector elements from non-contiguous memory addresses (indexing by a vector of offsets), simplifying the vectorization of sparse accesses. DWORD/QWORD permutes and variable vector shifts add data-processing flexibility. The co-introduced FMA3 fuses a multiply and an add into one three-operand instruction (a โ a + bยทc), doubling effective floating-point throughput. In ML kernels, integer dot products are built from instructions such as VPMADDWD, which multiply pairs of 16-bit words and horizontally accumulate into 32-bit values โ a core building block of quantized GEMM in libraries like llama.cpp.
Problem solved
Numerical compute and ML model inference on CPU are limited by vector-unit throughput. AVX2 doubles the width of integer vectors (256 vs 128 bits), adds gather for efficient access to non-contiguous data and โ together with FMA3 โ multiply-accumulate in a single cycle, accelerating GEMM, dot products and neural-network layers without a dedicated accelerator.
Components
Sixteen 256-bit vector registers (in x86-64 mode) holding e.g. 8ร float32, 4ร float64 or 32ร int8; extension of the XMM/AVX registers to full integer-operation support.
Extension of most vector-integer SSE/AVX instructions from 128 to 256 bits โ the key AVX2 change over AVX (which stayed 128-bit for integers).
Three-operand fused multiply-add (a โ a + bยทc) in a single instruction. Formally a separate extension with its own CPUID flag, introduced by Intel in the same Haswell microarchitecture and usually considered together with AVX2.
Official
Loads vector elements from non-contiguous memory locations based on a vector of offsets โ simplifies vectorization of sparse or indexed data accesses.
DWORD/QWORD-granularity any-to-any permutes and variable-count vector shifts โ flexible shuffling and scaling of elements within a register.
Instruction that multiplies pairs of signed 16-bit words and horizontally accumulates into 32-bit values; in its VEX.256 (AVX2) form it is a core building block of integer dot products and quantized GEMM in ML inference kernels.
Evolution
Intel introduces AVX in the Sandy Bridge microarchitecture (Q1 2011): 256-bit YMM registers and VEX encoding, but integer operations remain 128-bit.
Intel introduces AVX2 ("Haswell New Instructions", Q2 2013): integer operations extended to 256 bits, gather, permutes and vector shifts; FMA3 appears in the same microarchitecture.
AMD adds AVX2 support in the Excavator microarchitecture (Q2 2015), and subsequently in the Zen family.
The first hardware implementation of AVX-512 (proposed by Intel in July 2013) widens SIMD vectors to 512 bits, succeeding AVX2.
Celeron- and Pentium-branded processors start supporting AVX2 from Tiger Lake (Q3 2020), completing the extension's broad availability across Intel CPUs.
Execution paradigm
SIMD: a single instruction operates densely on many data elements in a 256-bit YMM register (e.g. 8ร float32 or 32ร int8).
Parallelism
Data-level parallelism (SIMD) โ one instruction processes up to 8 float32 / 32 int8 at once within a CPU core.
Hardware requirements
AVX2 is an x86 instruction-set extension executed natively by CPU vector units (Intel since Haswell 2013, AMD since Excavator 2015).