| #include <riscv_vector.h> |
| #include <springbok_intrinsics.h> |
| #include <stddef.h> |
| |
| #include "pw_unit_test/framework.h" |
| #include "test_v_helpers.h" |
| |
| namespace vle_vse_test { |
| namespace { |
| |
| using namespace test_v_helpers; |
| |
| uint8_t test_vector_1[MAXVL_BYTES]; |
| uint8_t test_vector_2[MAXVL_BYTES]; |
| |
| static void vlevse_test(VSEW sew, VLMUL lmul, bool use_intrinsic) { |
| for (int i = 0; i <= AVL_COUNT; ++i) { |
| zero_vector_registers(); |
| int32_t avl = AVLS[i]; |
| int vlmax; |
| int vl; |
| std::tie(vlmax, vl) = vector_test_setup<uint8_t>( |
| lmul, avl, {test_vector_1, test_vector_2}); |
| if (avl > vlmax) { |
| continue; |
| } |
| fill_random_vector<uint8_t>(test_vector_1, vl); |
| |
| // load c-array values into vector |
| // TODO(gkielian): utilize intrinsics for vle |
| if (use_intrinsic) { |
| } else { |
| __asm__ volatile("vle8.v v0, (%0)" : : "r"(test_vector_1)); |
| |
| // 2) store the vector back into memory (into result c-array) |
| __asm__ volatile("vse8.v v0, (%0)" : : "r"(test_vector_2)); |
| } |
| assert_vec_elem_eq<uint8_t>(vl, test_vector_1, test_vector_2); |
| } |
| } |
| |
| TEST(VleVseTest, vle8vse8_e8m1) { |
| vlevse_test(VSEW::SEW_E8, VLMUL::LMUL_M1, false); |
| } |
| |
| TEST(VleVseTest, vle8vse8_e8m2) { |
| vlevse_test(VSEW::SEW_E8, VLMUL::LMUL_M2, false); |
| } |
| |
| TEST(VleVseTest, vle8vse8_e8m4) { |
| vlevse_test(VSEW::SEW_E8, VLMUL::LMUL_M4, false); |
| } |
| |
| TEST(VleVseTest, vle8vse8_e8m8) { |
| vlevse_test(VSEW::SEW_E8, VLMUL::LMUL_M8, false); |
| } |
| |
| } // namespace |
| } // namespace vle_vse_test |