-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move self_leq to the is_less_equal callable (#2054)
- Loading branch information
1 parent
a1088f6
commit bd25bb6
Showing
18 changed files
with
329 additions
and
248 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <eve/module/core/regular/fam.hpp> | ||
#include <eve/module/core/regular/next.hpp> | ||
#include <eve/module/core/regular/max.hpp> | ||
#include <eve/traits/as_logical.hpp> | ||
|
||
namespace eve::detail | ||
{ | ||
template<callable_options O, typename T> | ||
EVE_FORCEINLINE constexpr as_logical_t<T> is_less_equal_(EVE_REQUIRES(cpu_), O const& o, T a, T b) noexcept | ||
{ | ||
if constexpr (O::contains(almost)) | ||
{ | ||
auto tol = o[almost].value(T{}); | ||
if constexpr(integral_value<decltype(tol)>) return a <= eve::next(b, tol); | ||
else return a <= fam(b, tol, eve::max(eve::abs(a), eve::abs(b))); | ||
} | ||
else if constexpr (product_type<T>) | ||
{ | ||
return kumi::to_tuple(a) <= kumi::to_tuple(b); | ||
} | ||
else | ||
{ | ||
if constexpr (scalar_value<T>) return as_logical_t<T>(a <= b); | ||
else return map([]<typename E>(E e, E f){ return as_logical_t<E>(e <= f); }, a, b); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
include/eve/module/core/regular/impl/simd/arm/neon/is_less_equal.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <eve/concept/value.hpp> | ||
#include <eve/detail/abi.hpp> | ||
#include <eve/detail/category.hpp> | ||
#include <eve/forward.hpp> | ||
|
||
namespace eve::detail | ||
{ | ||
template<callable_options O, arithmetic_scalar_value T, typename N> | ||
EVE_FORCEINLINE logical<wide<T, N>> is_less_equal_(EVE_REQUIRES(neon128_), O const& opts, wide<T, N> a, wide<T, N> b) noexcept | ||
requires arm_abi<abi_t<T, N>> | ||
{ | ||
if constexpr (O::contains(almost)) | ||
{ | ||
return is_less_equal.behavior(cpu_{}, opts, a, b); | ||
} | ||
else | ||
{ | ||
constexpr auto cat = categorize<wide<T, N>>(); | ||
|
||
if constexpr (cat == category::int32x4) return vcleq_s32(a, b); | ||
else if constexpr (cat == category::int16x8) return vcleq_s16(a, b); | ||
else if constexpr (cat == category::int8x16) return vcleq_s8(a, b); | ||
else if constexpr (cat == category::uint32x4) return vcleq_u32(a, b); | ||
else if constexpr (cat == category::uint16x8) return vcleq_u16(a, b); | ||
else if constexpr (cat == category::uint8x16) return vcleq_u8(a, b); | ||
else if constexpr (cat == category::float32x4) return vcleq_f32(a, b); | ||
else if constexpr (cat == category::int32x2) return vcle_s32(a, b); | ||
else if constexpr (cat == category::int16x4) return vcle_s16(a, b); | ||
else if constexpr (cat == category::int8x8) return vcle_s8(a, b); | ||
else if constexpr (cat == category::uint32x2) return vcle_u32(a, b); | ||
else if constexpr (cat == category::uint16x4) return vcle_u16(a, b); | ||
else if constexpr (cat == category::uint8x8) return vcle_u8(a, b); | ||
else if constexpr (cat == category::float32x2) return vcle_f32(a, b); | ||
else if constexpr (current_api >= asimd) | ||
{ | ||
if constexpr (cat == category::float64x1) return vcle_f64(a, b); | ||
else if constexpr (cat == category::int64x1) return vcle_s64(a, b); | ||
else if constexpr (cat == category::uint64x1) return vcle_u64(a, b); | ||
else if constexpr (cat == category::float64x2) return vcleq_f64(a, b); | ||
else if constexpr (cat == category::int64x2) return vcleq_s64(a, b); | ||
else if constexpr (cat == category::uint64x2) return vcleq_u64(a, b); | ||
} | ||
else return map([]<typename E>(E e, E f){ return as_logical_t<E>(e <= f); }, a, b); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
include/eve/module/core/regular/impl/simd/arm/sve/is_less_equal.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <eve/concept/value.hpp> | ||
#include <eve/detail/implementation.hpp> | ||
|
||
namespace eve::detail | ||
{ | ||
template<callable_options O, typename T, typename N> | ||
EVE_FORCEINLINE logical<wide<T, N>> is_less_equal_(EVE_REQUIRES(sve_), O const& opts, wide<T, N> a, wide<T, N> b) noexcept | ||
requires sve_abi<abi_t<T, N>> | ||
{ | ||
if constexpr (O::contains(almost)) return is_less_equal.behavior(cpu_{}, opts, a, b); | ||
else return svcmple(sve_true<T>(), a, b); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
include/eve/module/core/regular/impl/simd/ppc/is_less_equal.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <eve/concept/value.hpp> | ||
#include <eve/detail/abi.hpp> | ||
#include <eve/detail/category.hpp> | ||
#include <eve/forward.hpp> | ||
|
||
namespace eve::detail | ||
{ | ||
template<callable_options O, arithmetic_scalar_value T, typename N> | ||
EVE_FORCEINLINE logical<wide<T, N>> is_less_equal_(EVE_REQUIRES(vmx_), O const& opts, wide<T, N> a, wide<T, N> b) noexcept | ||
requires ppc_abi<abi_t<T, N>> | ||
{ | ||
if constexpr (O::contains(almost)) return is_less_equal.behavior(cpu_{}, opts, a, b); | ||
else if constexpr(std::is_floating_point_v<T>) return logical<wide<T, N>>(vec_cmple(a.storage(), b.storage())); | ||
else return !(a > b); | ||
} | ||
} |
Oops, something went wrong.