Merge changes I7e7dc515,I25723c65 * changes: Move zero_registers function into test_v_helpers library. Fix formatting on vle_vse, vsetvl and test_v_helpers.
diff --git a/tests/include/test_v_helpers.h b/tests/include/test_v_helpers.h index 82818f0..8ea85ee 100644 --- a/tests/include/test_v_helpers.h +++ b/tests/include/test_v_helpers.h
@@ -6,9 +6,9 @@ namespace test_v_helpers { const int32_t AVLS[] = {1, 4, 3, 2, 16, 8, 5, 17, - 32, 36, 64, 55, 100, 321, 256, 128, - 512, 623, 1024, 1100, 1543, 2048, 3052, 4096, - 5555, 8192, 10241, 16384, 24325, 32768}; + 32, 36, 64, 55, 100, 321, 256, 128, + 512, 623, 1024, 1100, 1543, 2048, 3052, 4096, + 5555, 8192, 10241, 16384, 24325, 32768}; const int32_t AVL_COUNT = sizeof(AVLS) / sizeof(AVLS[0]); enum VSEW { @@ -50,5 +50,7 @@ int set_vsetvli(VSEW sew, VLMUL lmul, uint32_t avl); +void zero_vector_registers(); + } // namespace test_v_helpers #endif
diff --git a/tests/test_v_helpers.cpp b/tests/test_v_helpers.cpp index 9b12c15..e7dadff 100644 --- a/tests/test_v_helpers.cpp +++ b/tests/test_v_helpers.cpp
@@ -255,4 +255,14 @@ return vl; } +void zero_vector_registers() { + // Clear all vector registers + int vlmax = get_vsetvlmax_intrinsic(VSEW::SEW_E32, VLMUL::LMUL_M8); + set_vsetvl_intrinsic(VSEW::SEW_E32, VLMUL::LMUL_M8, vlmax); + __asm__ volatile("vmv.v.i v0, 0"); + __asm__ volatile("vmv.v.i v8, 0"); + __asm__ volatile("vmv.v.i v16, 0"); + __asm__ volatile("vmv.v.i v24, 0"); +} + } // namespace test_v_helpers
diff --git a/tests/vle_vse_test.cpp b/tests/vle_vse_test.cpp index 5f269da..7e5ff03 100644 --- a/tests/vle_vse_test.cpp +++ b/tests/vle_vse_test.cpp
@@ -1,9 +1,9 @@ #include <riscv_vector.h> -#include <stddef.h> #include <springbok_intrinsics.h> +#include <stddef.h> -#include "test_v_helpers.h" #include "pw_unit_test/framework.h" +#include "test_v_helpers.h" namespace vle_vse_test { namespace { @@ -21,7 +21,7 @@ static void vle8vse8_test(VSEW sew, VLMUL lmul, bool use_intrinsic) { int vlmax = get_vsetvlmax_intrinsic(sew, lmul); - for (int avl = 0; avl <= vlmax; avl+=AVL_STEP) { + for (int avl = 0; avl <= vlmax; avl += AVL_STEP) { // clear arrays memset(test_vector_1, 0, MAXVL_BYTES); memset(test_vector_2, 0, MAXVL_BYTES); @@ -35,15 +35,13 @@ // 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)); + __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)); - } - for(int idx = 0; idx < MAXVL_BYTES; idx++) - { + __asm__ volatile("vse8.v v0, (%0)" : : "r"(test_vector_2)); + } + for (int idx = 0; idx < MAXVL_BYTES; idx++) { ASSERT_EQ(test_vector_1[idx], test_vector_2[idx]); } } @@ -66,5 +64,4 @@ } } // namespace -} // namespace test_vle_vse - +} // namespace vle_vse_test
diff --git a/tests/vmv_test.cpp b/tests/vmv_test.cpp index e934f7a..ff58a2f 100644 --- a/tests/vmv_test.cpp +++ b/tests/vmv_test.cpp
@@ -21,15 +21,6 @@ uint8_t test_vector_1[MAXVL_BYTES]; uint8_t test_vector_2[MAXVL_BYTES]; -static void zero_vector_registers() { - // Clear all vector registers - int vlmax = get_vsetvlmax_intrinsic(VSEW::SEW_E32, VLMUL::LMUL_M8); - set_vsetvl_intrinsic(VSEW::SEW_E32, VLMUL::LMUL_M8, vlmax); - __asm__ volatile("vmv.v.i v0, 0"); - __asm__ volatile("vmv.v.i v8, 0"); - __asm__ volatile("vmv.v.i v16, 0"); - __asm__ volatile("vmv.v.i v24, 0"); -} template <typename T> static std::tuple<int, int> vmv_test_setup(VLMUL lmul, int32_t avl) {
diff --git a/tests/vsetvl_test.cpp b/tests/vsetvl_test.cpp index b824144..8e926c3 100644 --- a/tests/vsetvl_test.cpp +++ b/tests/vsetvl_test.cpp
@@ -3,8 +3,8 @@ #include <stdio.h> #include <stdlib.h> -#include "test_v_helpers.h" #include "pw_unit_test/framework.h" +#include "test_v_helpers.h" namespace vsetvl_test { namespace { @@ -13,7 +13,6 @@ const uint64_t VLEN = 512u; - #define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) static uint32_t calculate_vl(uint32_t sew, uint32_t avl, float lmul) { @@ -73,7 +72,7 @@ } TEST(VsetvlTest, vsetvl_e32m4) { - test_vsetvl(VSEW::SEW_E32, VLMUL::LMUL_M4, 32, 4.0); + test_vsetvl(VSEW::SEW_E32, VLMUL::LMUL_M4, 32, 4.0); } TEST(VsetvlTest, vsetvl_e8m8) { @@ -137,4 +136,4 @@ } } // namespace -} // namespace test_vsetvl +} // namespace vsetvl_test