| #include <springbok.h> |
| #include <stdint.h> |
| #include <stdio.h> |
| #include <stdlib.h> |
| |
| #include "pw_unit_test/framework.h" |
| #include "softrvv.h" |
| |
| namespace softrvv_vmax_test { |
| namespace { |
| |
| // common to all tests |
| int32_t src1[] = {-1, 2, 3, 4, 5}; |
| |
| // vector test |
| int32_t src2[] = {5, 4, 3, 2, -1}; |
| |
| // scalar register tests |
| int32_t rs1[] = {-1, 3, 5}; |
| |
| }; // namespace |
| const int32_t kAVL = sizeof(src1) / sizeof(src1[0]); |
| int32_t dest[kAVL]; |
| |
| int32_t ref_vv[] = {5, 4, 3, 4, 5}; |
| |
| int32_t ref_vx[3][kAVL] = {{-1, 2, 3, 4, 5}, {3, 3, 3, 4, 5}, {5, 5, 5, 5, 5}}; |
| |
| class SoftRvvVmaxTest : public ::testing::Test { |
| protected: |
| void SetUp() override { memset(dest, 0, sizeof(dest)); } |
| }; |
| |
| TEST_F(SoftRvvVmaxTest, VV) { |
| softrvv::vmax_vv<int32_t>(dest, src1, src2, kAVL); |
| ASSERT_EQ(memcmp(dest, ref_vv, sizeof(dest)), 0); |
| } |
| |
| TEST_F(SoftRvvVmaxTest, VX) { |
| const int32_t num_vx_tests = sizeof(rs1) / sizeof(rs1[0]); |
| for (int32_t i = 0; i < num_vx_tests; i++) { |
| softrvv::vmax_vx<int32_t>(dest, src1, &rs1[i], kAVL); |
| ASSERT_EQ(memcmp(dest, &ref_vx[i], sizeof(dest)), 0); |
| } |
| } |
| |
| } // namespace softrvv_vmax_test |