Skip to content

Commit

Permalink
check sqinv
Browse files Browse the repository at this point in the history
  • Loading branch information
bassmang committed Nov 10, 2023
1 parent 15d5ed1 commit de58ab7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions vowpalwabbit/core/src/reductions/gd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,33 @@ VW_WARNING_STATE_POP

static inline float inv_sqrt(float x)
{
#if !defined(VW_NO_INLINE_SIMD)
# if defined(__ARM_NEON__)
// Propagate into vector
float32x2_t v1 = vdup_n_f32(x);
// Estimate
float32x2_t e1 = vrsqrte_f32(v1);
// N-R iteration 1
float32x2_t e2 = vmul_f32(e1, vrsqrts_f32(v1, vmul_f32(e1, e1)));
// N-R iteration 2
float32x2_t e3 = vmul_f32(e2, vrsqrts_f32(v1, vmul_f32(e2, e2)));
// Extract result
std::cout << "__ARM_NEON__" << "\n";
return vget_lane_f32(e3, 0);
# elif defined(__SSE2__)
__m128 eta = _mm_load_ss(&x);
eta = _mm_rsqrt_ss(eta);
_mm_store_ss(&x, eta);
std::cout << "__SSE2__" << "\n";
# else
std::cout << "None" << "\n";
x = quake_inv_sqrt(x);
# endif
#else
std::cout << "VW_NO_INLINE_SIMD" << "\n";
x = quake_inv_sqrt(x);
#endif

return x;
}

Expand Down

0 comments on commit de58ab7

Please sign in to comment.