From e9e7fe89d401120cb1807c56c8d651872a2c20dd Mon Sep 17 00:00:00 2001 From: Ivan Tetyushkin Date: Tue, 9 Jan 2024 18:31:48 +0300 Subject: [PATCH] review fixes 090124 --- include/eve/arch/riscv/tags.hpp | 4 +- .../eve/detail/function/simd/riscv/load.hpp | 2 +- test/unit/memory/load/tuple.cpp | 10 +- .../algorithm/min_element_special_cases.cpp | 119 ++++++++++-------- 4 files changed, 73 insertions(+), 62 deletions(-) diff --git a/include/eve/arch/riscv/tags.hpp b/include/eve/arch/riscv/tags.hpp index 10efc97460a..9ef925e61db 100644 --- a/include/eve/arch/riscv/tags.hpp +++ b/include/eve/arch/riscv/tags.hpp @@ -100,13 +100,13 @@ struct rvv_api_ : simd_api }; //================================================================================================ -// 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 concept rvv_abi = detail::is_one_of(detail::types {}); diff --git a/include/eve/detail/function/simd/riscv/load.hpp b/include/eve/detail/function/simd/riscv/load.hpp index 910525b6857..38d986f892c 100644 --- a/include/eve/detail/function/simd/riscv/load.hpp +++ b/include/eve/detail/function/simd/riscv/load.hpp @@ -23,7 +23,7 @@ template EVE_FORCEINLINE wide perform_load(logical> mask, as> tgt, PtrTy p) { - auto zero_init = make(as> {}, static_cast(0)); + wide zero_init {0}; constexpr auto c = categorize>(); if constexpr( match(c, category::size8_) ) return __riscv_vle8_tumu(mask, zero_init, p, N::value); if constexpr( match(c, category::size16_) ) diff --git a/test/unit/memory/load/tuple.cpp b/test/unit/memory/load/tuple.cpp index a5a00ca79c5..312ad95a003 100644 --- a/test/unit/memory/load/tuple.cpp +++ b/test/unit/memory/load/tuple.cpp @@ -45,13 +45,13 @@ TTS_CASE_TPL( "Check load behavior with soa_ptr", eve::test::scalar::all_types) , reference.storage() )}; - auto [data0,idx0] = page(); - auto [data1,idx1] = page(); - auto [data2,idx2] = page(); + auto [data0,idx0] = page(); + auto [data1,idx1] = page(); + auto [data2,idx2] = page(); - 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{}) ); diff --git a/test/unit/module/algo/algorithm/min_element_special_cases.cpp b/test/unit/module/algo/algorithm/min_element_special_cases.cpp index b67ef057288..2c43d042955 100644 --- a/test/unit/module/algo/algorithm/min_element_special_cases.cpp +++ b/test/unit/module/algo/algorithm/min_element_special_cases.cpp @@ -11,74 +11,85 @@ #include -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] // + [eve::algo::index_type] // [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 v(1000u, 1); - v.back() = 0; - TTS_EQUAL(999, alg(v) - v.begin()); - } - { - std::vector v(std::numeric_limits::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 v; - v.resize(48, 'b'); - v[23] = 'a'; - v[47] = 'a'; - TTS_EQUAL(23, alg(v) - v.begin()); - } - { - std::vector v; - v.resize(159, 'b'); - v[2] = 'a'; - v.back() = 'a'; - std::span 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 v(1000u, 1); + v.back() = 0; + TTS_EQUAL(999, alg(v) - v.begin()); + } + { + std::vector v(std::numeric_limits::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 v; + v.resize(48, 'b'); + v[23] = 'a'; + v[47] = 'a'; + TTS_EQUAL(23, alg(v) - v.begin()); + } + { + std::vector v; + v.resize(159, 'b'); + v[2] = 'a'; + v.back() = 'a'; + std::span 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] // + [eve::algo::index_type] // [eve::algo::unroll<2>]; + if constexpr( eve::current_api != eve::rvv ) + { + std::vector v; + v.resize(300); - std::vector 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 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 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."); } };