MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / hsum256

Function hsum256

nodedb-vector/src/distance/simd/avx2.rs:106–116  ·  view source on GitHub ↗
(v: std::arch::x86_64::__m256)

Source from the content-addressed store, hash-verified

104/// Horizontal sum of 8 × f32 in a __m256.
105#[target_feature(enable = "avx2")]
106unsafe fn hsum256(v: std::arch::x86_64::__m256) -> f32 {
107 use std::arch::x86_64::*;
108 let hi = _mm256_extractf128_ps(v, 1);
109 let lo = _mm256_castps256_ps128(v);
110 let sum128 = _mm_add_ps(lo, hi);
111 let shuf = _mm_movehdup_ps(sum128);
112 let sums = _mm_add_ps(sum128, shuf);
113 let shuf2 = _mm_movehl_ps(sums, sums);
114 let sums2 = _mm_add_ss(sums, shuf2);
115 _mm_cvtss_f32(sums2)
116}

Callers 3

l2_squared_implFunction · 0.70
cosine_implFunction · 0.70
ip_implFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected