-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
405 additions
and
0 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
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/category.hpp> | ||
#include <eve/detail/implementation.hpp> | ||
|
||
namespace eve::detail | ||
{ | ||
|
||
template<scalar_value T, typename N> | ||
EVE_FORCEINLINE auto | ||
abs_(EVE_SUPPORTS(rvv_), wide<T, N> const& a) noexcept -> wide<T, N> | ||
requires rvv_abi<abi_t<T, N>> && (match(categorize<wide<T, N>>(), category::float_)) | ||
{ | ||
return __riscv_vfabs(a, N::value); | ||
} | ||
|
||
template<scalar_value T, typename N> | ||
EVE_FORCEINLINE auto | ||
abs_(EVE_SUPPORTS(rvv_), wide<T, N> const& a) noexcept -> wide<T, N> | ||
requires rvv_abi<abi_t<T, N>> && (match(categorize<wide<T, N>>(), category::int_)) | ||
{ | ||
wide<T, N> negative_values = __riscv_vneg(a, N::value); | ||
logical<wide<T, N>> need_to_change_mask = self_less(a, static_cast<T>(0)); | ||
return if_else(need_to_change_mask, negative_values, a); | ||
} | ||
|
||
template<conditional_expr C, scalar_value T, typename N> | ||
EVE_FORCEINLINE auto | ||
abs_(EVE_SUPPORTS(rvv_), C const& cx, wide<T, N> const& v) noexcept -> wide<T, N> | ||
requires rvv_abi<abi_t<T, N>> | ||
{ | ||
constexpr auto c = categorize<wide<T, N>>(); | ||
if constexpr( C::is_complete ) return abs_(EVE_RETARGET(cpu_), cx, v); | ||
else | ||
{ | ||
auto mask = expand_mask(cx, as<wide<T, N>> {}); | ||
if constexpr( match(c, category::float_) ) { return __riscv_vfabs_tumu(mask, v, v, N::value); } | ||
if constexpr( match(c, category::int_) ) | ||
{ | ||
wide<T, N> negative_values = __riscv_vneg(v, N::value); | ||
logical<wide<T, N>> need_to_change_mask = self_less(v, static_cast<T>(0)); | ||
logical<wide<T, N>> mask_to_update = __riscv_vmand(mask, need_to_change_mask, N::value); | ||
return if_else(mask_to_update, negative_values, v); | ||
} | ||
} | ||
} | ||
} |
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,34 @@ | ||
//================================================================================================== | ||
/* | ||
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<conditional_expr C, typename T, typename N> | ||
EVE_FORCEINLINE wide<T, N> | ||
add_(EVE_SUPPORTS(rvv_), C const &cx, wide<T, N> v, wide<T, N> w) noexcept | ||
requires rvv_abi<abi_t<T, N>> | ||
{ | ||
if constexpr( C::is_complete ) { return add_(EVE_RETARGET(cpu_), cx, v, w); } | ||
else | ||
{ | ||
if constexpr( !C::has_alternative ) | ||
{ | ||
auto m = expand_mask(cx, as<wide<T, N>> {}); | ||
constexpr auto c = categorize<wide<T, N>>(); | ||
if constexpr( match(c, category::float_) ) return __riscv_vfadd_tumu(m, v, v, w, N::value); | ||
else return __riscv_vadd_tumu(m, v, v, w, N::value); | ||
} | ||
else return add_(EVE_RETARGET(cpu_), cx, v, w); | ||
} | ||
} | ||
} |
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,28 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <eve/detail/has_abi.hpp> | ||
#include <eve/detail/implementation.hpp> | ||
#include <eve/module/core/regular/count_true.hpp> | ||
|
||
namespace eve::detail | ||
{ | ||
template<scalar_value T, typename N, relative_conditional_expr C> | ||
EVE_FORCEINLINE bool | ||
all_(EVE_SUPPORTS(rvv_), C const& cond, logical<wide<T, N>> const& v) noexcept | ||
requires rvv_abi<abi_t<T, N>> | ||
{ | ||
if constexpr( C::is_complete ) | ||
{ | ||
if constexpr( C::is_inverted ) return __riscv_vcpop(v, N::value) == N::value; | ||
else return true; | ||
} | ||
else return count_true(cond, v) == cond.count(as<wide<T, N>>()); | ||
} | ||
} |
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,27 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <eve/detail/has_abi.hpp> | ||
#include <eve/detail/implementation.hpp> | ||
|
||
namespace eve::detail | ||
{ | ||
template<scalar_value T, typename N, relative_conditional_expr C> | ||
EVE_FORCEINLINE bool | ||
any_(EVE_SUPPORTS(rvv_), C const& cond, logical<wide<T, N>> v) noexcept | ||
requires rvv_abi<abi_t<T, N>> | ||
{ | ||
if constexpr( C::is_complete && !C::is_inverted ) return false; | ||
else | ||
{ | ||
auto m = expand_mask(cond, as<wide<T, N>> {}); | ||
return __riscv_vcpop(m, v, N::value) > 0; | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
include/eve/module/core/regular/impl/simd/riscv/bit_and.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,58 @@ | ||
//================================================================================================== | ||
/* | ||
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/overload.hpp> | ||
#include <eve/forward.hpp> | ||
namespace eve ::detail | ||
{ | ||
// ----------------------------------------------------------------------------------------------- | ||
// Masked case | ||
template<conditional_expr C, arithmetic_scalar_value T, typename N> | ||
EVE_FORCEINLINE wide<T, N> | ||
bit_and_(EVE_SUPPORTS(rvv_), C const& cx, wide<T, N> const& v0, wide<T, N> const& v1) noexcept | ||
requires rvv_abi<abi_t<T, N>> | ||
{ | ||
constexpr auto c = categorize<wide<T, N>>(); | ||
|
||
if constexpr( C::is_complete || abi_t<T, N>::is_wide_logical ) | ||
{ | ||
return bit_and_(EVE_RETARGET(cpu_), cx, v0, v1); | ||
} | ||
else | ||
{ | ||
auto m = expand_mask(cx, as<wide<T, N>> {}); | ||
using sign = unsigned; | ||
using out_part_scalar = as_integer_t<T, sign>; | ||
using out_part_wide = wide<out_part_scalar, N>; | ||
auto part_tgt = as<out_part_wide> {}; | ||
auto v0_int = bit_cast(v0, part_tgt); | ||
auto v1_int = bit_cast(v1, part_tgt); | ||
out_part_wide part_res = __riscv_vand_tumu(m, v0_int, v0_int, v1_int, N::value); | ||
return bit_cast(part_res, as<wide<T, N>> {}); | ||
} | ||
} | ||
// ----------------------------------------------------------------------------------------------- | ||
// Masked case | ||
template<arithmetic_scalar_value T, typename N> | ||
EVE_FORCEINLINE wide<T, N> | ||
bit_and_(EVE_SUPPORTS(rvv_), wide<T, N> const &v0, wide<T, N> const &v1) noexcept | ||
requires rvv_abi<abi_t<T, N>> | ||
{ | ||
using sign = unsigned; | ||
using out_part_scalar = as_integer_t<T, sign>; | ||
using out_part_wide = wide<out_part_scalar, N>; | ||
auto part_tgt = as<out_part_wide> {}; | ||
auto v0_int = bit_cast(v0, part_tgt); | ||
auto v1_int = bit_cast(v1, part_tgt); | ||
out_part_wide part_res = __riscv_vand(v0_int, v1_int, N::value); | ||
return bit_cast(part_res, as<wide<T, N>> {}); | ||
} | ||
} |
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,34 @@ | ||
//================================================================================================== | ||
/* | ||
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<conditional_expr C, arithmetic_scalar_value T, typename N> | ||
EVE_FORCEINLINE wide<T, N> | ||
div_(EVE_SUPPORTS(rvv_), C const& cx, wide<T, N> const& v, wide<T, N> const& w) noexcept | ||
requires rvv_abi<abi_t<T, N>> | ||
{ | ||
if constexpr( C::is_complete ) { return div_(EVE_RETARGET(cpu_), cx, v, w); } | ||
else | ||
{ | ||
if constexpr( !C::has_alternative ) | ||
{ | ||
auto m = expand_mask(cx, as<wide<T, N>> {}); | ||
constexpr auto c = categorize<wide<T, N>>(); | ||
if constexpr( match(c, category::int_) ) return __riscv_vdiv_tumu(m, v, v, w, N::value); | ||
else if constexpr( match(c, category::uint_) ) return __riscv_vdivu_tumu(m, v, v, w, N::value); | ||
else if constexpr( match(c, category::float_) ) return __riscv_vfdiv_tumu(m, v, v, w, N::value); | ||
} | ||
else return div_(EVE_RETARGET(cpu_), cx, v, w); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
include/eve/module/core/regular/impl/simd/riscv/logical_xor.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,20 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
namespace eve::detail | ||
{ | ||
template<arithmetic_scalar_value T, typename N, scalar_value U> | ||
EVE_FORCEINLINE logical<wide<T, N>> | ||
logical_xor_(EVE_SUPPORTS(rvv_), | ||
logical<wide<T, N>> const &a, | ||
logical<wide<U, N>> const &b) noexcept | ||
requires rvv_abi<abi_t<T, N>> | ||
{ | ||
return a != bit_cast(b, as<logical<wide<T, N>>> {}); | ||
} | ||
} |
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,35 @@ | ||
//================================================================================================== | ||
/* | ||
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<conditional_expr C, typename T, typename N> | ||
EVE_FORCEINLINE wide<T, N> | ||
max_(EVE_SUPPORTS(rvv_), C const &cx, wide<T, N> v, wide<T, N> w) noexcept | ||
requires rvv_abi<abi_t<T, N>> | ||
{ | ||
if constexpr( C::is_complete ) { return max_(EVE_RETARGET(cpu_), cx, v, w); } | ||
else | ||
{ | ||
if constexpr( !C::has_alternative ) | ||
{ | ||
auto m = expand_mask(cx, as<wide<T, N>> {}); | ||
constexpr auto c = categorize<wide<T, N>>(); | ||
if constexpr( match(c, category::float_) ) return __riscv_vfmax_tumu(m, v, v, w, N::value); | ||
else if constexpr( match(c, category::int_) ) return __riscv_vmax_tumu(m, v, v, w, N::value); | ||
else if constexpr( match(c, category::uint_) ) return __riscv_vmaxu_tumu(m, v, v, w, N::value); | ||
} | ||
else return max_(EVE_RETARGET(cpu_), cx, v, w); | ||
} | ||
} | ||
} |
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,43 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Project Contributors | ||
SPDX-License-Identifier: BSL-1.0 | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <eve/concept/value.hpp> | ||
#include <eve/detail/category.hpp> | ||
#include <eve/detail/implementation.hpp> | ||
|
||
namespace eve::detail | ||
{ | ||
template<scalar_value T, typename N> | ||
EVE_FORCEINLINE auto | ||
min_(EVE_SUPPORTS(rvv_), wide<T, N> const& a, wide<T, N> const& b) noexcept -> wide<T, N> | ||
requires rvv_abi<abi_t<T, N>> | ||
{ | ||
constexpr auto c = categorize<wide<T, N>>(); | ||
if constexpr( match(c, category::float_) ) return __riscv_vfmin_tu(a, a, b, N::value); | ||
else if constexpr( match(c, category::int_) ) | ||
{ | ||
wide<T, N> res = __riscv_vmin_tu(a, a, b, N::value); | ||
return res; | ||
} | ||
else if constexpr( match(c, category::uint_) ) return __riscv_vminu_tu(a, a, b, N::value); | ||
} | ||
|
||
template<conditional_expr C, arithmetic_scalar_value T, typename N> | ||
EVE_FORCEINLINE auto | ||
min_(EVE_SUPPORTS(rvv_), C const& cx, wide<T, N> const& v, wide<T, N> const& w) noexcept | ||
-> wide<T, N> | ||
{ | ||
auto mask = expand_mask(cx, as<wide<T, N>> {}); | ||
constexpr auto c = categorize<wide<T, N>>(); | ||
if constexpr( match(c, category::float_) ) return __riscv_vfmin_tumu(mask, v, v, w, N::value); | ||
else if constexpr( match(c, category::int_) ) return __riscv_vmin_tumu(mask, v, v, w, N::value); | ||
else if constexpr( match(c, category::uint_) ) return __riscv_vminu_tumu(mask, v, v, w, N::value); | ||
} | ||
|
||
} |
Oops, something went wrong.