| <%def name="test_opivv_opivx(dtype, op, src1, src2, rs1, ref_vv, ref_vx)"> |
| <% |
| |
| def to_carr_str(arr): |
| return ", ".join(("%s" % x for x in arr)) |
| |
| src1 = to_carr_str(src1) |
| src2 = to_carr_str(src2) |
| ref_vv = to_carr_str(ref_vv) |
| ref_vx = to_carr_str(ref_vx) |
| %> |
| namespace softrvv_${op}_test { |
| namespace { |
| |
| ${dtype} src1[] = {${src1}}; |
| ${dtype} src2[] = {${src2}}; |
| ${dtype} rs1 = ${rs1}; |
| const ${dtype} kAVL = sizeof(src1)/sizeof(src1[0]); |
| ${dtype} dest[kAVL]; |
| |
| ${dtype} ref_vv[] = {${ref_vv}}; |
| ${dtype} ref_vx[] = {${ref_vx}}; |
| |
| template <typename T> |
| void assert_vec_elem_eq(int avl, void *test_vector_1, void *test_vector_2) { |
| T *ptr_vec_1 = reinterpret_cast<T *>(test_vector_1); |
| T *ptr_vec_2 = reinterpret_cast<T *>(test_vector_2); |
| for (int idx = 0; idx < avl; idx++) { |
| ASSERT_EQ(ptr_vec_1[idx], ptr_vec_2[idx]); |
| } |
| } |
| |
| class SoftRvv${op.capitalize()}Test : public ::testing::Test { |
| protected: |
| void SetUp() override { memset(dest, 0, sizeof(dest)); } |
| }; |
| |
| TEST_F(SoftRvv${op.capitalize()}Test, VV) { |
| softrvv::${op}_vv<${dtype}>(dest, src1, src2, kAVL); |
| assert_vec_elem_eq<${dtype}>(kAVL, dest, ref_vv); |
| } |
| |
| TEST_F(SoftRvv${op.capitalize()}Test, VX) { |
| softrvv::${op}_vx<${dtype}>(dest, src1, &rs1, kAVL); |
| assert_vec_elem_eq<${dtype}>(kAVL, dest, ref_vx); |
| } |
| |
| } // namespace |
| } // namespace softrvv_${op}_test |
| </%def> |