Skip to content

Commit

Permalink
review fixes 090124
Browse files Browse the repository at this point in the history
  • Loading branch information
ita-sc committed Jan 9, 2024
1 parent c074d2e commit e9e7fe8
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 62 deletions.
4 changes: 2 additions & 2 deletions include/eve/arch/riscv/tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ struct rvv_api_ : simd_api<rvv_, spy::rvv_>
};

//================================================================================================
// SVE extensions tag objects
// RISC-V extensions tag objects
//================================================================================================
inline constexpr rvv_ rvv = {};
inline constexpr rvv_api_ rvv_api = {};

//================================================================================================
// RISCV RVV ABI concept
// RISC-V RVV ABI concept
//================================================================================================
template<typename T>
concept rvv_abi = detail::is_one_of<T>(detail::types<riscv_rvv_dyn_> {});
Expand Down
2 changes: 1 addition & 1 deletion include/eve/detail/function/simd/riscv/load.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ template<arithmetic_scalar_value T, typename N, typename PtrTy>
EVE_FORCEINLINE wide<T, N>
perform_load(logical<wide<T, N>> mask, as<wide<T, N>> tgt, PtrTy p)
{
auto zero_init = make(as<wide<T, N>> {}, static_cast<T>(0));
wide<T, N> zero_init {0};
constexpr auto c = categorize<wide<T, N>>();
if constexpr( match(c, category::size8_) ) return __riscv_vle8_tumu(mask, zero_init, p, N::value);
if constexpr( match(c, category::size16_) )
Expand Down
10 changes: 5 additions & 5 deletions test/unit/memory/load/tuple.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ TTS_CASE_TPL( "Check load behavior with soa_ptr", eve::test::scalar::all_types)
, reference.storage()
)};

auto [data0,idx0] = page<std::int8_t , typename w_t::cardinal_type >();
auto [data1,idx1] = page<T , typename w_t::cardinal_type >();
auto [data2,idx2] = page<double , typename w_t::cardinal_type >();
auto [data0,idx0] = page<std::int8_t , typename w8_t::cardinal_type >();
auto [data1,idx1] = page<T , typename w8_t::cardinal_type >();
auto [data2,idx2] = page<double , typename w8_t::cardinal_type >();

auto src = eve::soa_ptr ( eve::as_aligned(&data0[idx0],typename w_t::cardinal_type{})
auto src = eve::soa_ptr ( eve::as_aligned(&data0[idx0],typename w8_t::cardinal_type{})
, &data1[idx1] - 1
, eve::as_aligned(&data2[idx2],typename w_t::cardinal_type{})
, eve::as_aligned(&data2[idx2],typename w8_t::cardinal_type{})
);


Expand Down
119 changes: 65 additions & 54 deletions test/unit/module/algo/algorithm/min_element_special_cases.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,74 +11,85 @@

#include <span>

TTS_CASE("Min element one pass, uint16 index")
TTS_CASE("Min element one pass, uint8 index")
{
auto alg = eve::algo::min_element //
[eve::algo::single_pass] //
[eve::algo::index_type<std::uint16_t>] //
[eve::algo::index_type<std::uint8_t>] //
[eve::algo::unroll<2>];
if constexpr( eve::current_api != eve::rvv )
{
std::vector v {1, 2, 3};
TTS_EQUAL(0, alg(v) - v.begin());
}
{
std::vector v {2, 1, 3};
TTS_EQUAL(1, alg(v) - v.begin());
}
{
std::vector v {3, 2, 1};
TTS_EQUAL(2, alg(v) - v.begin());
}
{
std::vector<std::int8_t> v(1000u, 1);
v.back() = 0;
TTS_EQUAL(999, alg(v) - v.begin());
}
{
std::vector<std::int8_t> v(std::numeric_limits<std::uint16_t>::max() + 1, 'b');
v.back() = 'a';
v[5] = 'a';
TTS_EQUAL(5, alg(v) - v.begin());
v[5] = 'b';
TTS_EQUAL(std::ssize(v) - 1, alg(v) - v.begin());
}
{
std::vector<std::int8_t> v;
v.resize(48, 'b');
v[23] = 'a';
v[47] = 'a';
TTS_EQUAL(23, alg(v) - v.begin());
}
{
std::vector<std::int8_t> v;
v.resize(159, 'b');
v[2] = 'a';
v.back() = 'a';
std::span<std::int8_t> s(v.begin() + 1, v.end());
TTS_EQUAL(1, alg(s) - s.begin());
{
std::vector v {1, 2, 3};
TTS_EQUAL(0, alg(v) - v.begin());
}
{
std::vector v {2, 1, 3};
TTS_EQUAL(1, alg(v) - v.begin());
}
{
std::vector v {3, 2, 1};
TTS_EQUAL(2, alg(v) - v.begin());
}
{
std::vector<std::int8_t> v(1000u, 1);
v.back() = 0;
TTS_EQUAL(999, alg(v) - v.begin());
}
{
std::vector<std::int8_t> v(std::numeric_limits<std::uint16_t>::max() + 1, 'b');
v.back() = 'a';
v[5] = 'a';
TTS_EQUAL(5, alg(v) - v.begin());
v[5] = 'b';
TTS_EQUAL(std::ssize(v) - 1, alg(v) - v.begin());
}
{
std::vector<std::int8_t> v;
v.resize(48, 'b');
v[23] = 'a';
v[47] = 'a';
TTS_EQUAL(23, alg(v) - v.begin());
}
{
std::vector<std::int8_t> v;
v.resize(159, 'b');
v[2] = 'a';
v.back() = 'a';
std::span<std::int8_t> s(v.begin() + 1, v.end());
TTS_EQUAL(1, alg(s) - s.begin());
}
}
else { TTS_PASS("For RISC-V uint8 not enough to store element index."); }
};

TTS_CASE("Min element one pass, uint16 index, first one is the answer") {
TTS_CASE("Min element one pass, uint8 index, first one is the answer")
{
auto alg = eve::algo::min_element //
[eve::algo::single_pass] //
[eve::algo::index_type<std::uint16_t>] //
[eve::algo::index_type<std::uint8_t>] //
[eve::algo::unroll<2>];
if constexpr( eve::current_api != eve::rvv )
{
std::vector<std::int8_t> v;
v.resize(300);

std::vector<std::int8_t> v;
v.resize(300);

for (int i = 0; i != 16; ++i) {
for (int j = 0; j != 16; ++j) {
eve::algo::fill(v, 0);
std::span<std::int8_t> sub(v.begin() + i, v.end() - j);
eve::algo::fill(sub, -1);
for( int i = 0; i != 16; ++i )
{
for( int j = 0; j != 16; ++j )
{
eve::algo::fill(v, 0);
std::span<std::int8_t> sub(v.begin() + i, v.end() - j);
eve::algo::fill(sub, -1);

for (std::int8_t& x: sub) {
std::int8_t* found = std::to_address(alg(sub));
TTS_EQUAL(found, &x);
x = 0;
for( std::int8_t& x : sub )
{
std::int8_t *found = std::to_address(alg(sub));
TTS_EQUAL(found, &x);
x = 0;
}
}
}
}
else { TTS_PASS("For RISC-V uint8 not enough to store element index."); }
};

0 comments on commit e9e7fe8

Please sign in to comment.