mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:27:35 +00:00
AK: Add AK::SIMD::exp_approximate
This approximation tries to generate values within 0.1% of their actual expected value. Microbenchmarks indicate that this iterative SIMD version can be up to 60x faster than `AK::SIMD::exp`.
This commit is contained in:
parent
3275d659bf
commit
f4342c9118
3 changed files with 43 additions and 0 deletions
|
@ -66,6 +66,15 @@ ALWAYS_INLINE static f32x4 exp(f32x4 v)
|
|||
};
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static f32x4 exp_approximate(f32x4 v)
|
||||
{
|
||||
static constexpr int number_of_iterations = 10;
|
||||
auto result = 1.f + v / (1 << number_of_iterations);
|
||||
for (int i = 0; i < number_of_iterations; ++i)
|
||||
result *= result;
|
||||
return result;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE static f32x4 sqrt(f32x4 v)
|
||||
{
|
||||
#if ARCH(x86_64)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue