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.
Mathematical semantics: \(\text{res}_i = (T_{\text{wide}}) vd0_i \times (T_{\text{wide}}) vd1_i\)
Prototypes¶
// LMUL = 1 (also without the _m1 suffix)
vd_int64_m2_t mipp_wmul_int32_int64_m1(const vd_int32_m1_t vd0, const vd_int32_m1_t vd1);
vd_int32_m2_t mipp_wmul_int16_int32_m1(const vd_int16_m1_t vd0, const vd_int16_m1_t vd1);
vd_int16_m2_t mipp_wmul_int8_int16_m1(const vd_int8_m1_t vd0, const vd_int8_m1_t vd1);
vd_float64_m2_t mipp_wmul_float32_float64_m1(const vd_float32_m1_t vd0, const vd_float32_m1_t vd1);
vd_uint64_m2_t mipp_wmul_uint32_uint64_m1(const vd_uint32_m1_t vd0, const vd_uint32_m1_t vd1);
vd_uint32_m2_t mipp_wmul_uint16_uint32_m1(const vd_uint16_m1_t vd0, const vd_uint16_m1_t vd1);
vd_uint16_m2_t mipp_wmul_uint8_uint16_m1(const vd_uint8_m1_t vd0, const vd_uint8_m1_t vd1);
// LMUL = 2
vd_int64_m4_t mipp_wmul_int32_int64_m2(const vd_int32_m2_t vd0, const vd_int32_m2_t vd1);
vd_int32_m4_t mipp_wmul_int16_int32_m2(const vd_int16_m2_t vd0, const vd_int16_m2_t vd1);
vd_int16_m4_t mipp_wmul_int8_int16_m2(const vd_int8_m2_t vd0, const vd_int8_m2_t vd1);
vd_float64_m4_t mipp_wmul_float32_float64_m2(const vd_float32_m2_t vd0, const vd_float32_m2_t vd1);
vd_uint64_m4_t mipp_wmul_uint32_uint64_m2(const vd_uint32_m2_t vd0, const vd_uint32_m2_t vd1);
vd_uint32_m4_t mipp_wmul_uint16_uint32_m2(const vd_uint16_m2_t vd0, const vd_uint16_m2_t vd1);
vd_uint16_m4_t mipp_wmul_uint8_uint16_m2(const vd_uint8_m2_t vd0, const vd_uint8_m2_t vd1);
// LMUL = 4
vd_int64_m8_t mipp_wmul_int32_int64_m4(const vd_int32_m4_t vd0, const vd_int32_m4_t vd1);
vd_int32_m8_t mipp_wmul_int16_int32_m4(const vd_int16_m4_t vd0, const vd_int16_m4_t vd1);
vd_int16_m8_t mipp_wmul_int8_int16_m4(const vd_int8_m4_t vd0, const vd_int8_m4_t vd1);
vd_float64_m8_t mipp_wmul_float32_float64_m4(const vd_float32_m4_t vd0, const vd_float32_m4_t vd1);
vd_uint64_m8_t mipp_wmul_uint32_uint64_m4(const vd_uint32_m4_t vd0, const vd_uint32_m4_t vd1);
vd_uint32_m8_t mipp_wmul_uint16_uint32_m4(const vd_uint16_m4_t vd0, const vd_uint16_m4_t vd1);
vd_uint16_m8_t mipp_wmul_uint8_uint16_m4(const vd_uint8_m4_t vd0, const vd_uint8_m4_t vd1);
// d2 (half-vector)
vd_int64_m1_t mipp_wmul_int32_int64_d2(const vd_int32_d2_t vd0, const vd_int32_d2_t vd1);
vd_int32_m1_t mipp_wmul_int16_int32_d2(const vd_int16_d2_t vd0, const vd_int16_d2_t vd1);
vd_int16_m1_t mipp_wmul_int8_int16_d2(const vd_int8_d2_t vd0, const vd_int8_d2_t vd1);
vd_float64_m1_t mipp_wmul_float32_float64_d2(const vd_float32_d2_t vd0, const vd_float32_d2_t vd1);
vd_uint64_m1_t mipp_wmul_uint32_uint64_d2(const vd_uint32_d2_t vd0, const vd_uint32_d2_t vd1);
vd_uint32_m1_t mipp_wmul_uint16_uint32_d2(const vd_uint16_d2_t vd0, const vd_uint16_d2_t vd1);
vd_uint16_m1_t mipp_wmul_uint8_uint16_d2(const vd_uint8_d2_t vd0, const vd_uint8_d2_t vd1);
// LMUL = 1
vd<int64_t, 2> wmul_int64(const vd<int32_t> vd0, const vd<int32_t> vd1);
vd<int32_t, 2> wmul_int32(const vd<int16_t> vd0, const vd<int16_t> vd1);
vd<int16_t, 2> wmul_int16(const vd<int8_t> vd0, const vd<int8_t> vd1);
vd<float64_t, 2> wmul_float64(const vd<float32_t> vd0, const vd<float32_t> vd1);
vd<uint64_t, 2> wmul_uint64(const vd<uint32_t> vd0, const vd<uint32_t> vd1);
vd<uint32_t, 2> wmul_uint32(const vd<uint16_t> vd0, const vd<uint16_t> vd1);
vd<uint16_t, 2> wmul_uint16(const vd<uint8_t> vd0, const vd<uint8_t> vd1);
// LMUL = 2
vd<int64_t, 4> wmul_int64(const vd<int32_t, 2> vd0, const vd<int32_t, 2> vd1);
vd<int32_t, 4> wmul_int32(const vd<int16_t, 2> vd0, const vd<int16_t, 2> vd1);
vd<int16_t, 4> wmul_int16(const vd<int8_t, 2> vd0, const vd<int8_t, 2> vd1);
vd<float64_t, 4> wmul_float64(const vd<float32_t, 2> vd0, const vd<float32_t, 2> vd1);
vd<uint64_t, 4> wmul_uint64(const vd<uint32_t, 2> vd0, const vd<uint32_t, 2> vd1);
vd<uint32_t, 4> wmul_uint32(const vd<uint16_t, 2> vd0, const vd<uint16_t, 2> vd1);
vd<uint16_t, 4> wmul_uint16(const vd<uint8_t, 2> vd0, const vd<uint8_t, 2> vd1);
// LMUL = 4
vd<int64_t, 8> wmul_int64(const vd<int32_t, 4> vd0, const vd<int32_t, 4> vd1);
vd<int32_t, 8> wmul_int32(const vd<int16_t, 4> vd0, const vd<int16_t, 4> vd1);
vd<int16_t, 8> wmul_int16(const vd<int8_t, 4> vd0, const vd<int8_t, 4> vd1);
vd<float64_t, 8> wmul_float64(const vd<float32_t, 4> vd0, const vd<float32_t, 4> vd1);
vd<uint64_t, 8> wmul_uint64(const vd<uint32_t, 4> vd0, const vd<uint32_t, 4> vd1);
vd<uint32_t, 8> wmul_uint32(const vd<uint16_t, 4> vd0, const vd<uint16_t, 4> vd1);
vd<uint16_t, 8> wmul_uint16(const vd<uint8_t, 4> vd0, const vd<uint8_t, 4> vd1);
// d2 (half-vector)
vd<int64_t> wmul_int64(const vd<int32_t, -2> vd0, const vd<int32_t, -2> vd1);
vd<int32_t> wmul_int32(const vd<int16_t, -2> vd0, const vd<int16_t, -2> vd1);
vd<int16_t> wmul_int16(const vd<int8_t, -2> vd0, const vd<int8_t, -2> vd1);
vd<float64_t> wmul_float64(const vd<float32_t, -2> vd0, const vd<float32_t, -2> vd1);
vd<uint64_t> wmul_uint64(const vd<uint32_t, -2> vd0, const vd<uint32_t, -2> vd1);
vd<uint32_t> wmul_uint32(const vd<uint16_t, -2> vd0, const vd<uint16_t, -2> vd1);
vd<uint16_t> wmul_uint16(const vd<uint8_t, -2> vd0, const vd<uint8_t, -2> vd1);
// LMUL = 1
Vd<int64_t, 2> wmul(const Vd<int32_t>& vd0, const Vd<int32_t>& vd1);
Vd<int32_t, 2> wmul(const Vd<int16_t>& vd0, const Vd<int16_t>& vd1);
Vd<int16_t, 2> wmul(const Vd<int8_t>& vd0, const Vd<int8_t>& vd1);
Vd<float64_t, 2> wmul(const Vd<float32_t>& vd0, const Vd<float32_t>& vd1);
Vd<uint64_t, 2> wmul(const Vd<uint32_t>& vd0, const Vd<uint32_t>& vd1);
Vd<uint32_t, 2> wmul(const Vd<uint16_t>& vd0, const Vd<uint16_t>& vd1);
Vd<uint16_t, 2> wmul(const Vd<uint8_t>& vd0, const Vd<uint8_t>& vd1);
// LMUL = 2
Vd<int64_t, 4> wmul(const Vd<int32_t, 2>& vd0, const Vd<int32_t, 2>& vd1);
Vd<int32_t, 4> wmul(const Vd<int16_t, 2>& vd0, const Vd<int16_t, 2>& vd1);
Vd<int16_t, 4> wmul(const Vd<int8_t, 2>& vd0, const Vd<int8_t, 2>& vd1);
Vd<float64_t, 4> wmul(const Vd<float32_t, 2>& vd0, const Vd<float32_t, 2>& vd1);
Vd<uint64_t, 4> wmul(const Vd<uint32_t, 2>& vd0, const Vd<uint32_t, 2>& vd1);
Vd<uint32_t, 4> wmul(const Vd<uint16_t, 2>& vd0, const Vd<uint16_t, 2>& vd1);
Vd<uint16_t, 4> wmul(const Vd<uint8_t, 2>& vd0, const Vd<uint8_t, 2>& vd1);
// LMUL = 4
Vd<int64_t, 8> wmul(const Vd<int32_t, 4>& vd0, const Vd<int32_t, 4>& vd1);
Vd<int32_t, 8> wmul(const Vd<int16_t, 4>& vd0, const Vd<int16_t, 4>& vd1);
Vd<int16_t, 8> wmul(const Vd<int8_t, 4>& vd0, const Vd<int8_t, 4>& vd1);
Vd<float64_t, 8> wmul(const Vd<float32_t, 4>& vd0, const Vd<float32_t, 4>& vd1);
Vd<uint64_t, 8> wmul(const Vd<uint32_t, 4>& vd0, const Vd<uint32_t, 4>& vd1);
Vd<uint32_t, 8> wmul(const Vd<uint16_t, 4>& vd0, const Vd<uint16_t, 4>& vd1);
Vd<uint16_t, 8> wmul(const Vd<uint8_t, 4>& vd0, const Vd<uint8_t, 4>& vd1);
// d2 (half-vector)
Vd<int64_t> wmul(const Vd<int32_t, -2>& vd0, const Vd<int32_t, -2>& vd1);
Vd<int32_t> wmul(const Vd<int16_t, -2>& vd0, const Vd<int16_t, -2>& vd1);
Vd<int16_t> wmul(const Vd<int8_t, -2>& vd0, const Vd<int8_t, -2>& vd1);
Vd<float64_t> wmul(const Vd<float32_t, -2>& vd0, const Vd<float32_t, -2>& vd1);
Vd<uint64_t> wmul(const Vd<uint32_t, -2>& vd0, const Vd<uint32_t, -2>& vd1);
Vd<uint32_t> wmul(const Vd<uint16_t, -2>& vd0, const Vd<uint16_t, -2>& vd1);
Vd<uint16_t> wmul(const Vd<uint8_t, -2>& vd0, const Vd<uint8_t, -2>& vd1);
Headers¶
// Option 1: Monolithic (entire library)
#include <mipp.h>
// Option 2: Category level
#include <mipp/c/cat/arithmetic.h> // all variants & LMULs
#include <mipp/c/cat/u/arithmetic.h> // 1D: 'u' variant only (*)
#include <mipp/c/cat/m2/arithmetic.h> // 1D: LMUL=2 only (*)
#include <mipp/c/cat/u/m2/arithmetic.h> // 2D: 'u' + LMUL=2 (*)
// Option 3: Function level (recommended for minimal dependencies)
#include <mipp/c/fun/wmul.h> // all variants & LMULs
#include <mipp/c/fun/u/wmul.h> // 1D: 'u' variant only (*)
#include <mipp/c/fun/m2/wmul.h> // 1D: LMUL=2 only (*)
#include <mipp/c/fun/u/m2/wmul.h> // 2D atomic: 'u' + LMUL=2 (fastest compilation) (*)
// (*) Fine-grained headers require MIPP generated with '--granularity fine'
// Option 1: Monolithic (entire library)
#include <mipp.hpp>
// Option 2: Category level
#include <mipp/cpp/cat/arithmetic.hpp> // all variants & LMULs
#include <mipp/cpp/cat/u/arithmetic.hpp> // 1D: 'u' variant only (*)
#include <mipp/cpp/cat/m2/arithmetic.hpp> // 1D: LMUL=2 only (*)
#include <mipp/cpp/cat/u/m2/arithmetic.hpp> // 2D: 'u' + LMUL=2 (*)
// Option 3: Function level (recommended for minimal dependencies)
#include <mipp/cpp/fun/wmul.hpp> // all variants & LMULs
#include <mipp/cpp/fun/u/wmul.hpp> // 1D: 'u' variant only (*)
#include <mipp/cpp/fun/m2/wmul.hpp> // 1D: LMUL=2 only (*)
#include <mipp/cpp/fun/u/m2/wmul.hpp> // 2D atomic: 'u' + LMUL=2 (fastest compilation) (*)
// (*) Fine-grained headers require MIPP generated with '--granularity fine'
// Option 1: Monolithic (entire library)
#include <mipp_obj.hpp>
// Option 2: Category level
#include <mipp/obj/cat/arithmetic.hpp> // all variants & LMULs
#include <mipp/obj/cat/u/arithmetic.hpp> // 1D: 'u' variant only (*)
#include <mipp/obj/cat/m2/arithmetic.hpp> // 1D: LMUL=2 only (*)
#include <mipp/obj/cat/u/m2/arithmetic.hpp> // 2D: 'u' + LMUL=2 (*)
// Option 3: Function level (recommended for minimal dependencies)
#include <mipp/obj/fun/wmul.hpp> // all variants & LMULs
#include <mipp/obj/fun/u/wmul.hpp> // 1D: 'u' variant only (*)
#include <mipp/obj/fun/m2/wmul.hpp> // 1D: LMUL=2 only (*)
#include <mipp/obj/fun/u/m2/wmul.hpp> // 2D atomic: 'u' + LMUL=2 (fastest compilation) (*)
// (*) Fine-grained headers require MIPP generated with '--granularity fine'
Supported Datatypes¶
int32→int64int16→int32int8→int16float32→float64uint32→uint64uint16→uint32uint8→uint16
Architecture & Implementation Matrix¶
Legend: L0 Native Hardware • L1 Dedicated Emulation • L2 Generic Emulation • L3 Scalar Fallback • − N/A — Full details. When the level depends on a compiler flag, the best level is shown.
The levels are the ones at LMUL = 1 of the result (the arguments are half-vectors).
| Architecture | i32→i64 | i16→i32 | i8→i16 | f32→f64 | u32→u64 | u16→u32 | u8→u16 |
|---|---|---|---|---|---|---|---|
| SSE | L1 | L1 | L2 | L2 | L1 | L1 | L2 |
| AVX | L1 | L1 | L2 | L2 | L1 | L1 | L2 |
| AVX512 | L1 | L2 | L2 | L2 | L1 | L2 | L2 |
| NEON | L1 | L1 | L1 | L2 | L1 | L1 | L1 |
| RVV | L0 | L0 | L0 | L0 | L0 | L0 | L0 |
| SVE | L2 | L2 | L2 | L2 | L2 | L2 | L2 |
Reference Algorithm¶
The scalar reference of MIPP defines the expected result of the function, for each datatype and mask variant: the unit tests compare the SIMD implementations of every target with it.
Test & Verification Specifications¶
How the unit tests draw the inputs (random values) and compare each lane of the result with the scalar reference, as in the generated C API tests.
| Datatypes | Inputs | Comparison with the reference |
|---|---|---|
int32 → int64, int16 → int32, int8 → int16, uint32 → uint64, uint16 → uint32, uint8 → uint16 |
full range | Exact |
float32 → float64 |
[-1, 1] | Exact |