## Coverage Report

#### Created: 2026-01-25 15:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)

    /home/noah/src/trueno/src/backends/avx512/ops/arithmetic.rs

    Line
    Count
    Source
    1
    //! AVX-512 arithmetic operations (add, sub, mul, div).
    2
    3
    #[cfg(target_arch = "x86_64")]
    4
    use std::arch::x86_64::*;
    5
    6
    /// AVX-512 vector addition.
    7
    #[inline]
    8
    #[target_feature(enable = "avx512f")]
    9
    0
    pub unsafe fn add(a: &[f32], b: &[f32], result: &mut [f32]) {
    10
    0
        let len = a.len();
    11
    0
        let mut i = 0;
    12
    0
        while i + 16 <= len {
    13
    0
            let va = _mm512_loadu_ps(a.as_ptr().add(i));
    14
    0
            let vb = _mm512_loadu_ps(b.as_ptr().add(i));
    15
    0
            _mm512_storeu_ps(result.as_mut_ptr().add(i), _mm512_add_ps(va, vb));
    16
    0
            i += 16;
    17
    0
        }
    18
    0
        for j in i..len { result[j] = a[j] + b[j]; }
    19
    0
    }
    20
    21
    /// AVX-512 vector subtraction.
    22
    #[inline]
    23
    #[target_feature(enable = "avx512f")]
    24
    0
    pub unsafe fn sub(a: &[f32], b: &[f32], result: &mut [f32]) {
    25
    0
        let len = a.len();
    26
    0
        let mut i = 0;
    27
    0
        while i + 16 <= len {
    28
    0
            let va = _mm512_loadu_ps(a.as_ptr().add(i));
    29
    0
            let vb = _mm512_loadu_ps(b.as_ptr().add(i));
    30
    0
            _mm512_storeu_ps(result.as_mut_ptr().add(i), _mm512_sub_ps(va, vb));
    31
    0
            i += 16;
    32
    0
        }
    33
    0
        for j in i..len { result[j] = a[j] - b[j]; }
    34
    0
    }
    35
    36
    /// AVX-512 vector multiplication.
    37
    #[inline]
    38
    #[target_feature(enable = "avx512f")]
    39
    0
    pub unsafe fn mul(a: &[f32], b: &[f32], result: &mut [f32]) {
    40
    0
        let len = a.len();
    41
    0
        let mut i = 0;
    42
    0
        while i + 16 <= len {
    43
    0
            let va = _mm512_loadu_ps(a.as_ptr().add(i));
    44
    0
            let vb = _mm512_loadu_ps(b.as_ptr().add(i));
    45
    0
            _mm512_storeu_ps(result.as_mut_ptr().add(i), _mm512_mul_ps(va, vb));
    46
    0
            i += 16;
    47
    0
        }
    48
    0
        for j in i..len { result[j] = a[j] * b[j]; }
    49
    0
    }
    50
    51
    /// AVX-512 vector division.
    52
    #[inline]
    53
    #[target_feature(enable = "avx512f")]
    54
    0
    pub unsafe fn div(a: &[f32], b: &[f32], result: &mut [f32]) {
    55
    0
        let len = a.len();
    56
    0
        let mut i = 0;
    57
    0
        while i + 16 <= len {
    58
    0
            let va = _mm512_loadu_ps(a.as_ptr().add(i));
    59
    0
            let vb = _mm512_loadu_ps(b.as_ptr().add(i));
    60
    0
            _mm512_storeu_ps(result.as_mut_ptr().add(i), _mm512_div_ps(va, vb));
    61
    0
            i += 16;
    62
    0
        }
    63
    0
        for j in i..len { result[j] = a[j] / b[j]; }
    64
    0
    }