Skip to content

Commit

Permalink
Sqrt
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou committed Nov 23, 2022
1 parent c54301a commit 06ed099
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
44 changes: 44 additions & 0 deletions include/eve/module/core/regular/impl/simd/arm/sve/sqrt.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//==================================================================================================
/*
EVE - Expressive Vector Engine
Copyright : EVE Project Contributors
SPDX-License-Identifier: BSL-1.0
*/
//==================================================================================================
#pragma once

#include <eve/arch/arm/sve/sve_true.hpp>
#include <eve/concept/value.hpp>
#include <eve/detail/category.hpp>
#include <eve/detail/implementation.hpp>

namespace eve::detail
{
template<floating_real_scalar_value T, typename N>
EVE_FORCEINLINE auto
sqrt_(EVE_SUPPORTS(sve_), wide<T, N> const& v) noexcept -> wide<T, N>
requires sve_abi<abi_t<T, N>>
{
return svsqrt_x(sve_true<T>(), v);
}

// -----------------------------------------------------------------------------------------------
// Masked case
template<conditional_expr C, value V>
EVE_FORCEINLINE auto
sqrt_(EVE_SUPPORTS(sve_), C const& cond, V const& v) noexcept -> V
requires sve_abi<typename V::abi_type>
{
if constexpr(C::is_complete)
{
if constexpr(C::is_inverted) return alternative(cond, v, as<V> {});
else return sqrt(v);
}
else
{
auto src = alternative(cond, v, as<V> {});
auto m = expand_mask(cond, as<V> {});
return svsqrt_m(src, m, v);
}
}
}
6 changes: 3 additions & 3 deletions include/eve/module/core/regular/impl/sqrt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

namespace eve::detail
{
template<real_value T>
template<value T>
EVE_FORCEINLINE constexpr T
sqrt_(EVE_SUPPORTS(cpu_), raw_type const&, T const& a) noexcept
{
return eve::sqrt(a);
}

template<real_value T>
template<value T>
EVE_FORCEINLINE constexpr T
sqrt_(EVE_SUPPORTS(cpu_), T const& a0) noexcept
{
Expand All @@ -35,7 +35,7 @@ sqrt_(EVE_SUPPORTS(cpu_), T const& a0) noexcept

// -----------------------------------------------------------------------------------------------
// Masked case
template<conditional_expr C, real_value U>
template<conditional_expr C, value U>
EVE_FORCEINLINE auto
sqrt_(EVE_SUPPORTS(cpu_), C const& cond, U const& t) noexcept
{
Expand Down
4 changes: 4 additions & 0 deletions include/eve/module/core/regular/sqrt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,7 @@ EVE_MAKE_CALLABLE(sqrt_, sqrt);
#if defined(EVE_INCLUDE_ARM_HEADER)
# include <eve/module/core/regular/impl/simd/arm/neon/sqrt.hpp>
#endif

#if defined(EVE_INCLUDE_SVE_HEADER)
# include <eve/module/core/regular/impl/simd/arm/sve/sqrt.hpp>
#endif

0 comments on commit 06ed099

Please sign in to comment.