Skip to content

File jm_simd.h

FileList > doppler > jm_simd.h

Go to the source code of this file

Public Types

Type Name
typedef float JM_VEC_F32
typedef double JM_VEC_F64

Public Static Functions

Type Name
float jm_dot_f32 (const float *JM_RESTRICT a, const float *JM_RESTRICT b, int n)
double jm_dot_f64 (const double *JM_RESTRICT a, const double *JM_RESTRICT b, int n)

Macros

Type Name
define JM_ADD_F32 (a, b) ((a) + (b))
define JM_ADD_F64 (a, b) ((a) + (b))
define JM_FMA_F32 (acc, a, b) ((acc) += (a) \* (b))
define JM_FMA_F64 (acc, a, b) ((acc) += (a) \* (b))
define JM_HSUM_F32 (v) (v)
define JM_HSUM_F64 (v) (v)
define JM_LOAD_F32 (p) (\*(p))
define JM_LOAD_F64 (p) (\*(p))
define JM_MAC_F32 (acc, ptr, s) ((acc) += (\*(ptr)) \* (s))
define JM_MAC_F64 (acc, ptr, s) ((acc) += (\*(ptr)) \* (s))
define JM_MUL_F32 (a, b) ((a) \* (b))
define JM_MUL_F64 (a, b) ((a) \* (b))
define JM_RESTRICT restrict
define JM_SIMD_WIDTH 1
define JM_SIMD_WIDTH_F32 1
define JM_SIMD_WIDTH_F64 1
define JM_SPLAT_F32 (x) (x)
define JM_SPLAT_F64 (x) (x)
define JM_STORE_F32 (p, v) (\*(p) = (v))
define JM_STORE_F64 (p, v) (\*(p) = (v))
define JM_ZERO_F32 () 0.0f
define JM_ZERO_F64 () 0.0

Public Types Documentation

typedef JM_VEC_F32

typedef float JM_VEC_F32;

typedef JM_VEC_F64

typedef double JM_VEC_F64;

Public Static Functions Documentation

function jm_dot_f32

static inline float jm_dot_f32 (
    const float * JM_RESTRICT a,
    const float * JM_RESTRICT b,
    int n
) 

function jm_dot_f64

static inline double jm_dot_f64 (
    const double * JM_RESTRICT a,
    const double * JM_RESTRICT b,
    int n
) 

Macro Definition Documentation

define JM_ADD_F32

#define JM_ADD_F32 (
    a,
    b
) `((a) + (b))`

define JM_ADD_F64

#define JM_ADD_F64 (
    a,
    b
) `((a) + (b))`

define JM_FMA_F32

#define JM_FMA_F32 (
    acc,
    a,
    b
) `((acc) += (a) * (b))`

define JM_FMA_F64

#define JM_FMA_F64 (
    acc,
    a,
    b
) `((acc) += (a) * (b))`

define JM_HSUM_F32

#define JM_HSUM_F32 (
    v
) `(v)`

define JM_HSUM_F64

#define JM_HSUM_F64 (
    v
) `(v)`

define JM_LOAD_F32

#define JM_LOAD_F32 (
    p
) `(*(p))`

define JM_LOAD_F64

#define JM_LOAD_F64 (
    p
) `(*(p))`

define JM_MAC_F32

#define JM_MAC_F32 (
    acc,
    ptr,
    s
) `((acc) += (*(ptr)) * (s))`

define JM_MAC_F64

#define JM_MAC_F64 (
    acc,
    ptr,
    s
) `((acc) += (*(ptr)) * (s))`

define JM_MUL_F32

#define JM_MUL_F32 (
    a,
    b
) `((a) * (b))`

define JM_MUL_F64

#define JM_MUL_F64 (
    a,
    b
) `((a) * (b))`

define JM_RESTRICT

#define JM_RESTRICT `restrict`

jm_simd.h — width-portable SIMD operation macros.

Selects the widest available instruction set at compile time: AVX-512F -> 16 float / 8 double lanes (JM_SIMD_WIDTH_F32 = 16) AVX2+FMA -> 8 float / 4 double lanes (JM_SIMD_WIDTH_F32 = 8) NEON -> 4 float / 2 double lanes (JM_SIMD_WIDTH_F32 = 4) (aarch64) Scalar -> 1 lane (auto-vectorisation still applies)

Typical usage (FIR inner loop):

JM_VEC_F32 acc = JM_ZERO_F32();
for (int k = 0; k < N_TAPS; k++)
    JM_MAC_F32(acc, window + k, coeffs[k]);
*out = JM_HSUM_F32(acc);

JM_SIMD_WIDTH_F32 tells you how many floats the loop above advances per iteration — stride your outer loop accordingly.

Can be included standalone; reuses JM_RESTRICT from jm_perf.h if already defined, otherwise provides its own fallback.


define JM_SIMD_WIDTH

#define JM_SIMD_WIDTH `1`

define JM_SIMD_WIDTH_F32

#define JM_SIMD_WIDTH_F32 `1`

define JM_SIMD_WIDTH_F64

#define JM_SIMD_WIDTH_F64 `1`

define JM_SPLAT_F32

#define JM_SPLAT_F32 (
    x
) `(x)`

define JM_SPLAT_F64

#define JM_SPLAT_F64 (
    x
) `(x)`

define JM_STORE_F32

#define JM_STORE_F32 (
    p,
    v
) `(*(p) = (v))`

define JM_STORE_F64

#define JM_STORE_F64 (
    p,
    v
) `(*(p) = (v))`

define JM_ZERO_F32

#define JM_ZERO_F32 (

) `0.0f`

define JM_ZERO_F64

#define JM_ZERO_F64 (

) `0.0`


The documentation for this class was generated from the following file native/inc/doppler/jm_simd.h