Skip to content

Function Reference & Implementation Directory

This section contains complete API reference documentation, mathematical semantics, test specifications, and architecture acceleration matrices for all MIPP functions.

MIPP API Explorer

Search across all 197 primitives, perform reverse lookup on vendor hardware intrinsics (AVX, NEON, RVV, SVE), filter by guaranteed acceleration levels, and switch between the C, C++ Functional and C++ Object APIs in the MIPP API Explorer.

Implementation Levels & Acceleration Legend

Every MIPP function is resolved against a 4-level hierarchy (details and examples in Implementation Levels):

Badge Implementation Level Meaning
L0 Level 0 (Native Hardware) A single hardware instruction (vendor intrinsic) for this datatype and variant; the constants it uses do not count.
L1 Level 1 (Dedicated Emulation) A sequence of intrinsics written for this ISA, where no single instruction does the job.
L2 Level 2 (Generic Emulation) Generic code shared by the ISAs, built on other MIPP functions (in a few cases a loop over the lanes, or the identity).
L3 Level 3 (Scalar Fallback) The registers are copied to the scalar target, which computes the elements one by one.
− N/A (Not Applicable) Operation is not defined for this element datatype or masking variant.

Documentation Structure for Each Function

Each function reference page provides:

  1. Description & Semantics: Mathematical operation and vector execution behavior.
  2. Prototypes: C, C++ Functional and C++ Object API signatures across all LMUL ratios.
  3. Headers: Includes of each API, from the whole library down to one function.
  4. Supported Datatypes & Mask Execution Variants: Supported element types and masking execution modes.
  5. ISA & Variant Support Matrix: Per-architecture hardware capability breakdown across masking variants.
  6. Reference Algorithm: Scalar C reference implementation demonstrating exact arithmetic and masking semantics.
  7. Test & Verification Specifications: Values drawn by the unit tests and comparison with the scalar reference.

Function Directory by Category

Arithmetic

  • absdiff: Absolute difference of two registers element-wise, \(|a - b|\), without the overflow of \(a - b\) for the unsigned types. For the signed integers the result is \(|a - b|\) modulo \(2^n\): read as the unsigned type of the same size, it is exact (absdiff of -128 and 127 in int8 gives -1, that is 255).
  • add: Adds two vector registers element-wise. The integer additions wrap around (modulo \(2^n\): 100 + 100 is -56 in int8); adds saturates instead. Scalar forms: vs.
  • adds: Adds two integer vector registers element-wise with saturation to [MIN, MAX] on underflow/overflow. Scalar forms: vs.
  • avg: Average of two integer registers element-wise, rounded up: \((a + b + 1) \gg 1\), computed without overflow (pavgb of x86, vrhadd of NEON). For the signed types the rounding is toward \(+\infty\): the average of -1 and -2 is -1.
  • sub: Subtracts the second vector register from the first element-wise. The integer subtractions wrap around (modulo \(2^n\)); subs saturates instead. Scalar forms: vs, sv.
  • subs: Subtracts two integer vector registers element-wise with saturation to [MIN, MAX] on underflow/overflow. Scalar forms: vs, sv.
  • mul: Multiplies two vector registers element-wise. The integer multiplications keep the low bits of the product (modulo \(2^n\)). Scalar forms: vs.
  • mulhi: Multiplies two integer registers element-wise and returns the upper half of each product, of \(2n\) bits: \((a \cdot b) \gg n\), with \(n\) the number of bits of the type (the lower half is mul). The product is signed for the signed types, unsigned for the unsigned ones. It is the multiplication of the fixed-point formats and of the division by a constant.
  • wmul: Widening multiplication: the product of two registers element-wise, in the type twice as wide, so without overflow nor rounding (int16 x int16 gives the exact int32 product, float32 x float32 the exact float64 one); the result has the next LMUL up, as wcvt. It is mul(wcvt(a), wcvt(b)), in a single instruction on RVV (vwmul, vfwmul), and in one vmull per half of the result on NEON for the integer types.
  • wpadd: Adds the neighbors two by two into the integer type twice as wide: \(\text{res}_i = vd0_{2i} + vd0_{2i+1}\), without overflow (int8 to int16, int16 to int32, int32 to int64, and the same for the unsigned types). The result has the same size, so the same LMUL, and half the lanes. It is the first step of the horizontal sums of narrow types (histograms, sums of bytes), and with absdiff the sum of absolute differences of the motion estimation (wpadd(wpadd(wpadd(absdiff(a, b)))) sums 8 bytes into 64 bits, as psadbw). Native on NEON (vpaddl) and SVE2 (sadalp / uadalp); on x86, pmaddwd (int16) and pmaddubsw (8-bit types, SSSE3) with a register of ones; elsewhere a reinterpretation, a mask or a shift, and an addition.
  • dot2: Dot products of pairs of 16-bit elements accumulated in 32 bits: each 32-bit lane \(i\) of the accumulator vd0 receives \(a_{2i} b_{2i} + a_{2i+1} b_{2i+1}\), the products of the two 16-bit lanes of vd1 and vd2 at the same place (the registers have the same size: the accumulator has half as many lanes). Computed modulo \(2^{32}\), without saturation. On x86: vpdpwssd (int16) with AVX-512 VNNI (and VL on 256 bits) or AVX-VNNI, vpdpwuud (uint16) with AVX-VNNI-INT16 or AVX10.2 (also on 512 bits), pmaddwd then an addition otherwise (int16); on AArch64, vmull and vpaddq; elsewhere, the two 16-bit halves of each 32-bit lane extended, multiplied and added.
  • dot4: Dot products of groups of four 8-bit elements accumulated in 32 bits: each 32-bit lane \(i\) of the accumulator vd0 receives \(\sum_{k=0}^{3} a_{4i+k} b_{4i+k}\), the products of the four 8-bit lanes of vd1 and vd2 at the same place (the registers have the same size: the accumulator has four times fewer lanes). Both operands are signed (int8 to int32) or both unsigned (uint8 to uint32); dot4us mixes an unsigned and a signed operand. Computed modulo \(2^{32}\), without saturation. Native on NEON with the dot product extension (sdot / udot, ARMv8.4 and the Apple chips), on SVE, and on x86 with AVX-VNNI-INT8 (vpdpbssd / vpdpbuud, 256 bits) or AVX10.2 (256 and 512 bits); with AVX-512 VNNI or AVX-VNNI, two vpdpbusd (the product of unsigned by signed bytes, with an operand shifted by 128 and the correction of its sum); two pmaddwd on the even and odd bytes otherwise (SSE2, AVX2, AVX-512 BW); elsewhere (as NEON without the extension and RVV), the four bytes of each 32-bit lane extended, multiplied and added.
  • dot4us: dot4 with an unsigned operand vd1 (uint8) and a signed operand vd2 (int8), accumulated in int32: the form of the quantized neural networks (unsigned activations, signed weights), and the only 8-bit dot product of the AVX-512 VNNI and AVX-VNNI extensions of x86 (vpdpbusd). Computed modulo \(2^{32}\), without saturation.
  • div: Divides the first vector register by the second element-wise. On 32-bit ARM NEON (ARMv7, float32; AArch64 has the division), the division is a reciprocal estimate refined by two Newton-Raphson steps, then a multiplication: the last bits can differ from an IEEE division. Scalar forms: vs, sv.
  • div2: Divides each element of a vector register by 2 (a right shift for the integers, arithmetic for the signed types and logical for the unsigned ones; a division for the floating-point types). For the negative integers the shift rounds toward \(-\infty\), where the C division rounds toward zero: -7 gives -4, not -3.
  • div4: Divides each element of a vector register by 4 (a right shift for the integers, arithmetic for the signed types and logical for the unsigned ones; a division for the floating-point types). For the negative integers the shift rounds toward \(-\infty\), where the C division rounds toward zero: -7 gives -2, not -1.
  • fmadd: Computes the fused multiply-add of three vector registers (\(a \times b + c\)). The operation is fused (a single rounding) on the targets that have the instruction. Without it (SSE and AVX without FMA, ARMv7 NEON without VFPv4 for float32, and the scalar target depending on the compiler) the product is rounded before the addition, and the last bits of the result can differ. In int32, the product and the sum wrap around (modulo \(2^{32}\)). Scalar forms: vsv, vvs.
  • fmsub: Computes the fused multiply-subtract of three vector registers (\(a \times b - c\)). The operation is fused (a single rounding) on the targets that have the instruction. Without it (SSE and AVX without FMA, ARMv7 NEON without VFPv4 for float32, and the scalar target depending on the compiler) the product is rounded before the addition, and the last bits of the result can differ. In int32, the product and the sum wrap around (modulo \(2^{32}\)). Scalar forms: vsv, vvs.
  • fnmadd: Computes the fused negative multiply-add of three vector registers (\(-(a \times b) + c\)). The operation is fused (a single rounding) on the targets that have the instruction. Without it (SSE and AVX without FMA, ARMv7 NEON without VFPv4 for float32, and the scalar target depending on the compiler) the product is rounded before the addition, and the last bits of the result can differ. In int32, the product and the sum wrap around (modulo \(2^{32}\)). Scalar forms: vsv, vvs.
  • fnmsub: Computes the fused negative multiply-subtract of three vector registers (\(-(a \times b) - c\)). The operation is fused (a single rounding) on the targets that have the instruction. Without it (SSE and AVX without FMA, ARMv7 NEON without VFPv4 for float32, and the scalar target depending on the compiler) the product is rounded before the addition, and the last bits of the result can differ. In int32, the product and the sum wrap around (modulo \(2^{32}\)). Scalar forms: vsv, vvs.

Combine

  • lo: Returns the lower half of a vector register as a register of the LMUL below (m2 to m1, m1 to d2, ...).
  • lo_k: Returns the lower half of a mask register as a mask of the LMUL below (m2 to m1, m1 to d2, ...).
  • hi: Returns the upper half of a vector register as a register of the LMUL below (m2 to m1, m1 to d2, ...).
  • hi_k: Returns the upper half of a mask register as a mask of the LMUL below (m2 to m1, m1 to d2, ...).
  • combine: Joins two vector registers into a register of the LMUL above (d2 to m1, m1 to m2, ...): the first one gives the lower half, the second one the upper half.
  • combine_k: Joins two mask registers into a mask of the LMUL above (d2 to m1, m1 to m2, ...): the first one gives the lower half, the second one the upper half.

Comparison

  • cmpeq: Compares two vector registers element-wise for equality (\(a = b\)). False when one of the two elements is NaN. Scalar forms: vs.
  • cmpneq: Compares two vector registers element-wise for inequality (\(a \ne b\)). True when one of the two elements is NaN. Scalar forms: vs.
  • cmple: Compares two vector registers element-wise for less-than-or-equal (\(a \le b\)). False when one of the two elements is NaN. Scalar forms: vs, sv.
  • cmplt: Compares two vector registers element-wise for less-than (\(a < b\)). False when one of the two elements is NaN. Scalar forms: vs, sv.
  • cmpge: Compares two vector registers element-wise for greater-than-or-equal (\(a \ge b\)). False when one of the two elements is NaN. Scalar forms: vs, sv.
  • cmpgt: Compares two vector registers element-wise for greater-than (\(a > b\)). False when one of the two elements is NaN. Scalar forms: vs, sv.
  • isfinite: Returns the mask of the elements that are finite: neither infinite nor NaN. Zeros and subnormal values are finite.
  • isinf: Returns the mask of the elements that are infinite, \(+\infty\) or \(-\infty\).
  • isnan: Returns the mask of the elements that are NaN (quiet or signaling, of either sign).
  • signbit: Returns the mask of the elements whose sign bit is set: the negative values, and for the floating-point types also -0.0 and the NaN with a negative sign.

Complex

  • cmul: Complex product of the complex numbers (re, im) of the pairs of lanes of the two registers (interleaved layout: the real part in the even lane, the imaginary part in the odd lane).
  • cmulconj: Complex product of the complex numbers of vd0 by the conjugates of the complex numbers of vd1 (interleaved layout).
  • cfmadd: Complex fused multiply-add: vd0 * vd1 + vd2, with complex numbers in the interleaved layout.
  • conj: Complex conjugate: the imaginary parts (odd lanes) negated (interleaved layout).
  • cnorm: Squared modulus of the complex numbers (interleaved layout), in both lanes of each pair.
  • cabs: Modulus of the complex numbers (interleaved layout), in both lanes of each pair, without intermediate overflow: computed as \(m \sqrt{(a_r/m)^2 + (a_i/m)^2}\) with \(m\) the largest absolute value of the two parts.
  • cdiv: Complex division of the complex numbers of vd0 by the ones of vd1 (interleaved layout), with the algorithm of Smith: the division by the part of the largest absolute value avoids the overflows and the losses of \(b_r^2 + b_i^2\).

Convert

  • cvt: Converts elements of a vector register to another datatype with numerical casting. A floating-point element converted to an integer is truncated toward zero, as a C cast: 2.7 gives 2 (cvtround, cvtroundeven, cvtfloor and cvtceil round instead). An integer without an exact floating-point representation is rounded to the nearest one. The conversion to an integer of a NaN, or of a value out of the range of the destination, gives a result that depends on the target.
  • cvtceil: Converts the floating-point elements to integers of the same size, rounded toward plus infinity: 2.1 gives 3, -2.9 gives -2, as cvt(ceil(vd0)). The result is exactly the one of cvt applied to the rounded register, in one instruction on AVX-512 (AVX-512 DQ for float64), NEON from ARMv8 (float64 on AArch64) and RVV; elsewhere (SSE, AVX, SVE), the rounding then the conversion. The conversion of a NaN, or of a value whose rounding is out of the range of the destination, gives a result that depends on the target.
  • cvtfloor: Converts the floating-point elements to integers of the same size, rounded toward minus infinity: 2.9 gives 2, -2.1 gives -3, as cvt(floor(vd0)). The result is exactly the one of cvt applied to the rounded register, in one instruction on AVX-512 (AVX-512 DQ for float64), NEON from ARMv8 (float64 on AArch64) and RVV; elsewhere (SSE, AVX, SVE), the rounding then the conversion. The conversion of a NaN, or of a value whose rounding is out of the range of the destination, gives a result that depends on the target.
  • cvtround: Converts the floating-point elements to integers of the same size, rounded to the nearest integer with the ties away from zero: 2.5 gives 3, -2.5 gives -3, as cvt(round(vd0)). The result is exactly the one of cvt applied to the rounded register, in one instruction on NEON from ARMv8 (vcvta; float64 on AArch64) and RVV (vfcvt in the rounding mode rmm); elsewhere (SSE, AVX, AVX-512, which has no rounding of the ties away from zero, and SVE), the rounding then the conversion. The conversion of a NaN, or of a value whose rounding is out of the range of the destination, gives a result that depends on the target.
  • cvtroundeven: Converts the floating-point elements to integers of the same size, rounded to the nearest integer with the ties to the even neighbor: 2.5 gives 2, 3.5 gives 4, as cvt(roundeven(vd0)). The result is exactly the one of cvt applied to the rounded register, in one instruction on AVX-512 (AVX-512 DQ for float64), NEON from ARMv8 (float64 on AArch64), RVV, and on SSE and AVX for float32 to int32 (cvtps2dq, which rounds with the rounding mode of the environment, MXCSR, to the nearest even by default); elsewhere, the rounding then the conversion. The conversion of a NaN, or of a value whose rounding is out of the range of the destination, gives a result that depends on the target.
  • ncvt: Narrowing conversion: converts each element to the type twice as narrow, keeping the lanes in a register one LMUL below. The integers keep their low bits (modulo \(2^n\): 70000 gives 4464 in int16), without saturation (ncvts saturates). A float64 is rounded to the nearest float32, and a value out of its range gives \(\pm\infty\).
  • ncvts: Converts each integer element to the type twice as narrow with saturation to its range; the result has the next LMUL down.
  • ncvtsrshiftround: Shifts each element right by s0 bits with a rounding to the nearest (ties up), then converts it to the integer type of half the size with a saturation: ncvts(rshiftround(vd0, s0)) in one operation, the requantization of the fixed-point arithmetic and of the quantized neural networks (an int32 accumulator scaled down to int16, an int16 to int8). The result has half the LMUL of the argument, as ncvts. Counts from 0 to the number of bits of the source type minus 1. One instruction on RVV (vnclip in the rounding mode rnu), two on NEON (vrshl, then vqmovn); the shift then the narrowing elsewhere.
  • wcvt: Widening conversion: converts each element to the type twice as wide (int8 to int16, ..., uint32 to uint64, float32 to float64), exactly (sign or zero extension for the integers); the result has the next LMUL up (the inverse of ncvt).

Load

  • firstn: Returns the mask of the first \(n\) lanes: the lane \(i\) is active when \(i < n\). No lane is active for \(n \le 0\), every lane for \(n \ge N\). It is the mask of the last iteration of a loop: firstn(len - i).
  • iota: Returns the sequence that starts at s0: the lane \(i\) holds \(s_0 + i\) (iota(2) gives \(2, 3, 4, \ldots\)), as std::iota. For the integers the sequence wraps around modulo \(2^n\) (beyond 127 for int8 from 0).
  • load: Loads elements from an aligned memory address into a vector register. The masked variants read only the memory of the active lanes: the memory of the inactive lanes can be out of bounds (the tail of an array).
  • loadu: Loads elements from an unaligned memory address into a vector register. The masked variants read only the memory of the active lanes: the memory of the inactive lanes can be out of bounds (the tail of an array).
  • set: Initializes a vector register from a scalar array.
  • set_k: Initializes a mask register from one value per lane: an array of int32_t in C (a lane is active when its value is not 0), of bool in the C++ APIs.
  • set1: Broadcasts a single scalar value to all elements of a vector register.
  • set1_k: Broadcasts a boolean to all elements of a mask register: an int32_t in C (active when not 0), a bool in the C++ APIs.
  • set0: Initializes a vector register with all zeros.
  • set0_k: Clears all elements of a mask register (all inactive).
  • gather: Loads elements from non-contiguous memory locations into a vector register using an index vector (unsigned indices counted in elements, of the width of the data or 32/64-bit: then at their own LMUL; 32-bit indices lower than \(2^{31}\), and than \(2^{30}\) on RVV for 32-bit data). The masked variants read only the elements of the active lanes: the index of an inactive lane is not used.
  • loadu_expand: Loads as many elements from p0 (no alignment required) as there are active lanes (mask vm0) and puts them in the active lanes, in order; the inactive lanes are zero. Only these elements are read.
  • loadu_ff: First-faulting load: loads the lanes from p0 that can be read without a fault and writes their number n to *s0 (when s0 is not null: NULL in C, nullptr by default in C++). On every target, at least the first lane is read (p0 must be accessible, as for any load), the next lanes never fault, \(1 \le n \le N\), and the lanes after the first n are unspecified. n says how far the load could go without risk, not where the data ends: it can be lower than N while the memory after is readable. It reads a buffer whose length is unknown and whose end is marked in the data (the 0 of a string, a sentinel): the loop looks for the sentinel in the n lanes; when it is not there, the buffer goes on, so p0 + n is accessible and the loop continues from there. Native on RVV (vle<n>ff) and SVE (ldff1 and the first-fault register): in practice the lanes up to the first one that would fault, though both architectures allow a core to stop earlier. Elsewhere, the lanes up to the end of the page of p0, of MIPP_PAGE_SIZE bytes (4096 by default, which can be raised to the page size of the machine, e.g. -DMIPP_PAGE_SIZE=16384 on Apple Silicon): a load that crosses a page boundary is cut there, even when the next page is readable. For a pointer aligned on the size of its elements, this happens at most once per traversal: the next load starts at the beginning of a page, and the following ones never straddle two pages.
  • loadu_unzip: Loads \(N\) elements (no alignment required) and separates the even and the odd ones: the even elements in the lower half of the register, the odd ones in the upper half (unzip(loadu(p0)); with LMUL 2, the two LMUL 1 halves are the even and the odd elements of \(2N\) elements, as ARM vld2).
  • loadu_unzip2: Loads \(N\) structures of 2 fields (\(2N\) elements, no alignment required; complex numbers, (x, y) points) and separates the fields: vd0 and vd1 receive the fields 0 and 1, the lane \(i\) of vd{k} being the element \(2i + k\) (array of structures to structure of arrays, the inverse of storeu_zip2). The registers are written through pointers in C and references in C++. loadu_unzip does the same in a single register (the two fields in its two halves). Native on NEON (vld2q), SVE (svld2) and RVV (vlseg2e; at LMUL 8, a strided load vlse per field); elsewhere, two loads then unziplo and unziphi.
  • loadu_unzip3: Loads \(N\) structures of 3 fields (\(3N\) elements, no alignment required; RGB pixels, xyz points) and separates the fields: vd0, vd1 and vd2 receive the fields 0 to 2, the lane \(i\) of vd{k} being the element \(3i + k\) (array of structures to structure of arrays, the inverse of storeu_zip3). The registers are written through pointers in C and references in C++. Native on NEON (vld3q), SVE (svld3) and RVV (vlseg3e; from LMUL 4, a strided load vlse per field); gathers elsewhere.
  • loadu_unzip4: Loads \(N\) structures of 4 fields (\(4N\) elements, no alignment required; RGBA pixels) and separates the fields: vd0, vd1, vd2 and vd3 receive the fields 0 to 3, the lane \(i\) of vd{k} being the element \(4i + k\) (array of structures to structure of arrays, the inverse of storeu_zip4). The registers are written through pointers in C and references in C++. Native on NEON (vld4q), SVE (svld4) and RVV (vlseg4e; from LMUL 4, a strided load vlse per field); gathers elsewhere.
  • loadu_strided: Loads a register from memory with a constant stride: the lane i is the element p0[i * s0], s0 a number of elements, from 0 (every lane gets p0[0]) to any positive value (s0 = 1 is loadu); the negative strides are undefined behavior. The elements between the lanes and after the last one are not accessed, except as follows. Native on RVV (vlse). Elsewhere: s0 = 1 is a loadu; s0 = 2, 3 and 4 are the field 0 of loadu_unzip2 / 3 / 4 (contiguous loads, then the lanes of the field: vld2q / vld3q / vld4q on NEON, ld2 / ld3 / ld4 on SVE), when the s0 - 1 elements read after the last lane are in the same page as it (MIPP_PAGE_SIZE bytes, 4096 by default), so that they cannot fault (a memory checker such as ASan may report them); the other strides, or a last lane near the end of a page, use a gather for the 32-bit and 64-bit types (the indices i * s0, which must stay below \(2^{31}\), in a register of unsigned integers) and an element by element copy for the 8-bit and 16-bit types. With a constant stride, the choice is made at compile time. A field of an array of structures is loadu_strided with the size of the structure as stride (loadu_unzip2 to loadu_unzip4 read every field of 2 to 4 at once).

Logic

  • andb: Computes the bitwise AND of two vector registers. Scalar forms: vs.
  • andb_k: Computes the bitwise AND of two mask registers.
  • andnb: Computes the bitwise AND-NOT of two vector registers (~a & b). Scalar forms: vs, sv.
  • andnb_k: Computes the bitwise AND-NOT of two mask registers (~vm0 & vm1).
  • byteswap: Reverses the order of the bytes of each integer element (endianness conversion, as std::byteswap of C++23). The 8-bit elements are unchanged.
  • clz: Counts the leading zero bits of each integer element, from the most significant bit: \(n\) for 0, 0 for the negative values. The count is returned in an element of the same type.
  • ctz: Counts the trailing zero bits of each integer element, from the least significant bit: \(n\) for 0. The count is returned in an element of the same type.
  • orb: Computes the bitwise OR of two vector registers. Scalar forms: vs.
  • orb_k: Computes the bitwise OR of two mask registers.
  • popcount: Counts the bits set to 1 in each integer element (population count). The count is returned in an element of the same type.
  • rotl: Rotates the bits of each integer element left by the number of bits of the same lane of the second register: the bits that leave on the left enter on the right. The count is taken modulo the number of bits \(n\) of the type. Not to be confused with rotate, which rotates the lanes of a register. Scalar forms: vs.
  • rotr: Rotates the bits of each integer element right by the number of bits of the same lane of the second register: the bits that leave on the right enter on the left. The count is taken modulo the number of bits \(n\) of the type. Not to be confused with rotate, which rotates the lanes of a register. Scalar forms: vs.
  • xorb: Computes the bitwise XOR of two vector registers. Scalar forms: vs.
  • xorb_k: Computes the bitwise XOR of two mask registers.
  • msb: Masks out all bits except the most significant bit (sign bit) for each vector element.
  • notb: Computes the bitwise NOT (inversion) of a vector register.
  • notb_k: Computes the bitwise NOT (inversion) of a mask register.
  • lshift: Shifts each element left by the number of bits of the same lane of the second register (from 0 to the number of bits of the type minus 1; any other count is undefined behavior). The shift by the same count for every lane is lshift_vs (mipp::lshift(vd0, s0) in C++). lshift_vs also accepts the floating-point types: their bits are shifted as an integer of the same size. Scalar forms: vs.
  • rshift: Shifts each element right by the number of bits of the same lane of the second register: arithmetic shift (copies of the sign bit) for the signed types, logical shift (zeros) for the unsigned ones. Counts from 0 to the number of bits of the type minus 1; any other count is undefined behavior. The shift by the same count for every lane is rshift_vs (mipp::rshift(vd0, s0) in C++), and the logical shift of the signed types is rshiftl. rshift_vs also accepts the floating-point types: their bits are shifted logically, as an unsigned integer of the same size (-1.0f shifted by 4 gives the bits 0x0bf80000). Scalar forms: vs.
  • rshiftl: Shifts each element right by the number of bits of the same lane of the second register, with a logical shift (zeros enter on the left) for all the types: the signed elements are shifted as the unsigned integer of the same size, like (int32_t)((uint32_t)a >> n) in C. Same result as rshift on the unsigned types. Counts from 0 to the number of bits of the type minus 1; any other count is undefined behavior. The shift by the same count for every lane is rshiftl_vs (mipp::rshiftl(vd0, s0) in C++). rshiftl_vs also accepts the floating-point types: their bits are shifted as an unsigned integer of the same size. Scalar forms: vs.
  • rshiftround: Shifts each element right by the number of bits of the same lane of the second register, rounded to the nearest integer with the ties up: \((vd0_i + 2^{n-1}) \gg n\) computed without overflow, arithmetic for the signed types and logical for the unsigned ones (7 shifted by 1 gives 4, -7 gives -3). A count of 0 gives the element itself. Counts from 0 to the number of bits of the type minus 1; any other count is undefined behavior. The fixed-point arithmetic uses it to divide by a power of 2 with a rounding instead of a truncation (rshift). One instruction on RVV (vssra / vssrl in the rounding mode rnu), two on NEON and SVE2 (the negated count, then vrshl / srshl / urshl), a few elsewhere, around rshift, which x86 computes element by element for the 8-bit types, and for the other types without the variable shifts of AVX2 or AVX-512. The shift by the same count for every lane is rshiftround_vs (mipp::rshiftround(vd0, s0) in C++). Scalar forms: vs.
  • all: Tests if every element of a mask register is active: 1 if all active, 0 otherwise (int32_t in C, bool in the C++ APIs).
  • none: Tests if every element in a mask register is inactive: 1 if all inactive, 0 otherwise (int32_t in C, bool in the C++ APIs).
  • any: Tests if at least one element of a mask register is active: 1 if any active, 0 otherwise (int32_t in C, bool in the C++ APIs).
  • testz: Tests if the bitwise AND of two mask registers is all zero: 1 if disjoint, 0 otherwise (int32_t in C, bool in the C++ APIs).

Math

  • abs: Computes the absolute value of each element in a vector register. The most negative integer has no positive counterpart: its absolute value is itself (-128 in int8).
  • acos: Computes the arc cosine of each floating-point element in radians. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 3e-7 in float32 and 5e-16 in float64. The scalar target calls the C library.
  • acosh: Computes the inverse hyperbolic cosine of each floating-point element. On the SIMD targets (measured on SSE, AVX and NEON), it uses the formula of fdlibm, \(\operatorname{log1p}(t + \sqrt{t (t + 2)})\) with \(t = x - 1\), accurate near 1, and \(\ln x + \ln 2\) from \(x = 2^{24}\) in float32 / \(2^{53}\) in float64, where \(x^2\) would overflow: the relative error is below 3e-7 in float32 and 5e-16 in float64. The special values are the ones of the C library: \(x < 1\) and NaN give NaN, and \(+\infty\) gives \(+\infty\). The scalar target calls the C library.
  • asin: Computes the arc sine of each floating-point element in radians. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 3e-7 in float32 and 5e-16 in float64. The scalar target calls the C library.
  • asinh: Computes the inverse hyperbolic sine of each floating-point element. On the SIMD targets (measured on SSE, AVX and NEON), it uses the formula of fdlibm, \(\operatorname{log1p}(a + a^2 / (1 + \sqrt{1 + a^2}))\) with \(a = |x|\), accurate near 0, and \(\ln a + \ln 2\) from \(a = 2^{24}\) in float32 / \(2^{53}\) in float64, where \(a^2\) would overflow, then the sign of \(x\): the relative error is below 3e-7 in float32 and 5e-16 in float64, tiny \(x\) included (the result is then \(x\)). The special values are the ones of the C library: \(\pm\infty\) gives \(\pm\infty\) and a NaN gives NaN. The scalar target calls the C library.
  • atan: Computes the arc tangent of each floating-point element in radians. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 3e-7 in float32 and 5e-16 in float64. The scalar target calls the C library.
  • atan2: Computes the four-quadrant arc tangent of y and x floating-point vector elements. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 3e-7 in float32 and 4e-11 in float64, and atan2(0, -0) and atan2(-0, -0) give \(\pm 0\) instead of \(\pm\pi\). The scalar target calls the C library. Scalar forms: vs, sv.
  • atanh: Computes the inverse hyperbolic tangent of each floating-point element. On the SIMD targets (measured on SSE, AVX and NEON), it uses the formula of fdlibm, \(\operatorname{log1p}(2a + 2a \cdot a / (1 - a)) / 2\) with \(a = |x|\), accurate near 0, then the sign of \(x\): the relative error is below 3e-7 in float32 and 5e-16 in float64, tiny \(x\) included (the result is then \(x\)). The special values are the ones of the C library: \(\pm 1\) gives \(\pm\infty\), and \(|x| > 1\) (the infinities included) and NaN give NaN. The scalar target calls the C library.
  • cbrt: Computes the cube root of each floating-point element, negative elements included. On the SIMD targets (measured on SSE, AVX and NEON), it uses the algorithm of the C library (fdlibm, musl): a first estimate from the bits of \(|x|\) (its exponent divided by 3), a polynomial, then one Newton-like step, with the sign of \(x\), without exp nor log: the relative error is below 1.2e-7 in float32 (one unit in the last place, checked on every float32) and 2.3e-16 in float64, the subnormals included. \(\pm 0\), \(\pm\infty\) and NaN are returned as they are. The scalar target calls the C library.
  • ceil: Rounds each floating-point element up, toward \(+\infty\), as the C function ceil: 2.3 gives 3 and -2.7 gives -2. The sign of a zero is kept: -0.5 gives -0.0. The integers are returned unchanged.
  • cos: Computes the trigonometric cosine of each floating-point element in radians. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 2e-7 in float32 and 5e-16 in float64, for any argument: the lanes with \(|x| > 8192\) (float32) or \(|x| > 2^{50}\) (float64), the infinities and NaN are computed by the C library. The scalar target calls the C library.
  • cosh: Computes the hyperbolic cosine of each floating-point element. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 4e-7 in float32 and 5e-16 in float64. It is computed as \(h \cdot h/2 + 1/(4 \, h \cdot h/2)\) with \(h = e^{|x|/2}\), so that it overflows to \(+\infty\) where the C library does (\(|x| \approx 89.42\) in float32, \(710.48\) in float64), and not where \(e^{|x|}\) does; \(\pm\infty\) gives \(+\infty\) and a NaN gives NaN. The scalar target calls the C library.
  • erf: Computes the error function of each element: \(\operatorname{erf}(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} \, dt\), odd, from \(-1\) to \(1\) (the cumulative distribution of the normal law is \(\frac{1}{2}(1 + \operatorname{erf}(x / \sqrt{2}))\), the GELU activation \(\frac{x}{2}(1 + \operatorname{erf}(x / \sqrt{2}))\)). Two polynomials, written in MIPP: \(x \, P(x^2)\) for \(|x| \le 1\) (float32) or \(2\) (float64), \(1 - e^{-x^2} Q(1/|x|)\) beyond, and \(\pm 1\) from \(3.92\) / \(5.93\), where the result rounds to 1. The maximum relative error measured against erf of the C library is about 2e-7 in float32 and 1e-15 in float64. erf(+-inf) is +-1, erf(NaN) is a NaN. No target has an instruction for it.
  • exp: Computes the base-e exponential of each floating-point element. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 2e-7 in float32 and 3e-16 in float64 (one unit in the last place). The special values are the ones of the C library: the result overflows to \(+\infty\) from \(x \approx 88.72\) in float32 and \(709.78\) in float64, decreases through the subnormals below \(x \approx -87.3\) / \(-708.4\) down to 0 from \(-103.97\) / \(-745.13\), \(-\infty\) gives 0 and a NaN gives NaN. When every lane is in \([-87, 87]\) in float32 or \([-708, 708]\) in float64 (the usual case), \(2^n\) is built in the exponent field; otherwise it is applied in two factors, a few more operations for the whole register. On NEON of ARMv7, which flushes the subnormals to zero, a subnormal result is 0. The scalar target calls the C library.
  • expm1: Computes \(e^x - 1\) for each floating-point element, without the loss of precision of exp(x) - 1 near 0. On the SIMD targets (measured on SSE, AVX and NEON), it uses the identity \((u - 1)\,x / \ln u\) with \(u = e^x\) for \(|x| < 0.5\) (W. Kahan) and \(u - 1\) elsewhere: the relative error is below 3e-7 in float32 and 4e-16 in float64, tiny \(x\) included (the result is then \(x\)). The special values follow exp: \(+\infty\) gives \(+\infty\), \(-\infty\) gives \(-1\), and a NaN gives NaN. The scalar target calls the C library.
  • floor: Rounds each floating-point element down, toward \(-\infty\), as the C function floor: 2.7 gives 2 and -2.3 gives -3. The sign of a zero is kept (-0.0 gives -0.0). The integers are returned unchanged.
  • frexp: Splits each element into a mantissa and an exponent, as frexp in C: \(x = m \cdot 2^e\) with \(|m|\) in \([0.5, 1)\) and the sign of \(x\). The mantissa is returned, the exponent is written to the output register vd1, signed integers of the width of the data (int32 for float32, int64 for float64): frexp(8.0) gives 0.5 and 4. +-0, +-inf and NaN give themselves as mantissa and an exponent of 0. The subnormals give their true exponent. ldexp(m, e) gives back x; getexp(x) is e - 1 for the finite non-zero values. Generic on every target (the exponent field of the bits). On NEON of ARMv7, which flushes the subnormals to zero, a subnormal input counts as 0.
  • getexp: Returns the exponent of each element as a floating-point value: \(\lfloor \log_2 |x| \rfloor\), as logb in C (getexp(10.0) gives 3.0, getexp(0.75) gives -1.0). The subnormals give their true exponent (down to -149 in float32). getexp(+-0) is -inf, getexp(+-inf) is +inf and getexp(NaN) is a NaN. Native on AVX-512 (vgetexp); elsewhere, the exponent field of the bits minus the bias. With ldexp, it scales a value by a power of 2 without a division, and it gives the range reduction of log and exp. On NEON of ARMv7, which flushes the subnormals to zero, a subnormal input counts as 0 (the result is -inf).
  • hypot: Computes \(\sqrt{x^2 + y^2}\) element-wise without overflow nor underflow in the squares: it is computed as \(m \sqrt{1 + (n / m)^2}\) with \(m = \max(|x|, |y|)\) and \(n = \min(|x|, |y|)\). On the SIMD targets (measured on SSE, AVX, AVX-512, NEON, SVE and RVV), the relative error is below 3e-7 in float32 and 4e-16 in float64, from the subnormals to the largest values, and an infinite argument gives \(+\infty\). A NaN follows min and max: it gives NaN on NEON and SVE, and may give a number elsewhere (hypot(NaN, 1) is \(\sqrt{2}\) on SSE, AVX, AVX-512 and RVV). The scalar target calls the C library. Scalar forms: vs, sv.
  • ldexp: Multiplies each element by 2 to the power of the same lane of the second register, signed integers of the same size (int32 for float32, int64 for float64): \(x \cdot 2^n\) as ldexp in C, with a single rounding when the result is subnormal, +-inf beyond the largest value, +-0 below the smallest one. +-0, +-inf and NaN are returned unchanged. Native on SVE (fscale), two instructions on AVX-512 (the conversion of n, then vscalef); elsewhere, the exponent field is replaced. With getexp, it scales a value by a power of 2 without a multiplication by a constant computed at run time. On NEON of ARMv7, which flushes the subnormals to zero, a subnormal input counts as 0 and a subnormal result is 0.
  • log: Computes the natural (base-e) logarithm of each floating-point element. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 2e-7 in float32 and 3e-16 in float64 (one unit in the last place), the subnormals included; the float64 version uses the algorithm of fdlibm. The special values are the ones of the C library: \(\pm 0\) gives \(-\infty\), \(+\infty\) gives \(+\infty\), and a negative element or a NaN gives NaN. When every element is a positive normal number (the usual case), the subnormals and the special values are not looked at; otherwise, the computation is done again with the subnormals scaled, a few more operations for the whole register. On NEON of ARMv7, which flushes the subnormals to zero, a subnormal element counts as 0. The scalar target calls the C library.
  • log10: Computes the base-10 logarithm of each floating-point element, as \(\ln x / \ln 10\). On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 2e-7 in float32 and 3e-16 in float64, the subnormals included; the special values follow log (those of the C library: \(\pm 0\) gives \(-\infty\), \(+\infty\) gives \(+\infty\), a negative element or a NaN gives NaN). The scalar target calls the C library.
  • log1p: Computes \(\ln(1 + x)\) for each floating-point element, without the loss of precision of log(1 + x) near 0. On the SIMD targets (measured on SSE, AVX and NEON), it uses the identity \(\ln(u)\,x / (u - 1)\) with \(u = 1 + x\) for \(|x| < 0.5\) (D. Goldberg) and \(\ln u\) elsewhere: the relative error is below 3e-7 in float32 and 4e-16 in float64, tiny \(x\) included (the result is then \(x\)). The special values are the ones of the C library: log1p(-1) gives \(-\infty\), \(+\infty\) gives \(+\infty\), and \(x < -1\) or a NaN gives NaN. The scalar target calls the C library.
  • log2: Computes the base-2 logarithm of each floating-point element, as \(\ln x / \ln 2\). On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 2e-7 in float32 and 3e-16 in float64, the subnormals included; the special values follow log (those of the C library: \(\pm 0\) gives \(-\infty\), \(+\infty\) gives \(+\infty\), a negative element or a NaN gives NaN). The scalar target calls the C library.
  • neg: Negates each element of a vector register. The most negative integer has no positive counterpart: its negation is itself (-128 in int8).
  • rcp: Computes an estimate of the reciprocal of each floating-point element (\(1 / a\)). Its precision is the one of the instruction of the target: about two significant digits with the 7- or 8-bit estimates of NEON, SVE and RVV, three with the 12 bits of SSE and AVX (float32), four with the 14 bits of AVX-512, and the exact value for float64 on SSE and AVX (a division). Divide by div when the last digits matter.
  • xorsign: Negates each element of the first register where the sign bit of the element of the second register is set (negative values, and also -0.0 and the negative NaN for the floating-point types). Scalar forms: vs.
  • copysign: Builds each element with the magnitude of the first register and the sign of the second one (IEEE copysign). Scalar forms: vs.
  • pow: Computes the first vector register raised to the power of the second element-wise. On the SIMD targets (measured on SSE, AVX and NEON), it is computed as \(e^{y \ln x}\): a zero base gives 0 or \(+\infty\) by the sign of \(y\), and the infinities and NaN follow the C library, except pow(0, 0), pow(1, \pm\infty) and pow(1, NaN), which give NaN instead of 1; a negative base gives NaN, even with an integer exponent (pow(-2, 3)). The relative error grows with \(|y \ln x|\) (the error of \(\ln x\) is multiplied by it): below 5e-6 in float32 and 1e-14 in float64 for results between 1e-17 and 1e17. On the unsigned types, the integer power wraps around (modulo \(2^n\)) and pow(0, 0) is 1. Scalar forms: vs, sv.
  • pow2: Computes 2 raised to the power of each vector element. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 2e-7 in float32 and 3e-16 in float64 (one unit in the last place): \(2^x = 2^n \, 2^f\) with \(n\) the nearest integer and \(f = x - n\), both exact, \(2^f\) by the polynomial of exp, and an integer \(x\) gives an exact power of 2. The special values are the ones of the C library: \(+\infty\) from \(x = 128\) / \(1024\), the subnormals below \(x = -126\) / \(-1022\) and 0 from \(-150\) / \(-1075\), \(-\infty\) gives 0 and a NaN gives NaN. On the unsigned types, the result is 1 << x: 0 when \(x\) is at least the number of bits of the type, undefined from \(x = 64\).
  • round: Rounds each floating-point element to the nearest integer. A tie is rounded away from zero, as the C function round: 2.5 gives 3 and -2.5 gives -3. The rounding of a tie to the even integer is roundeven. The sign of a zero result depends on the target: -0.3 and -0.0 give -0.0 on NEON, SVE and the scalar target, and +0.0 on SSE, AVX, AVX-512 and RVV. The integers are returned unchanged.
  • roundeven: Rounds each floating-point element to the nearest integer. A tie is rounded to the even integer, as the C23 function roundeven and the default rounding of IEEE 754: 2.5 gives 2, 3.5 gives 4 and -0.5 gives -0.0. Unlike round, it does not move the ties away from zero, so it does not bias a sum of rounded values. The integers are returned unchanged.
  • rsqrt: Computes an estimate of the reciprocal square root of each floating-point element (\(1 / \sqrt{a}\)). Its precision is the one of the instruction of the target: about two significant digits with the 7- or 8-bit estimates of NEON and RVV, three with the 12 bits of SSE and AVX (float32), four with the 14 bits of AVX-512, and the exact value on SVE and for float64 on SSE and AVX (a division by the square root). Divide by sqrt when the last digits matter.
  • sin: Computes the trigonometric sine of each floating-point element in radians. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 2e-7 in float32 and 5e-16 in float64, for any argument: the lanes with \(|x| > 8192\) (float32) or \(|x| > 2^{50}\) (float64), the infinities and NaN are computed by the C library. The scalar target calls the C library.
  • sinh: Computes the hyperbolic sine of each floating-point element. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 5e-7 in float32 and 1e-15 in float64. It is computed as \(h \cdot h/2 - 1/(4 \, h \cdot h/2)\) with \(h = e^{|x|/2}\), so that it overflows to \(\pm\infty\) where the C library does (\(|x| \approx 89.42\) in float32, \(710.48\) in float64), and with a Taylor polynomial for \(|x| < 0.5\), where this difference cancels (a tiny \(x\) gives \(x\)); \(\pm\infty\) gives \(\pm\infty\) and a NaN gives NaN. The scalar target calls the C library.
  • sqrt: Computes the square root of each element in a vector register, correctly rounded. On ARMv7 NEON before ARMv8 (float32), it is a reciprocal square root estimate refined by two Newton-Raphson steps: the last bits can differ.
  • tan: Computes the trigonometric tangent of each floating-point element in radians. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 2e-7 in float32 and 5e-16 in float64, for any argument: the lanes with \(|x| > 8192\) (float32) or \(|x| > 2^{50}\) (float64), the infinities and NaN are computed by the C library. In float64 on NEON, tan(-0.0) gives +0.0. The scalar target calls the C library.
  • tanh: Computes the hyperbolic tangent of each floating-point element. On the SIMD targets (measured on SSE, AVX and NEON), the relative error is below 1e-6 in float32 for \(|x| \ge 0.1\), and 2e-15 in float64. Near 0, the error is absolute (a few 1e-8 in float32): below \(|x| = 0.1\) the relative error grows (about 1e-4 at \(|x| = 0.001\) in float32), and a tiny \(x\) (1e-30) gives 0. The scalar target calls the C library.
  • trunc: Truncates each floating-point element toward zero: -2.7 gives -2. The integers are returned unchanged.

Rearrangement

  • reverse: Reverses the order of the lanes of the register (of the whole LMUL group).
  • swap2: Swaps the lanes of each pair (lanes \(2k\) and \(2k+1\)). A register of a single lane is unchanged.
  • dupeven: Copies each even lane to the next odd lane: lanes \(2k\) and \(2k+1\) both receive the lane \(2k\).
  • dupodd: Copies each odd lane to the previous even lane: lanes \(2k\) and \(2k+1\) both receive the lane \(2k+1\). A register of a single lane is unchanged.
  • ziplo: Interleaves the lanes of the lower halves of the two registers: vd0[0], vd1[0], vd0[1], vd1[1]... (the first half of zip).
  • ziphi: Interleaves the lanes of the upper halves of the two registers: vd0[N/2], vd1[N/2], vd0[N/2+1]... (the second half of zip).
  • bcast: Copies the lane s0 to every lane (\(0 \le s0 < N\), with \(N\) the number of lanes of the LMUL group; other values are undefined behavior).
  • insert: Returns the register with its lane s1 replaced by the scalar s0 (the inverse of get); s1 must be in \([0, N)\), a value out of the range is undefined behavior. With a variable s1: a broadcast of s0 under the mask of the lane on AVX-512 (2 instructions), a merging dup on SVE, vmv.s.x then a vslideup of vl = s1 + 1 lanes on RVV, and elsewhere a select of the broadcast s0 where the indices of the lanes equal s1 (no round trip through memory). With a constant s1 (insert<S>(v, x), or a constant argument once inlined): the insertion instructions on SSE (pinsrw, and pinsrb / pinsrd / pinsrq / insertps with SSE4.1; movsd / unpcklpd for float64), vpinsr or a blend on AVX, ins (vsetq_lane) on NEON, when the compiler optimizes.
  • rotate: Rotates the lanes down by s0 (\(0 \le s0 < N\)): the lane \(i\) receives the lane \((i + s0) \bmod N\).
  • slide: Window of \(N\) lanes at the position s0 (\(0 \le s0 \le N\)) of the concatenation of the two registers: the lanes \(s0\) to \(N-1\) of vd0, then the lanes \(0\) to \(s0-1\) of vd1 (x86 alignr, ARM ext).
  • slideup: Moves the lanes up by s0 (\(0 \le s0 \le N\)): the lane \(i\) receives the lane \(i - s0\), the lanes below \(s0\) are zero.
  • slidedown: Moves the lanes down by s0 (\(0 \le s0 \le N\)): the lane \(i\) receives the lane \(i + s0\), the lanes from \(N - s0\) are zero.
  • reverse_b128: Reverses the order of the lanes in each block of 128 bits (the whole register when it is smaller).
  • ziplo_b128: ziplo in each block of 128 bits: interleaves the lanes of the lower halves of the blocks (x86 unpacklo).
  • ziphi_b128: ziphi in each block of 128 bits: interleaves the lanes of the upper halves of the blocks (x86 unpackhi).
  • bcast_b128: Copies the lane s0 of each block of 128 bits to the lanes of the block (\(0 \le s0 < B\), with \(B\) the number of lanes of a block).
  • rotate_b128: rotate in each block of 128 bits (\(0 \le s0 < B\), with \(B\) the number of lanes of a block).
  • slide_b128: slide in each block of 128 bits: the window at s0 of the concatenation of the blocks of vd0 and vd1 (\(0 \le s0 \le B\), with \(B\) the number of lanes of a block; x86 alignr).
  • slideup_b128: slideup in each block of 128 bits, zeros entering at the bottom of each block (x86 pslldq).
  • slidedown_b128: slidedown in each block of 128 bits, zeros entering at the top of each block (x86 psrldq).
  • unziplo: Even lanes of the concatenation of the two registers: vd0[0], vd0[2]... then vd1[0], vd1[2]... (with lo / hi, the even lanes of a register of twice the LMUL; ARM uzp1).
  • unziphi: Odd lanes of the concatenation of the two registers: vd0[1], vd0[3]... then vd1[1], vd1[3]... (ARM uzp2).
  • unziplo_b128: unziplo in each block of 128 bits (x86 shufps with the even lanes).
  • unziphi_b128: unziphi in each block of 128 bits.
  • zip: Interleaves the two halves of the register: the lane \(2k\) receives the lane \(k\), the lane \(2k+1\) the lane \(N/2 + k\) (planar to interleaved layout; the inverse of unzip).
  • unzip: Separates the even and the odd lanes: the even lanes in the lower half, the odd lanes in the upper half (interleaved to planar layout).
  • loadu_unzip: Loads \(N\) elements (no alignment required) and separates the even and the odd ones: the even elements in the lower half of the register, the odd ones in the upper half (unzip(loadu(p0)); with LMUL 2, the two LMUL 1 halves are the even and the odd elements of \(2N\) elements, as ARM vld2).
  • loadu_unzip2: Loads \(N\) structures of 2 fields (\(2N\) elements, no alignment required; complex numbers, (x, y) points) and separates the fields: vd0 and vd1 receive the fields 0 and 1, the lane \(i\) of vd{k} being the element \(2i + k\) (array of structures to structure of arrays, the inverse of storeu_zip2). The registers are written through pointers in C and references in C++. loadu_unzip does the same in a single register (the two fields in its two halves). Native on NEON (vld2q), SVE (svld2) and RVV (vlseg2e; at LMUL 8, a strided load vlse per field); elsewhere, two loads then unziplo and unziphi.
  • loadu_unzip3: Loads \(N\) structures of 3 fields (\(3N\) elements, no alignment required; RGB pixels, xyz points) and separates the fields: vd0, vd1 and vd2 receive the fields 0 to 2, the lane \(i\) of vd{k} being the element \(3i + k\) (array of structures to structure of arrays, the inverse of storeu_zip3). The registers are written through pointers in C and references in C++. Native on NEON (vld3q), SVE (svld3) and RVV (vlseg3e; from LMUL 4, a strided load vlse per field); gathers elsewhere.
  • loadu_unzip4: Loads \(N\) structures of 4 fields (\(4N\) elements, no alignment required; RGBA pixels) and separates the fields: vd0, vd1, vd2 and vd3 receive the fields 0 to 3, the lane \(i\) of vd{k} being the element \(4i + k\) (array of structures to structure of arrays, the inverse of storeu_zip4). The registers are written through pointers in C and references in C++. Native on NEON (vld4q), SVE (svld4) and RVV (vlseg4e; from LMUL 4, a strided load vlse per field); gathers elsewhere.
  • storeu_zip: Interleaves the two halves of the register and stores the \(N\) elements (no alignment required): storeu(p0, zip(vd0)), the inverse of loadu_unzip (ARM vst2).
  • storeu_zip2: Stores vd0 and vd1 as \(N\) structures of 2 fields (\(2N\) elements, no alignment required): the lane \(i\) of vd{k} goes to the element \(2i + k\) (structure of arrays to array of structures, the inverse of loadu_unzip2). storeu_zip does the same from a single register (the two fields in its two halves). Native on NEON (vst2q), SVE (svst2) and RVV (vsseg2e; at LMUL 8, a strided store vsse per field); elsewhere, ziplo and ziphi then two stores.
  • storeu_zip3: Stores vd0, vd1 and vd2 as \(N\) structures of 3 fields (\(3N\) elements, no alignment required): the lane \(i\) of vd{k} goes to the element \(3i + k\) (structure of arrays to array of structures, the inverse of loadu_unzip3). Native on NEON (vst3q), SVE (svst3) and RVV (vsseg3e; from LMUL 4, a strided store vsse per field); scatters elsewhere.
  • storeu_zip4: Stores vd0, vd1, vd2 and vd3 as \(N\) structures of 4 fields (\(4N\) elements, no alignment required): the lane \(i\) of vd{k} goes to the element \(4i + k\) (structure of arrays to array of structures, the inverse of loadu_unzip4). Native on NEON (vst4q), SVE (svst4) and RVV (vsseg4e; from LMUL 4, a strided store vsse per field); scatters elsewhere.
  • permute: Lane \(i\) receives the lane vd1[i] of vd0 (vd1: unsigned indices of the width of the elements, each below \(N\), the number of lanes of the LMUL group; other values are undefined behavior).
  • permute2: Lane i receives the lane vd2[i] of the concatenation of vd0 and vd1 (indices below 2N; other values are undefined behavior).
  • permute_b128: permute in each block of 128 bits: lane \(i\) receives the lane vd1[i] of its block (indices below the number of lanes of a block; x86 vpermilps, pshufb).
  • compress: The active lanes of vd0 (mask vm0), in order, packed at the beginning of the register; the other lanes are zero.
  • expand: The inverse of compress: the first lanes of vd0, in order, go to the active lanes (mask vm0); the inactive lanes are zero.

Reduction

  • findfirst: Returns the index of the first active lane of a mask register, or \(-1\) when no lane is active.
  • findlast: Returns the index of the last active lane of a mask register, or \(-1\) when no lane is active.
  • hadd: Computes the horizontal addition (reduction sum) of all elements in a vector register. The integer sum wraps around (modulo \(2^n\)), so its result depends on the number of lanes; hadds saturates instead. For the floating-point types, the order of the additions depends on the target: the last bits of the result can differ from one target to another, and from a sequential sum.
  • hadds: Computes the horizontal addition with saturation of all elements in an integer vector register. For the 8-, 16- and 32-bit types, the sum is exact and saturated once at the end: 100 + 100 - 100 - 100 gives 0 in int8. For the 64-bit types, each addition saturates, in the order of the lanes: MAX + 1 - 1 gives MAX - 1.
  • hmul: Computes the horizontal multiplication (reduction product) of all elements in a vector register. The integer product keeps the low bits (modulo \(2^n\)). For the floating-point types, the order of the multiplications depends on the target: the last bits of the result can differ from one target to another, and from a sequential product.
  • hmin: Computes the horizontal minimum (reduction minimum) of all elements in a vector register. With a NaN element, the result depends on the target (measured): NEON and SVE return NaN; RVV and the scalar target ignore the NaN elements (and return FLT_MAX / DBL_MAX when all the elements are NaN); on SSE, AVX and AVX-512, the result depends on the position of the NaN in the register (in the measures: NaN with the NaN in the last lane, the minimum of the other elements with the NaN in the first or a middle lane, NaN when all the elements are NaN). To get a NaN whenever an element is NaN, test any(isnan(v)) first.
  • hmax: Computes the horizontal maximum (reduction maximum) of all elements in a vector register. With a NaN element, the result depends on the target (measured): NEON and SVE return NaN; RVV and the scalar target ignore the NaN elements (and return -FLT_MAX / -DBL_MAX when all the elements are NaN); on SSE, AVX and AVX-512, the result depends on the position of the NaN in the register (in the measures: NaN with the NaN in the last lane, the maximum of the other elements with the NaN in the first or a middle lane, NaN when all the elements are NaN). To get a NaN whenever an element is NaN, test any(isnan(v)) first.
  • argmin: Returns the index of the first lane holding the minimum of the register (the lane of hmin): with equal values, the lowest index. With a NaN, the result depends on the ISA (see hmin), and may be \(-1\) when the NaN reaches hmin and no lane is equal to it; on the scalar target, which compares the lanes in order, a NaN is ignored, except in the first lane, which is then the result (with NaN as minimum). When s0 is not null (NULL in C, nullptr by default in C++), the minimum is also written to *s0: the result of hmin, computed anyway to find the lane, which saves a second reduction (to compare blocks in a loop over an array, for example).
  • argmax: Returns the index of the first lane holding the maximum of the register (the lane of hmax): with equal values, the lowest index. With a NaN, the result depends on the ISA (see hmax), and may be \(-1\) when the NaN reaches hmax and no lane is equal to it; on the scalar target, which compares the lanes in order, a NaN is ignored, except in the first lane, which is then the result (with NaN as maximum). When s0 is not null (NULL in C, nullptr by default in C++), the maximum is also written to *s0: the result of hmax, computed anyway to find the lane, which saves a second reduction (to compare blocks in a loop over an array, for example).
  • testz: Tests if the bitwise AND of two mask registers is all zero: 1 if disjoint, 0 otherwise (int32_t in C, bool in the C++ APIs).
  • none: Tests if every element in a mask register is inactive: 1 if all inactive, 0 otherwise (int32_t in C, bool in the C++ APIs).
  • any: Tests if at least one element of a mask register is active: 1 if any active, 0 otherwise (int32_t in C, bool in the C++ APIs).
  • all: Tests if every element of a mask register is active: 1 if all active, 0 otherwise (int32_t in C, bool in the C++ APIs).
  • count: Number of active lanes of a mask register.

Reinterpret

  • cast: In-register bitcast/reinterpretation of a vector register to another datatype with zero runtime instructions: the register keeps its size and its bits, so the number of lanes changes with the element size.
  • cast_k: In-register bitcast/reinterpretation of a mask register to another datatype of the same element size with zero runtime instructions: the mask keeps its lanes.
  • tovd: Expands a mask register into an all-ones (~0) / all-zeros (0) vector register.
  • tovm: Converts vector elements to mask elements: a lane is active when its element has at least one non-zero bit (so -0.0 is active), and the resulting mask lane has all its bits set.

Selection

  • select: Selects elements between two vector registers based on a mask (vd0 in the active lanes of vm0, vd1 in the others). Scalar forms: vs, sv.
  • min: Selects the minimum value element-wise between two vector registers. With a NaN, the result depends on the target (measured): SSE, AVX, AVX-512 and the scalar target return the second element when one of the two is NaN (min(NaN, 1) is 1, min(1, NaN) is NaN), NEON and SVE return NaN, RVV returns the other element (vfmin, IEEE 754-2019 minimumNumber: NaN only when both are NaN); on ARMv7, float64 (emulated) behaves as the scalar target. The sign of the zero returned for -0.0 and 0.0 depends on the target too. Scalar forms: vs.
  • max: Selects the maximum value element-wise between two vector registers. With a NaN, the result depends on the target (measured): SSE, AVX, AVX-512 and the scalar target return the second element when one of the two is NaN (max(NaN, 1) is 1, max(1, NaN) is NaN), NEON and SVE return NaN, RVV returns the other element (vfmax, IEEE 754-2019 maximumNumber: NaN only when both are NaN); on ARMv7, float64 (emulated) behaves as the scalar target. The sign of the zero returned for -0.0 and 0.0 depends on the target too. Scalar forms: vs.
  • clamp: Clamps each element between the elements of the same lane of the second (lower bound) and third (upper bound) registers: min(max(vd0, vd1), vd2). With a lower bound greater than the upper bound, the result is the upper bound. The form vss takes scalar bounds: clamp(vd0, s0, s1). Scalar forms: vss.

Store

  • store: Stores vector elements into an aligned memory address.
  • storent: Stores a vector register to aligned memory with a non-temporal hint: the data bypasses the caches when the target allows it, for the large arrays that are written once and not read soon (the caches keep the data that is reused). The address must be aligned as for store. On x86, the non-temporal stores are weakly ordered: call mipp_storent_fence() / mipp::storent_fence() before another thread reads the data. Where the target has no such store (NEON with GCC, RVV), it is an ordinary store.
  • storeu: Stores vector elements into an unaligned memory address.
  • get: Extracts a single scalar element at index s0 from a vector register.
  • get_k: Returns the lane s0 of a mask register. In C, a value of the element type: all bits set for an active lane (-1 for the signed integers, the maximum for the unsigned ones, NaN for the floating-point types), 0 for an inactive lane, on every target; test it with != 0, and do not convert a floating-point result to an integer. In the C++ APIs (mipp::get(vm, idx)), a bool.
  • getfirst: Extracts the first scalar element (element 0) from a vector register with minimal latency.
  • scatter: Stores vector elements into non-contiguous memory locations using an index vector (unsigned indices counted in elements, of the width of the data or 32/64-bit: then at their own LMUL; 32-bit indices lower than \(2^{31}\), and than \(2^{30}\) on RVV for 32-bit data). Two active lanes with the same index write the same element: undefined behavior (the value that remains depends on the target).
  • storeu_compress: Stores the active lanes of vd0 (mask vm0), in order, at p0 (no alignment required) and returns their number. Exactly this number of elements is written.
  • storeuf_compress: storeu_compress that may write a whole register: the active lanes of vd0 at p0, then up to \(N - c\) unspecified elements, with \(c\) the number of active lanes (the memory of \(N\) elements from p0 must be writable). Faster than storeu_compress without a native masked store: a filter loop overwrites the unspecified elements with the next call (keep \(N\) elements of margin at the end of the output).
  • storeu_zip: Interleaves the two halves of the register and stores the \(N\) elements (no alignment required): storeu(p0, zip(vd0)), the inverse of loadu_unzip (ARM vst2).
  • storeu_zip2: Stores vd0 and vd1 as \(N\) structures of 2 fields (\(2N\) elements, no alignment required): the lane \(i\) of vd{k} goes to the element \(2i + k\) (structure of arrays to array of structures, the inverse of loadu_unzip2). storeu_zip does the same from a single register (the two fields in its two halves). Native on NEON (vst2q), SVE (svst2) and RVV (vsseg2e; at LMUL 8, a strided store vsse per field); elsewhere, ziplo and ziphi then two stores.
  • storeu_zip3: Stores vd0, vd1 and vd2 as \(N\) structures of 3 fields (\(3N\) elements, no alignment required): the lane \(i\) of vd{k} goes to the element \(3i + k\) (structure of arrays to array of structures, the inverse of loadu_unzip3). Native on NEON (vst3q), SVE (svst3) and RVV (vsseg3e; from LMUL 4, a strided store vsse per field); scatters elsewhere.
  • storeu_zip4: Stores vd0, vd1, vd2 and vd3 as \(N\) structures of 4 fields (\(4N\) elements, no alignment required): the lane \(i\) of vd{k} goes to the element \(4i + k\) (structure of arrays to array of structures, the inverse of loadu_unzip4). Native on NEON (vst4q), SVE (svst4) and RVV (vsseg4e; from LMUL 4, a strided store vsse per field); scatters elsewhere.
  • storeu_strided: Stores a register to memory with a constant stride: the lane i goes to p0[i * s0], s0 a positive number of elements (s0 = 1 is storeu). Only these N elements are written: the ones between them are left unchanged. s0 must be positive: s0 = 0 (every lane to the same element, the value that remains would depend on the target) and the negative strides are undefined behavior. Native on RVV (vsse); a scatter on SVE and on the other targets for the 32-bit and 64-bit types; an element by element copy otherwise.