blob: 1df04486471c1b2e3305a1b6c5393657eeb9f166 [file] [log] [blame]
/* Automatically generated file */
#include <limits.h>
#include <riscv_vector.h>
#include <softrvv.h>
#include <springbok.h>
#include <stdio.h>
#include <stdlib.h>
#include <bit>
#include <tuple>
#include "pw_unit_test/framework.h"
#include "test_v_helpers.h"
namespace ${op_code}_vv_test {
namespace {
using namespace test_v_helpers;
uint8_t src_vector_1[MAXVL_BYTES];
uint8_t src_vector_2[MAXVL_BYTES];
uint8_t dest_vector[MAXVL_BYTES];
uint8_t ref_dest_vector[MAXVL_BYTES];
class ${op_code.capitalize()}Test : public ::testing::Test {
protected:
void SetUp() override { zero_vector_registers(); }
void TearDown() override { zero_vector_registers(); }
};
% for sew in [8, 16, 32]:
% for lmul in [1, 2, 4, 8]:
<%
var_type = "int%d_t" % sew
%>\
TEST_F(${op_code.capitalize()}Test, ${op_code.lower()}_vv${sew}m${lmul}) {
for (int i = 0; i < AVL_COUNT; i++) {
int32_t avl = AVLS[i];
int vlmax;
int vl;
std::tie(vlmax, vl) = vector_test_setup<${var_type}>(
VLMUL::LMUL_M${lmul}, avl,
{src_vector_1, src_vector_2, dest_vector, ref_dest_vector});
if (avl > vlmax) {
continue;
}
${var_type} *ptr_vec_1 = reinterpret_cast<${var_type} *>(src_vector_1);
${var_type} *ptr_vec_2 = reinterpret_cast<${var_type} *>(src_vector_2);
${var_type} *ptr_dest_vec = reinterpret_cast<${var_type} *>(dest_vector);
${var_type} *ptr_ref_dest_vec = reinterpret_cast<${var_type} *>(ref_dest_vector);
// set up values to test up to index of the AVL
fill_random_vector<${var_type}>(ptr_vec_1, avl);
fill_random_vector<${var_type}>(ptr_vec_2, avl);
memset(dest_vector, 0, MAXVL_BYTES);
memset(ref_dest_vector, 0, MAXVL_BYTES);
// Generate reference vector
softrvv::${op_code}_vv<${var_type}>(ptr_ref_dest_vec, ptr_vec_2, ptr_vec_1, avl);
// Load vector registers
__asm__ volatile("vle${sew}.v v8, (%0)" : : "r"(ptr_vec_1));
__asm__ volatile("vle${sew}.v v16, (%0)" : : "r"(ptr_vec_2));
// Run target instruction
__asm__ volatile("${op_code}.vv v24, v16, v8");
// Store result vector register
__asm__ volatile("vse${sew}.v v24, (%0)" : : "r"(ptr_dest_vec));
// Check vector elements
assert_vec_elem_eq<${var_type}>(vlmax, dest_vector, ref_dest_vector);
}
}
%endfor
%endfor
} // namespace
} // namespace ${op_code}_vv_test