Skip to content

Vector Types & Generalized LMUL

MIPP provides a unified vector type system supporting 10 standard numeric datatypes across configurable register multipliers (\(\text{LMUL}\)).


1. Supported Datatypes Matrix

MIPP standardizes naming across C and C++ interfaces:

MIPP Datatype Scalar Type (T) C Vector Type (LMUL=1) C Mask Type (LMUL=1)
float64 double / float64_t vd_float64_t vm_float64_t
float32 float / float32_t vd_float32_t vm_float32_t
int64 int64_t vd_int64_t vm_int64_t
int32 int32_t vd_int32_t vm_int32_t
int16 int16_t vd_int16_t vm_int16_t
int8 int8_t vd_int8_t vm_int8_t
uint64 uint64_t vd_uint64_t vm_uint64_t
uint32 uint32_t vd_uint32_t vm_uint32_t
uint16 uint16_t vd_uint16_t vm_uint16_t
uint8 uint8_t vd_uint8_t vm_uint8_t

2. Vector Type Representation

2.1. Vector Handles

  • Value Registers: mipp::vd<T, LMUL> (underlying C struct / hardware handle) and mipp::Vd<T, LMUL> (C++ class).
  • Mask Registers: mipp::vm<T, LMUL> and mipp::Vm<T, LMUL>.

2.2. Compile-Time Element Capacity (N)

The total number of elements contained in a vector is retrieved via mipp::N<T, LMUL>() (C API: MIPP_N_[TYPE]_[LMUL] macros; C++ Object API: mipp::Vd<T, LMUL>::N()):

\[N(T, \text{LMUL}) = \left( \frac{\text{VectorBitWidth}}{\text{sizeof}(T) \times 8} \right) \times \text{LMUL}\]

For the half-vectors (d2), the capacity is half the one of LMUL = 1 (MIPP_N_FLOAT32_D2, mipp::N<float, -2>()).

const int n_f32_m1 = MIPP_N_FLOAT32;    // 8 on AVX2 (256-bit / 32-bit * 1)
const int n_f32_m4 = MIPP_N_FLOAT32_M4; // 32 on AVX2 (8 * 4)
constexpr int n_f32_m1 = mipp::N<float, 1>(); // 8 on AVX2 (256-bit / 32-bit * 1)
constexpr int n_f32_m4 = mipp::N<float, 4>(); // 32 on AVX2 (8 * 4)
constexpr int n_f32_m1 = mipp::Vd<float, 1>::N(); // 8 on AVX2 (256-bit / 32-bit * 1)
constexpr int n_f32_m4 = mipp::Vd<float, 4>::N(); // 32 on AVX2 (8 * 4)

3. Generalized LMUL (Length Multiplier) Semantics

The Length Multiplier (\(\text{LMUL} \in \{1, 2, 4, 8\}\), plus the half-vectors of section 4) originates from RISC-V Vector 1.0 (RVV), where hardware registers are grouped to scale vector capacity. To support RVV natively while maintaining an identical API across all backends, MIPP generalizes the LMUL concept across all supported ISAs.

On architectures without hardware register grouping (x86, ARM), software LMUL functions as a structured multi-register unrolling mechanism: operations on \(\text{LMUL}=2\) or \(\text{LMUL}=4\) expand into discrete SIMD instructions across separate registers, increasing instruction-level parallelism (ILP) without manual loop unrolling, while developer discretion is required to manage register pressure at high LMUL values.

The figure also shows the half-vectors (\(\text{LDIV}=2\), i.e. \(\text{LMUL}=1/2\)), described in section 4.

LMUL modes with 128-bit registers and float elements: a half-vector (LDIV = 2, LMUL = 1/2) uses the lower half of one register (2 elements); LMUL = 1, 2, 4 and 8 group 1, 2, 4 and 8 registers (4, 8, 16 and 32 elements)

Optimization Practice: Parameterizing Kernels by LMUL

When developing compute kernels in C++, parameterizing functions by int LMUL = 1 makes it simple to explore the unrolling optimization space:

template <typename T, int LMUL = 1>
void compute_kernel(const T* in, T* out, size_t n);
  • LMUL=2 or LMUL=4 typically can yield performance gains in compute-bound loops by saturating execution units and interleaving instruction latencies.
  • LMUL=8 often exhibits diminishing returns or regressions due to register spilling.

3.1. Hardware LMUL (RISC-V Vector 1.0)

On architectures with native register grouping support (RVV v extension), MIPP maps directly to hardware types:

  • \(\text{LMUL}=1\): vfloat32m1_t
  • \(\text{LMUL}=2\): vfloat32m2_t (2 adjacent hardware registers)
  • \(\text{LMUL}=4\): vfloat32m4_t (4 adjacent hardware registers)
  • \(\text{LMUL}=8\): vfloat32m8_t (8 adjacent hardware registers)

The vector execution unit operates on grouped registers as single wide units in hardware.

3.2. Software Recursive Binary Structs (x86, ARM)

On SIMD architectures without hardware register grouping (SSE, AVX, AVX-512, NEON and SVE), MIPP emulates LMUL in software via hierarchical binary structures. SVE is vector-length agnostic by design, but MIPP fixes its vector length at compile time (-msve-vector-bits) and SVE has no register grouping, so it is handled like the others:

/* Base Level: LMUL = 1 (Single hardware vector) */
typedef struct { __m256 vd; } vd_avx_float32_m1_t;

/* Multiplied Level: LMUL = 2 (Pair of LMUL=1 structs) */
typedef struct { vd_avx_float32_m1_t lo, hi; } vd_avx_float32_m2_t;

/* Multiplied Level: LMUL = 4 (Pair of LMUL=2 structs) */
typedef struct { vd_avx_float32_m2_t lo, hi; } vd_avx_float32_m4_t;

/* Multiplied Level: LMUL = 8 (Pair of LMUL=4 structs) */
typedef struct { vd_avx_float32_m4_t lo, hi; } vd_avx_float32_m8_t;

Compilation & Zero-Overhead Execution

When calling an operation on a multiplied vector (e.g., mipp::add(va, vb) on LMUL=2), the generator emits code evaluating the sub-components recursively:

static inline vd_avx_float32_m2_t mipp_avx_add_float32_m2(
    const vd_avx_float32_m2_t vd0,
    const vd_avx_float32_m2_t vd1)
{
    vd_avx_float32_m2_t res;
    res.lo = mipp_avx_add_float32_m1(vd0.lo, vd1.lo); // _mm256_add_ps
    res.hi = mipp_avx_add_float32_m1(vd0.hi, vd1.hi); // _mm256_add_ps
    return res;
}

The compiler places the .lo and .hi halves into separate CPU vector registers (e.g., %ymm0 and %ymm1), inlining the calls into dual-issue instructions without memory round-trips.

3.3. Flattened Array Representation (Scalar Target)

In the scalar fallback backend, multi-register vectors are represented as flat arrays sized by the total capacity:

/* The generated types also carry __attribute__((aligned(MIPP_SCALAR_VD_ALIGN_BYTE))) */
typedef struct { float32_t vd[MIPP_SCALAR_N_FLOAT32]; } vd_scalar_float32_m1_t;
typedef struct { float32_t vd[MIPP_SCALAR_N_FLOAT32_M2]; } vd_scalar_float32_m2_t;
typedef struct { float32_t vd[MIPP_SCALAR_N_FLOAT32_M4]; } vd_scalar_float32_m4_t;
typedef struct { float32_t vd[MIPP_SCALAR_N_FLOAT32_M8]; } vd_scalar_float32_m8_t;

Scalar operations execute flat sequential loops over all \(N \times \text{LMUL}\) elements.

3.4. Representation per Target

The table gives, for each target, the representation of each LMUL and of the half-vectors. It is generated from the ISA descriptors of the generator (sw_lmul, hw_lmul).

Target Register width LMUL = 1 LMUL = 2 LMUL = 4 LMUL = 8 d2 MIPP_LDIV_2
SSE 128 bits native struct struct struct half of an LMUL = 1 register defined
AVX / AVX2 256 bits native struct struct struct SSE register defined
AVX-512 512 bits native struct struct struct AVX register defined
NEON 128 bits native struct struct struct half of an LMUL = 1 register defined
SVE 128 to 2048 bits, fixed at compile time native struct struct struct half of an LMUL = 1 register defined
RVV VLEN, fixed at compile time native native group native group native group native fractional defined
Scalar MIPP_SCALAR_SIZE array array array array array defined

native: one hardware register; native group / native fractional: hardware register group or fractional register type; struct: structure of LMUL=1 registers; SSE register / AVX register: register of the narrower ISA; half of an LMUL = 1 register: same register as LMUL = 1, only the lower half of the lanes is meaningful; array: plain array of elements; —: not generated.


4. Half-Vectors (d2)

In addition to multi-register expansion (\(\text{LMUL} > 1\)), MIPP provides half-vectors: vectors holding half the elements of a base register. The same concept appears under several notations, which all mean the same thing:

Context Notation
Concept half-vector, length divider \(\text{LDIV} = 2\) (equivalently \(\text{LMUL} = 1/2\))
C API types and functions d2 suffix: vd_float32_d2_t, mipp_add_float32_d2
C++ Functional and Object APIs LMUL template argument -2: mipp::vd<float, -2>, mipp::Vd<float, -2>
Availability macro MIPP_LDIV_2
ISA descriptors of the generator (sw_lmul, hw_lmul) factor -2
Test generator (gen_mipp_tests.py --ldiv) --ldiv 2

The same loop in the three APIs (the MIPP_LDIV_2 guard keeps the code portable, see §4.1):

#ifdef MIPP_LDIV_2
const size_t n_half = MIPP_N_FLOAT32_D2;
for (size_t i = 0; i + n_half <= n; i += n_half) {
    vd_float32_d2_t a = mipp_loadu_float32_d2(in_a + i);
    vd_float32_d2_t b = mipp_loadu_float32_d2(in_b + i);
    vd_float32_d2_t c = mipp_add_float32_d2(a, b);
    mipp_storeu_float32_d2(out + i, c);
}
#endif
#ifdef MIPP_LDIV_2
constexpr size_t n_half = mipp::N<float, -2>();
for (size_t i = 0; i + n_half <= n; i += n_half) {
    mipp::vd<float, -2> a = mipp::loadu<float, -2>(in_a + i);
    mipp::vd<float, -2> b = mipp::loadu<float, -2>(in_b + i);
    mipp::vd<float, -2> c = mipp::add(a, b);
    mipp::storeu(out + i, c);
}
#endif
#ifdef MIPP_LDIV_2
constexpr size_t n_half = mipp::N<float, -2>();
for (size_t i = 0; i + n_half <= n; i += n_half) {
    mipp::Vd<float, -2> a = mipp::loadu_obj<float, -2>(in_a + i);
    mipp::Vd<float, -2> b = mipp::loadu_obj<float, -2>(in_b + i);
    mipp::Vd<float, -2> c = a + b;
    mipp::storeu(out + i, c);
}
#endif

4.1. Availability

Today, every SIMD extension supported by MIPP provides half-vectors (\(\text{LDIV} = 2\)). This is not a guarantee for the future: an extension added later may not support \(\text{LDIV} = 2\) at first. MIPP therefore defines the MIPP_LDIV_2 macro when the target provides half-vectors, and portable code should use it as a guard:

#ifdef MIPP_LDIV_2
    vd_float32_d2_t h = mipp_set0_float32_d2();
#endif
#ifdef MIPP_LDIV_2
    mipp::vd<float, -2> h = mipp::set0<float, -2>();
#endif
#ifdef MIPP_LDIV_2
    mipp::Vd<float, -2> h = mipp::set0_obj<float, -2>();
#endif

The d2 and MIPP_LDIV_2 columns of the table of §3.4 give the targets that provide half-vectors, and their representation:

  • AVX / AVX2, AVX-512: a native register of the narrower ISA: 128-bit SSE registers (__m128, __m128d, __m128i) on AVX, 256-bit AVX registers on AVX-512.
  • RISC-V Vector (RVV): native fractional register types (vfloat32mf2_t, ...) for 8 to 32-bit elements. For 64-bit elements, where the RVV constraint \(\text{SEW} / \text{LMUL} \le \text{ELEN}\) forbids fractional types, MIPP stores the half-vector in a plain array, and most operations on it use the scalar fallback. They are implemented with the standard V extension; on cores without 64-bit elements or with VLEN < 128, some of them are not (see Implementation Levels). The representation of the RVV half-vectors can be changed at compile time (see §4.3).
  • SSE / NEON / ARM SVE: there is no narrower register (on ARMv7, part of the float64 half-vector operations are not implemented, see Implementation Levels), so a d2 value is stored in a full LMUL = 1 register (same member as the m1 type, but a distinct type). Only the lower \(N/2\) lanes are meaningful; the upper lanes are unspecified and ignored (they may hold garbage). Consequences:
    • lane-wise operations are the m1 operations; loads and stores only access \(N/2\) elements; reductions (hadd, hmin, argmin...), testz, none, any, all, count, findfirst and findlast ignore the upper lanes;
    • get(r, lane) with lane outside \([0, N/2)\) is undefined behavior;
    • the upper lanes of a d2 mask are not kept at zero: they are neutralized only where observable (testz, none, any, all, count, findfirst, findlast, masked loads/stores/gathers/scatters, masked reductions, combine on masks).
  • Scalar: plain array of half the elements.

4.2. Scope and Constraints of Deeper Fractional Division

While RISC-V Vector supports \(\text{LMUL} \in \{1/2, 1/4, 1/8\}\), generalizing deeper divisions (\(\text{LDIV} = 4, 8\)) across ISAs is constrained by element capacity:

  • On a 128-bit register (SSE / NEON), a 64-bit datatype (float64, int64) has an element capacity of \(N=2\) at \(\text{LMUL}=1\).
  • Defining \(\text{LDIV} = 4\) for a 64-bit type would result in \(N = 2 / 4 = 0.5\) elements, which has no meaning.

For this reason, MIPP only exposes \(\text{LDIV} = 2\) (d2), and deeper divisions are not part of the API.

4.3. RVV Half-Vectors: Hardware or by vl

On RVV, a half-vector can be represented in two ways, chosen by defining one of these macros before including MIPP (or with -D on the command line):

Macro Half-vectors of 8 to 32-bit elements Half-vectors of 64-bit elements
MIPP_RVV_LDIV_HW (default) fractional register (vfloat32mf2_t) plain array, scalar fallback (Level 3)
MIPP_RVV_LDIV_VL register of LMUL 1 used with a vector length vl of \(N/2\) register of LMUL 1 with vl = \(N/2\) (native)
MIPP_RVV_LDIV_HYBRID fractional register (vfloat32mf2_t) register of LMUL 1 with vl = \(N/2\) (native)

With a vector length of \(N/2\), the RVV instructions only process the lower \(N/2\) lanes: the lane-wise operations, the loads, the stores and the reductions of a half-vector are single instructions, with no mask and no access beyond the \(N/2\) elements. This is the only native representation of the 64-bit half-vectors, for which RVV has no fractional register type. lo is then free and hi / combine are a slide of the register.

With GCC, the Level 3 functions of RVV (scalar fallbacks) are neither inlined nor vectorized: GCC 14 miscompiles them in some inlining contexts (details). In the default mode, most functions on the 64-bit half-vectors are such fallbacks. The modes MIPP_RVV_LDIV_VL and MIPP_RVV_LDIV_HYBRID have native 64-bit half-vectors.

The API is the same in the three modes (same type names, same functions, same results): only the content of the d2 types and the implementation change. Since the types change, all the files of a program must be compiled with the same mode; passing a d2 register between files compiled with different modes is not supported. Defining several of these macros is a compilation error. The implementation levels given by the documentation and the API Explorer are the ones of the default mode.


5. Type Conversions

MIPP provides five main conversions between data vectors. They differ in what they preserve: the bits (cast), the values (cvt), or the values with a wider (wcvt) or narrower (ncvt, ncvts) type. The last ones change the LMUL of the register, so that no element is lost or left unused (see §5.5). Variants of cvt and ncvts add a rounding: cvtfloor, cvtceil, cvtround and cvtroundeven (§5.2), and ncvtsrshiftround (§5.4).

Operation Effect C API C++ Functional API C++ Object API
cast Reinterprets the bits of the register as another type. No value is converted, no instruction is emitted. mipp_cast_[src]_[dst]_[lmul](v) mipp::cast_[dst](v) mipp::cast<T_DST>(v)
cvt Converts the value of each element to another type of the same width. mipp_cvt_[src]_[dst]_[lmul](v) mipp::cvt_[dst](v) mipp::cvt<T_DST>(v)
wcvt Converts the value of every element to the type twice as wide; the result has the next LMUL up. mipp_wcvt_[src]_[dst]_[lmul](v) mipp::wcvt_[dst](v) mipp::wcvt<T_DST>(v)
ncvt Converts the value of every element to the type twice as narrow (truncation); the result has the next LMUL down. mipp_ncvt_[src]_[dst]_[lmul](v) mipp::ncvt_[dst](v) mipp::ncvt<T_DST>(v)
ncvts As ncvt for the integers, with saturation to the range of the destination type. mipp_ncvts_[src]_[dst]_[lmul](v) mipp::ncvts_[dst](v) mipp::ncvts<T_DST>(v)

cast and cvt keep the LMUL of their input; wcvt, ncvt and ncvts do not. Masks have their own reinterpretation, cast_k (see Masking Semantics §6.1), and masks convert to and from data vectors with tovd / tovm (§6.2, §6.3).

vd_float32_t v  = mipp_loadu_float32(ptr);         // {-2.7, -1.4, -0.1, 1.2, ...}
vd_int32_t   vb = mipp_cast_float32_int32(v);      // {0xC02CCCCD, ...}: IEEE-754 bit patterns
vd_int32_t   vi = mipp_cvt_float32_int32(v);       // {-2, -1, 0, 1, ...}: truncation
vd_float64_m2_t vw = mipp_wcvt_float32_float64(v); // {-2.7, -1.4, ...}: every element, in a register of LMUL 2
vd_int16_m2_t v16 = mipp_loadu_int16_m2(ptr16);    // {300, -300, 100, ...} in a register of LMUL 2
vd_int8_t    vn = mipp_ncvt_int16_int8_m2(v16);    // {44, -44, 100, ...}: truncation, in a register of LMUL 1
vd_int8_t    vs = mipp_ncvts_int16_int8_m2(v16);   // {127, -128, 100, ...}: saturation to the range of int8
mipp::vd<float>   v  = mipp::loadu<float>(ptr);            // {-2.7, -1.4, -0.1, 1.2, ...}
mipp::vd<int32_t> vb = mipp::cast_int32(v);                // {0xC02CCCCD, ...}: IEEE-754 bit patterns
mipp::vd<int32_t> vi = mipp::cvt_int32(v);                 // {-2, -1, 0, 1, ...}: truncation
mipp::vd<double, 2> vw = mipp::wcvt_float64(v);            // {-2.7, -1.4, ...}: every element, in a register of LMUL 2
mipp::vd<int16_t, 2> v16 = mipp::loadu<int16_t, 2>(ptr16); // {300, -300, 100, ...} in a register of LMUL 2
mipp::vd<int8_t>  vn = mipp::ncvt_int8(v16);               // {44, -44, 100, ...}: truncation, in a register of LMUL 1
mipp::vd<int8_t>  vs = mipp::ncvts_int8(v16);              // {127, -128, 100, ...}: saturation to the range of int8
mipp::Vd<float>   v  = mipp::loadu_obj<float>(ptr);            // {-2.7, -1.4, -0.1, 1.2, ...}
mipp::Vd<int32_t> vb = mipp::cast<int32_t>(v);                 // {0xC02CCCCD, ...}: IEEE-754 bit patterns
mipp::Vd<int32_t> vi = mipp::cvt<int32_t>(v);                  // {-2, -1, 0, 1, ...}: truncation
mipp::Vd<double, 2> vw = mipp::wcvt<double>(v);                // {-2.7, -1.4, ...}: every element, in a register of LMUL 2
mipp::Vd<int16_t, 2> v16 = mipp::loadu_obj<int16_t, 2>(ptr16); // {300, -300, 100, ...} in a register of LMUL 2
mipp::Vd<int8_t>  vn = mipp::ncvt<int8_t>(v16);                // {44, -44, 100, ...}: truncation, in a register of LMUL 1
mipp::Vd<int8_t>  vs = mipp::ncvts<int8_t>(v16);               // {127, -128, 100, ...}: saturation to the range of int8

5.1. cast (Bit Reinterpretation)

cast exists for every pair of the 10 datatypes. The register keeps its size, so the number of elements changes when the widths differ: cast from vd<float> to vd<int8_t> gives 4 times more lanes, each holding one byte of the original floats. Typical uses are bit manipulations on floating-point values (sign, exponent) and feeding integer-only operations with floating-point data.

5.2. cvt (Value Conversion, Same Width)

cvt converts each element like a C cast. Available pairs: float32 \(\leftrightarrow\) int32 / uint32, float64 \(\leftrightarrow\) int64 / uint64, and signed \(\leftrightarrow\) unsigned integers of the same width (int8 \(\leftrightarrow\) uint8, ..., int64 \(\leftrightarrow\) uint64), plus the identity (a type to itself).

  • Floating-point to integer: truncation toward zero (-2.7f gives -2). Values out of the range of the destination type, and NaN, give a result that depends on the target. cvtfloor, cvtceil, cvtround (ties away from zero) and cvtroundeven (ties to even) round instead of truncating: they give the result of cvt(floor(v)), cvt(ceil(v)), cvt(round(v)) and cvt(roundeven(v)), in one instruction where the target has it (AVX-512, NEON from ARMv8, RVV). They are named as cvt in the three APIs (mipp_cvtfloor_float32_int32(v), mipp::cvtfloor_int32(v), mipp::cvtfloor<int32_t>(v)), and only exist from a floating-point type to an integer type of the same width.
  • Integer to floating-point: rounded to the nearest representable value (int32 above \(2^{24}\) loses precision in float).
  • Signed to unsigned and back: modular, the bit pattern is unchanged (-1 gives 4294967295 in uint32); the result is the same as cast.

5.3. wcvt (Widening Value Conversion)

wcvt converts to the type twice as wide: int8 \(\to\) int16, int16 \(\to\) int32, int32 \(\to\) int64, the same for the unsigned types, and float32 \(\to\) float64. The elements are twice as large, so they take twice the room: the result has the next LMUL up (d2 \(\to\) m1, m1 \(\to\) m2, m2 \(\to\) m4, m4 \(\to\) m8), and keeps every element in its original position. There is nothing to widen from m8: wcvt does not exist for this LMUL.

5.4. ncvt (Narrowing Value Conversion)

ncvt is the inverse of wcvt: int16 \(\to\) int8, int32 \(\to\) int16, int64 \(\to\) int32, the same for the unsigned types, and float64 \(\to\) float32. The result has the next LMUL down (m8 \(\to\) m4, ..., m1 \(\to\) d2), and keeps every element. There is nothing to narrow into from d2.

  • Integers: the value is truncated (modulo \(2^{n}\) of the destination width), like a C cast. There is no saturation: see ncvts.
  • float64 to float32: rounded to the nearest representable value.

ncvts is the saturating version, for the integers of the same signedness (int16 \(\to\) int8, ..., uint64 \(\to\) uint32): a value out of the range of the destination type gives the nearest bound (300 gives 127 in int8, -300 gives -128; 70000 gives 65535 in uint16). It is the pack of MIPPv1 on one register of the LMUL above: the pack of two registers a and b (the lanes of a, then the lanes of b) is ncvts(combine(a, b)). From a signed type to the unsigned type of half the width, clamp the negative values first: ncvts_uint8(cast_uint16(max(v, 0))).

ncvtsrshiftround(v, s) is ncvts(rshiftround(v, s)) in one operation: a right shift by s bits rounded to the nearest (ties up), then the saturating narrowing, as in the requantization of fixed-point arithmetic (an int32 accumulator scaled down to int16). It has the same types and the same LMUL change as ncvts, and s goes from 0 to the number of bits of the source type minus 1.

5.5. Changing the LMUL

wcvt, ncvt, ncvts and ncvtsrshiftround are functions whose result has an LMUL different from the one of their arguments, as the widening multiplication wmul (the exact product of two registers in the type twice as wide: mul(wcvt(a), wcvt(b)), in one instruction on NEON and RVV). The pairwise widening addition wpadd and the dot products dot2, dot4 and dot4us also return wider elements, but keep the LMUL: they combine 2 or 4 neighboring elements into one, so their result has the same size and fewer lanes. The others split and join registers:

Function Effect Input \(\to\) result
lo The lower half of the register. m8 \(\to\) m4 \(\to\) m2 \(\to\) m1 \(\to\) d2
hi The upper half of the register. m8 \(\to\) m4 \(\to\) m2 \(\to\) m1 \(\to\) d2
combine Joins two registers: the first one gives the lower half, the second one the upper half. d2 \(\to\) m1 \(\to\) m2 \(\to\) m4 \(\to\) m8

lo, hi and combine also exist on masks: lo_k, hi_k and combine_k in the C API, overloads of lo, hi and combine taking vm / Vm arguments in the C++ APIs. combine(lo(v), hi(v)) gives back v. The result LMUL is always the next one in the sequence d2, m1, m2, m4, m8, and a function is not defined where the next one does not exist (no lo from d2, no combine or wcvt from m8).

The C name carries the LMUL of the arguments, the one of the result being given by the type (mipp_lo_float32_m2 takes an m2 register and returns an m1 one). As for the other functions, no suffix means m1. The C++ Functional and Object APIs deduce the LMUL from the type of the argument.

vd_float32_t    a  = mipp_loadu_float32(ptr);
vd_float32_t    b  = mipp_loadu_float32(ptr + MIPP_N_FLOAT32);
vd_float32_m2_t ab = mipp_combine_float32(a, b);       // {a, b}: twice as many elements
vd_float32_t    lo = mipp_lo_float32_m2(ab);           // == a
vd_float32_t    hi = mipp_hi_float32_m2(ab);           // == b
vd_float64_m2_t vw = mipp_wcvt_float32_float64(a);     // a as double, in a register of LMUL 2
vd_float32_t    vn = mipp_ncvt_float64_float32_m2(vw); // and back to float: == a
mipp::vd<float>     a  = mipp::loadu<float>(ptr);
mipp::vd<float>     b  = mipp::loadu<float>(ptr + mipp::N<float>());
mipp::vd<float, 2>  ab = mipp::combine(a, b);    // {a, b}: twice as many elements
mipp::vd<float>     lo = mipp::lo(ab);           // == a
mipp::vd<float>     hi = mipp::hi(ab);           // == b
mipp::vd<double, 2> vw = mipp::wcvt_float64(a);  // a as double, in a register of LMUL 2
mipp::vd<float>     vn = mipp::ncvt_float32(vw); // and back to float: == a
mipp::Vd<float>     a  = mipp::loadu_obj<float>(ptr);
mipp::Vd<float>     b  = mipp::loadu_obj<float>(ptr + mipp::Vd<float>::N());
mipp::Vd<float, 2>  ab = mipp::combine(a, b);   // {a, b}: twice as many elements
mipp::Vd<float>     lo = mipp::lo(ab);          // == a
mipp::Vd<float>     hi = mipp::hi(ab);          // == b
mipp::Vd<double, 2> vw = mipp::wcvt<double>(a); // a as double, in a register of LMUL 2
mipp::Vd<float>     vn = mipp::ncvt<float>(vw); // and back to float: == a

Availability

These functions are provided by every target (see the function support pages for the implementation level of each one). Those that produce or take a d2 register also require MIPP_LDIV_2 (see §4.1).