Merge "cmake:risv_baremetal: Remove -Wno-unused-command-line-argument flag"
diff --git a/cmake/vec_cc_test.cmake b/cmake/vec_cc_test.cmake
index a76d0d2..7c36331 100644
--- a/cmake/vec_cc_test.cmake
+++ b/cmake/vec_cc_test.cmake
@@ -33,13 +33,28 @@
set(_TIMEOUT ${_RULE_TIMEOUT})
endif()
-find_program(QEMU_RV32 qemu-system-riscv32 HINTS $ENV{OUT}/host/qemu REQUIRED)
-find_program(RENODE_EXE Renode.exe HINTS $ENV{OUT}/host/renode REQUIRED)
-add_test(NAME "qemu_${_RULE_NAME}"
- COMMAND test_runner.py qemu $<TARGET_FILE:${_RULE_NAME}.elf> --qemu-path ${QEMU_RV32} --timeout=${_TIMEOUT})
-add_test(NAME "renode_${_RULE_NAME}"
- COMMAND test_runner.py renode $<TARGET_FILE:${_RULE_NAME}.elf> --renode-path ${RENODE_EXE})
-set_tests_properties("renode_${_RULE_NAME}" PROPERTIES TIMEOUT ${_TIMEOUT})
-set_tests_properties("qemu_${_RULE_NAME}" PROPERTIES TIMEOUT ${_TIMEOUT})
-
+find_program(QEMU_RV32 qemu-system-riscv32 HINTS $ENV{OUT}/host/qemu)
+if(QEMU_RV32)
+ add_test(
+ NAME
+ "qemu_${_RULE_NAME}"
+ COMMAND
+ test_runner.py qemu $<TARGET_FILE:${_RULE_NAME}.elf> --qemu-path ${QEMU_RV32} --timeout=${_TIMEOUT}
+ )
+ set_tests_properties("qemu_${_RULE_NAME}" PROPERTIES TIMEOUT ${_TIMEOUT})
+else()
+ message(WARNING "qemu-system-riscv32 doesn't exist. Make sure you build qemu first and start a clean build to enable the qemu test")
+endif()
+find_program(RENODE_EXE Renode.exe HINTS $ENV{OUT}/host/renode)
+if(RENODE_EXE)
+ add_test(
+ NAME
+ "renode_${_RULE_NAME}"
+ COMMAND
+ test_runner.py renode $<TARGET_FILE:${_RULE_NAME}.elf> --renode-path ${RENODE_EXE}
+ )
+ set_tests_properties("renode_${_RULE_NAME}" PROPERTIES TIMEOUT ${_TIMEOUT})
+else()
+ message(WARNING "Renode.exe doesn't exist. Make sure you build renode first and start a clean build to enable the renode test")
+endif()
endfunction()
diff --git a/softrvv/CMakeLists.txt b/softrvv/CMakeLists.txt
index 4700e7d..76a12e8 100644
--- a/softrvv/CMakeLists.txt
+++ b/softrvv/CMakeLists.txt
@@ -20,5 +20,16 @@
DEPS
softrvv
LINKOPTS
- -Xlinker --defsym=__itcm_length__=256K
+ -Xlinker --defsym=__itcm_length__=128K
+)
+
+vec_cc_test(
+ NAME
+ softrvv_vsub
+ SRCS
+ tests/softrvv_vsub_test.cpp
+ DEPS
+ softrvv
+ LINKOPTS
+ -Xlinker --defsym=__itcm_length__=128K
)
\ No newline at end of file
diff --git a/softrvv/include/softrvv.h b/softrvv/include/softrvv.h
index b585b19..18402a6 100644
--- a/softrvv/include/softrvv.h
+++ b/softrvv/include/softrvv.h
@@ -5,6 +5,9 @@
#include "encoding.h"
#include "softrvv_vadd.h"
+#include "softrvv_vsub.h"
+
+
namespace softrvv {
diff --git a/softrvv/include/softrvv_vadd.h b/softrvv/include/softrvv_vadd.h
index ae712c6..8a0ff99 100644
--- a/softrvv/include/softrvv_vadd.h
+++ b/softrvv/include/softrvv_vadd.h
@@ -1,28 +1,27 @@
#ifndef SOFTRVV_VADD_H
#define SOFTRVV_VADD_H
-#include <softrvv_vadd.h>
#include <stddef.h>
namespace softrvv {
template <typename T>
-void vadd_vi(T *dest, T *src1, T src2, size_t avl) {
- for (size_t idx = 0; idx < avl; idx++) {
+void vadd_vi(T *dest, T *src1, T src2, int32_t avl) {
+ for (int32_t idx = 0; idx < avl; idx++) {
dest[idx] = src1[idx] + src2;
}
}
template <typename T>
-void vadd_vx(T *dest, T *src1, const T *src2, size_t avl) {
- for (size_t idx = 0; idx < avl; idx++) {
+void vadd_vx(T *dest, T *src1, const T *src2, int32_t avl) {
+ for (int32_t idx = 0; idx < avl; idx++) {
dest[idx] = src1[idx] + *src2;
}
}
template <typename T>
-void vadd_vv(T *dest, T *src1, T *src2, size_t avl) {
- for (size_t idx = 0; idx < avl; idx++) {
+void vadd_vv(T *dest, T *src1, T *src2, int32_t avl) {
+ for (int32_t idx = 0; idx < avl; idx++) {
dest[idx] = src1[idx] + src2[idx];
}
}
diff --git a/softrvv/include/softrvv_vsub.h b/softrvv/include/softrvv_vsub.h
new file mode 100644
index 0000000..144141e
--- /dev/null
+++ b/softrvv/include/softrvv_vsub.h
@@ -0,0 +1,31 @@
+#ifndef SOFTRVV_VSUB_H
+#define SOFTRVV_VSUB_H
+
+#include <stddef.h>
+
+namespace softrvv {
+
+template <typename T>
+void vsub_vx(T *dest, T *src1, const T *src2, int32_t avl) {
+ for (int idx = 0; idx < avl; idx++) {
+ dest[idx] = src1[idx] - *src2;
+ }
+}
+
+template <typename T>
+void vsub_vv(T *dest, T *src1, T *src2, int32_t avl) {
+ for (int32_t idx = 0; idx < avl; idx++) {
+ dest[idx] = src1[idx] - src2[idx];
+ }
+}
+
+template <typename T>
+void vrsub_vx(T *dest, T *src1, const T *src2, int32_t avl) {
+ for (int32_t idx = 0; idx < avl; idx++) {
+ dest[idx] = *src2 - src1[idx];
+ }
+}
+
+} // namespace softrvv
+
+#endif // SOFTRVV_VSUB_H
\ No newline at end of file
diff --git a/softrvv/tests/softrvv_vsub_test.cpp b/softrvv/tests/softrvv_vsub_test.cpp
new file mode 100644
index 0000000..1b7a4b5
--- /dev/null
+++ b/softrvv/tests/softrvv_vsub_test.cpp
@@ -0,0 +1,45 @@
+#include <riscv_vector.h>
+#include <springbok.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "pw_unit_test/framework.h"
+#include "softrvv.h"
+
+namespace softrvv_vadd_test {
+namespace {
+
+int32_t src1[] = {2, 4, 6, 8, 10};
+int32_t src2[] = {1, 2, 3, 4, 5};
+int32_t rs1 = 2;
+const uint32_t AVL_CONST = sizeof(src1)/sizeof(src1[0]);
+int32_t dest[AVL_CONST];
+
+
+int32_t ref_vv[] = {1, 2, 3, 4, 5};
+int32_t ref_vx[] = {0, 2, 4, 6, 8};
+
+int32_t ref_r_vx[] = {0, -2, -4, -6, -8};
+
+class SoftRvvVsubTest : public ::testing::Test {
+ protected:
+ void SetUp() override { memset(dest, 0, sizeof(dest)); }
+};
+
+TEST_F(SoftRvvVsubTest, VV) {
+ softrvv::vsub_vv<int32_t>(dest, src1, src2, AVL_CONST);
+ ASSERT_EQ(memcmp(dest, ref_vv, sizeof(dest)), 0);
+}
+
+TEST_F(SoftRvvVsubTest, VX) {
+ softrvv::vsub_vx<int32_t>(dest, src1, &rs1, AVL_CONST);
+ ASSERT_EQ(memcmp(dest, ref_vx, sizeof(dest)), 0);
+}
+
+TEST_F(SoftRvvVsubTest, RVX) {
+ softrvv::vrsub_vx<int32_t>(dest, src1, &rs1, AVL_CONST);
+ ASSERT_EQ(memcmp(dest, ref_r_vx, sizeof(dest)), 0);
+}
+
+} // namespace
+} // namespace softrvv_vsub_test
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 8aa2b11..73fbeef 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.10)
-
+include(vec_cc_generated_test.cmake)
enable_language(ASM)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test_runner.py
@@ -15,6 +15,27 @@
${VEC_DEFAULT_COPTS}
)
+vec_cc_generated_test(
+ NAME
+ vsub
+ OPFMT
+ OPIVV
+ OPIVX
+ LINKOPTS
+ -Xlinker --defsym=__itcm_length__=128K
+)
+
+vec_cc_generated_test(
+ NAME
+ vadd
+ OPFMT
+ OPIVV
+ OPIVX
+ OPIVI
+ LINKOPTS
+ -Xlinker --defsym=__itcm_length__=256K
+)
+
vec_cc_test(
NAME
vsetvl_test
@@ -48,19 +69,6 @@
vec_cc_test(
NAME
- vadd_test
- SRCS
- vadd_vi_test.cpp
- vadd_vx_test.cpp
- vadd_vv_test.cpp
- LINKOPTS
- -Xlinker --defsym=__itcm_length__=256K
- TIMEOUT
- 40
-)
-
-vec_cc_test(
- NAME
vmax_test
SRCS
vmax_vx_test.cpp
@@ -70,3 +78,4 @@
TIMEOUT
40
)
+
diff --git a/tests/include/test_v_helpers.h b/tests/include/test_v_helpers.h
index 7b02208..2a56f84 100644
--- a/tests/include/test_v_helpers.h
+++ b/tests/include/test_v_helpers.h
@@ -74,9 +74,8 @@
}
template <typename T>
-static std::tuple<int, int> vector_test_setup(VLMUL lmul, int32_t avl,
- uint8_t *test_vector_1,
- uint8_t *test_vector_2) {
+static std::tuple<int, int> vector_test_setup(
+ VLMUL lmul, int32_t avl, const std::initializer_list<void *> &vec_list) {
// Clear all vector registers
zero_vector_registers();
// Initialize test_vector_1 and determine vl, vlmax
@@ -86,8 +85,9 @@
if (avl > vlmax) {
avl = vlmax;
}
- memset(test_vector_1, 0, MAXVL_BYTES);
- memset(test_vector_2, 0, MAXVL_BYTES);
+ for (auto vec : vec_list) {
+ memset(vec, 0, MAXVL_BYTES);
+ }
int vl = set_vsetvl_intrinsic(sew, lmul, avl);
EXPECT_EQ(avl, vl);
@@ -95,6 +95,20 @@
return std::make_tuple(vlmax, vl);
}
+template <typename T>
+void fill_random_vector(T *vec, int32_t avl) {
+ for (int32_t i = 0; i < avl; i++) {
+ vec[i] = static_cast<T>(rand());
+ }
+}
+
+template <typename T>
+void fill_vector_with_index(T *vec, int32_t avl) {
+ for (int32_t i = 0; i < avl; i++) {
+ vec[i] = static_cast<T>(i);
+ }
+}
+
} // namespace test_v_helpers
#endif
diff --git a/tests/scripts/generate_vector_tests.py b/tests/scripts/generate_vector_tests.py
new file mode 100644
index 0000000..b3e002d
--- /dev/null
+++ b/tests/scripts/generate_vector_tests.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python3
+"""
+Generate tests for Vector Instructions
+"""
+import os
+import logging
+import argparse
+from collections import namedtuple
+from pathlib import Path
+
+from mako.lookup import TemplateLookup
+import mako.exceptions
+
+parser = argparse.ArgumentParser(
+ description='Generate tests for vector instructions.')
+
+parser.add_argument('--template-path', dest='template_path',
+ help='path to templates', required=True)
+parser.add_argument('-v', '--verbose', help='increase output verbosity',
+ action='store_true')
+parser.add_argument('--op-code', dest='op_code',
+ help='Op-code', required=True)
+parser.add_argument('--out-path', dest='out_path',
+ help='Path to output files', default='.')
+
+template_name_lookup = {
+ 'OPIVV':'opivv_test.tpl.cpp',
+ 'OPIVI':'opivi_test.tpl.cpp',
+ 'OPIVX':'opivx_test.tpl.cpp',
+}
+
+parser.add_argument('--instruction-format',
+ action='append', choices=template_name_lookup.keys(), required=True)
+args = parser.parse_args()
+
+if args.verbose:
+ logging.basicConfig(level=logging.DEBUG)
+
+def main():
+ """ Main routine for generating tests from templates."""
+ mylookup = TemplateLookup(directories=[args.template_path, "."])
+ template_names = [template_name_lookup.get(fmt, None) for fmt in args.instruction_format]
+ template_names = [template for template in template_names if template is not None]
+ template_jobs = []
+ TemplateJob = namedtuple("TemplateJob", "template outfile")
+ Path(args.out_path).mkdir(parents=True, exist_ok=True)
+ for opfmt, template_name in template_name_lookup.items():
+ if not opfmt in args.instruction_format:
+ continue
+ try:
+ template = mylookup.get_template(template_name)
+ except mako.exceptions.TopLevelLookupException:
+ parser.error("Template does not exist %s" % template_name)
+ outfile_name = "%s_%s" % (args.op_code, template_name.replace(".tpl", ""))
+ template_jobs.append(TemplateJob(template, outfile_name))
+
+ for template_job in template_jobs:
+ full_outfile_path = os.path.join(args.out_path, template_job.outfile)
+ with open(full_outfile_path, "w+") as outfile:
+ outfile.write(template_job.template.render(op_code=args.op_code))
+
+if __name__ == "__main__":
+ main()
diff --git a/tests/templates/opivi_test.tpl.cpp b/tests/templates/opivi_test.tpl.cpp
new file mode 100644
index 0000000..40a5d26
--- /dev/null
+++ b/tests/templates/opivi_test.tpl.cpp
@@ -0,0 +1,78 @@
+/* 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}_vi_test {
+namespace {
+
+using namespace test_v_helpers;
+
+uint8_t src_vector_1[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 test_val in [-16, -15, -4, 1, 5, 12, 15]:
+% 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()}_vi${sew}m${lmul}simm5_${("%s" % test_val).replace('-','n')}) {
+ for (int i = 0; i < AVL_COUNT; i++) {
+ int32_t avl = AVLS[i];
+ int vlmax;
+ int vl;
+ const ${var_type} test_val = ${test_val};
+
+ std::tie(vlmax, vl) = vector_test_setup<${var_type}>(
+ VLMUL::LMUL_M${lmul}, avl,
+ {src_vector_1, dest_vector, ref_dest_vector});
+ if (avl > vlmax) {
+ continue;
+ }
+ ${var_type} *ptr_vec_1 = reinterpret_cast<${var_type} *>(src_vector_1);
+ ${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);
+ memset(dest_vector, 0, MAXVL_BYTES);
+ memset(ref_dest_vector, 0, MAXVL_BYTES);
+
+ // Generate reference vector
+ softrvv::${op_code}_vx<${var_type}>(ptr_ref_dest_vec, ptr_vec_1, &test_val, avl);
+
+ // Load vector registers
+ __asm__ volatile("vle${sew}.v v8, (%0)" : : "r"(ptr_vec_1));
+
+ // Run target instruction
+ __asm__ volatile("${op_code}.vi v24, v8, %[SIMM5]" ::[SIMM5] "n"(test_val));
+
+ // 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
+%endfor
+
+} // namespace
+} // namespace ${op_code}_vi_test
diff --git a/tests/templates/opivv_test.tpl.cpp b/tests/templates/opivv_test.tpl.cpp
new file mode 100644
index 0000000..1df0448
--- /dev/null
+++ b/tests/templates/opivv_test.tpl.cpp
@@ -0,0 +1,79 @@
+/* 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
diff --git a/tests/templates/opivx_test.tpl.cpp b/tests/templates/opivx_test.tpl.cpp
new file mode 100644
index 0000000..2476708
--- /dev/null
+++ b/tests/templates/opivx_test.tpl.cpp
@@ -0,0 +1,75 @@
+/* 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}_vx_test {
+namespace {
+
+using namespace test_v_helpers;
+
+uint8_t src_vector_1[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()}_vx${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, dest_vector, ref_dest_vector});
+ if (avl > vlmax) {
+ continue;
+ }
+ ${var_type} *ptr_vec_1 = reinterpret_cast<${var_type} *>(src_vector_1);
+ ${var_type} *ptr_dest_vec = reinterpret_cast<${var_type} *>(dest_vector);
+ ${var_type} *ptr_ref_dest_vec = reinterpret_cast<${var_type} *>(ref_dest_vector);
+ ${var_type} test_val = static_cast<${var_type}>(rand());
+ // set up values to test up to index of the AVL
+ fill_random_vector<${var_type}>(ptr_vec_1, avl);
+ memset(dest_vector, 0, MAXVL_BYTES);
+ memset(ref_dest_vector, 0, MAXVL_BYTES);
+
+ // Generate reference vector
+ softrvv::${op_code}_vx<${var_type}>(ptr_ref_dest_vec, ptr_vec_1, &test_val, avl);
+
+ // Load vector registers
+ __asm__ volatile("vle${sew}.v v8, (%0)" : : "r"(ptr_vec_1));
+
+ // Run target instruction
+ __asm__ volatile("${op_code}.vx v24, v8, %[RS1]" ::[RS1] "r"(test_val));
+
+ // 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}_vx_test
diff --git a/tests/test_v_helpers.cpp b/tests/test_v_helpers.cpp
index 013184e..32886eb 100644
--- a/tests/test_v_helpers.cpp
+++ b/tests/test_v_helpers.cpp
@@ -15,8 +15,8 @@
uint32_t vtype = get_vtype(sew, lmul, tail_agnostic, mask_agnostic);
uint32_t vl;
__asm__ volatile("vsetvl %[VL], %[AVL], %[VTYPE]"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl), [ VTYPE ] "r"(vtype));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl), [VTYPE] "r"(vtype));
return vl;
}
@@ -169,18 +169,18 @@
switch (sew) {
case VSEW::SEW_E8:
__asm__ volatile("vsetvli %[VL], %[AVL], e8, m1, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
case VSEW::SEW_E16:
__asm__ volatile("vsetvli %[VL], %[AVL], e16, m1, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
case VSEW::SEW_E32:
__asm__ volatile("vsetvli %[VL], %[AVL], e32, m1, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
default:
return 0;
@@ -190,18 +190,18 @@
switch (sew) {
case VSEW::SEW_E8:
__asm__ volatile("vsetvli %[VL], %[AVL], e8, m2, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
case VSEW::SEW_E16:
__asm__ volatile("vsetvli %[VL], %[AVL], e16, m2, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
case VSEW::SEW_E32:
__asm__ volatile("vsetvli %[VL], %[AVL], e32, m2, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
default:
return 0;
@@ -211,18 +211,18 @@
switch (sew) {
case VSEW::SEW_E8:
__asm__ volatile("vsetvli %[VL], %[AVL], e8, m4, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
case VSEW::SEW_E16:
__asm__ volatile("vsetvli %[VL], %[AVL], e16, m4, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
case VSEW::SEW_E32:
__asm__ volatile("vsetvli %[VL], %[AVL], e32, m4, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
default:
return 0;
@@ -232,18 +232,18 @@
switch (sew) {
case VSEW::SEW_E8:
__asm__ volatile("vsetvli %[VL], %[AVL], e8, m8, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
case VSEW::SEW_E16:
__asm__ volatile("vsetvli %[VL], %[AVL], e16, m8, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
case VSEW::SEW_E32:
__asm__ volatile("vsetvli %[VL], %[AVL], e32, m8, tu, mu"
- : [ VL ] "=r"(vl)
- : [ AVL ] "r"(avl));
+ : [VL] "=r"(vl)
+ : [AVL] "r"(avl));
break;
default:
return 0;
diff --git a/tests/vadd_vi_test.cpp b/tests/vadd_vi_test.cpp
deleted file mode 100644
index de27c24..0000000
--- a/tests/vadd_vi_test.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#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 vadd_vi_test {
-namespace {
-
-using namespace test_v_helpers;
-
-uint8_t test_vector_1[MAXVL_BYTES];
-uint8_t reference_vector_1[MAXVL_BYTES];
-
-class VaddViTest : public ::testing::Test {
- protected:
- void SetUp() override { zero_vector_registers(); }
- void TearDown() override { zero_vector_registers(); }
-};
-
-// Below is a non-macro version of the test for more convenient debugging.
-// Remove the "DISABLED_" prefix to enable this test for debugging.
-TEST_F(VaddViTest, DISABLED_vadd_vi_demo) {
- for (int i = 0; i < AVL_COUNT; i++) {
- int32_t avl = AVLS[i];
- int vlmax;
- int vl;
- std::tie(vlmax, vl) = vector_test_setup<int8_t>(
- VLMUL::LMUL_M1, avl, test_vector_1, reference_vector_1);
- if (avl > vlmax) {
- continue;
- }
- int8_t *ptr_vec_1 = reinterpret_cast<int8_t *>(test_vector_1);
- int8_t *ptr_ref_vec_1 = reinterpret_cast<int8_t *>(reference_vector_1);
- const int8_t test_val_1 = 1;
- const int8_t test_val_2 = -3;
- __asm__ volatile("vadd.vi v8, v8, %[SIMM5]" ::[SIMM5] "n"(test_val_1));
- __asm__ volatile("vadd.vi v8, v8, %[SIMM5]" ::[SIMM5] "n"(test_val_2));
- softrvv::vadd_vi<int8_t>(ptr_ref_vec_1, ptr_ref_vec_1, test_val_1, avl);
- softrvv::vadd_vi<int8_t>(ptr_ref_vec_1, ptr_ref_vec_1, test_val_2, avl);
- __asm__ volatile("vse8.v v8, (%0)" : : "r"(ptr_vec_1));
- assert_vec_elem_eq<int8_t>(vlmax, test_vector_1, reference_vector_1);
- }
-}
-
-#define DEFINE_TEST_VADD_VI(_SEW_, _LMUL_, TEST_VAL_1, TEST_VAL_2) \
- TEST_F(VaddViTest, vadd_vi##_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<int##_SEW_##_t>( \
- VLMUL::LMUL_M##_LMUL_, avl, test_vector_1, reference_vector_1); \
- if (avl > vlmax) { \
- continue; \
- } \
- int##_SEW_##_t *ptr_vec_1 = \
- reinterpret_cast<int##_SEW_##_t *>(test_vector_1); \
- int##_SEW_##_t *ptr_ref_vec_1 = \
- reinterpret_cast<int##_SEW_##_t *>(reference_vector_1); \
- const int##_SEW_##_t test_val_1 = TEST_VAL_1; \
- const int##_SEW_##_t test_val_2 = TEST_VAL_2; \
- __asm__ volatile("vadd.vi v8, v8, %[SIMM5]" ::[SIMM5] "n"(test_val_1)); \
- __asm__ volatile("vadd.vi v8, v8, %[SIMM5]" ::[SIMM5] "n"(test_val_2)); \
- softrvv::vadd_vi<int##_SEW_##_t>(ptr_ref_vec_1, ptr_ref_vec_1, \
- test_val_1, avl); \
- softrvv::vadd_vi<int##_SEW_##_t>(ptr_ref_vec_1, ptr_ref_vec_1, \
- test_val_2, avl); \
- __asm__ volatile("vse" #_SEW_ ".v v8, (%0)" : : "r"(ptr_vec_1)); \
- assert_vec_elem_eq<int##_SEW_##_t>(vlmax, test_vector_1, \
- reference_vector_1); \
- } \
- }
-
-// TODO(gkielian): modify macro to permit more than one test per sew/lmul pair
-DEFINE_TEST_VADD_VI(8, 1, -16, 15)
-DEFINE_TEST_VADD_VI(8, 2, -2, 3)
-DEFINE_TEST_VADD_VI(8, 4, 15, 15)
-DEFINE_TEST_VADD_VI(8, 8, -15, -15)
-
-DEFINE_TEST_VADD_VI(16, 1, -16, 15)
-DEFINE_TEST_VADD_VI(16, 2, -2, 3)
-DEFINE_TEST_VADD_VI(16, 4, 15, 15)
-DEFINE_TEST_VADD_VI(16, 8, -15, -15)
-
-DEFINE_TEST_VADD_VI(32, 1, -16, 15)
-DEFINE_TEST_VADD_VI(32, 2, -2, 3)
-DEFINE_TEST_VADD_VI(32, 4, 15, 15)
-DEFINE_TEST_VADD_VI(32, 8, -15, -15)
-
-} // namespace
-} // namespace vadd_vi_test
diff --git a/tests/vadd_vv_test.cpp b/tests/vadd_vv_test.cpp
deleted file mode 100644
index cd9be4d..0000000
--- a/tests/vadd_vv_test.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-#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 vadd_vv_test {
-namespace {
-
-using namespace test_v_helpers;
-
-uint8_t test_vector_1[MAXVL_BYTES];
-uint8_t reference_vector_1[MAXVL_BYTES];
-
-class VaddVxTest : public ::testing::Test {
- protected:
- void SetUp() override { zero_vector_registers(); }
- void TearDown() override { zero_vector_registers(); }
-};
-
-// Below is a demo Test for convenient debugging
-// Currently disabled, so remove "DISABLED_" prefix to enable this test
-TEST_F(VaddVxTest, DISABLED_vadd_vv_demo) {
- for (int i = 0; i < AVL_COUNT; i++) {
- int32_t avl = AVLS[i];
- int vlmax;
- int vl;
- std::tie(vlmax, vl) = vector_test_setup<int8_t>(
- VLMUL::LMUL_M1, avl, test_vector_1, reference_vector_1);
- if (avl > vlmax) {
- continue;
- }
- int8_t *ptr_vec_1 = reinterpret_cast<int8_t *>(test_vector_1);
- int8_t *ptr_ref_vec_1 = reinterpret_cast<int8_t *>(reference_vector_1);
-
- // set up values to test up to index of the AVL
- for (int idx = 0; idx < vl; idx++) {
- // restrict values to valid int8_t range
- ptr_vec_1[idx] = idx % (INT8_MAX) + (INT8_MIN);
- reference_vector_1[idx] = ptr_vec_1[idx];
- }
- __asm__ volatile("vle8.v v8, (%0)" : : "r"(ptr_vec_1));
- __asm__ volatile("vadd.vv v8, v8, v8");
- softrvv::vadd_vv<int8_t>(ptr_ref_vec_1, ptr_ref_vec_1, ptr_ref_vec_1, avl);
- __asm__ volatile("vse8.v v8, (%0)" : : "r"(ptr_vec_1));
- assert_vec_elem_eq<int8_t>(vlmax, test_vector_1, reference_vector_1);
- }
-}
-
-#define DEFINE_TEST_VADD_VV(_SEW_, _LMUL_) \
- TEST_F(VaddVxTest, vadd_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<int##_SEW_##_t>( \
- VLMUL::LMUL_M##_LMUL_, avl, test_vector_1, reference_vector_1); \
- if (avl > vlmax) { \
- continue; \
- } \
- int##_SEW_##_t *ptr_vec_1 = \
- reinterpret_cast<int##_SEW_##_t *>(test_vector_1); \
- int##_SEW_##_t *ptr_ref_vec_1 = \
- reinterpret_cast<int##_SEW_##_t *>(reference_vector_1); \
- \
- for (long long idx = 0; idx < vl; idx++) { \
- ptr_vec_1[idx] = idx % INT##_SEW_##_MAX + INT##_SEW_##_MIN; \
- ptr_ref_vec_1[idx] = ptr_vec_1[idx]; \
- } \
- \
- __asm__ volatile("vle" #_SEW_ ".v v8, (%0)" : : "r"(ptr_vec_1)); \
- __asm__ volatile("vadd.vv v8, v8, v8"); \
- softrvv::vadd_vv<int##_SEW_##_t>(ptr_ref_vec_1, ptr_ref_vec_1, \
- ptr_ref_vec_1, avl); \
- __asm__ volatile("vse" #_SEW_ ".v v8, (%0)" : : "r"(ptr_vec_1)); \
- assert_vec_elem_eq<int##_SEW_##_t>(vlmax, test_vector_1, \
- reference_vector_1); \
- } \
- } // namespace
-
-// TODO(gkielian): modify macro to permit more than one test per sew/lmul pair
-DEFINE_TEST_VADD_VV(8, 1)
-DEFINE_TEST_VADD_VV(8, 2)
-DEFINE_TEST_VADD_VV(8, 4)
-DEFINE_TEST_VADD_VV(8, 8)
-
-DEFINE_TEST_VADD_VV(16, 1)
-DEFINE_TEST_VADD_VV(16, 2)
-DEFINE_TEST_VADD_VV(16, 4)
-DEFINE_TEST_VADD_VV(16, 8)
-
-DEFINE_TEST_VADD_VV(32, 1)
-DEFINE_TEST_VADD_VV(32, 2)
-DEFINE_TEST_VADD_VV(32, 4)
-DEFINE_TEST_VADD_VV(32, 8)
-
-} // namespace
-} // namespace vadd_vv_test
diff --git a/tests/vadd_vx_test.cpp b/tests/vadd_vx_test.cpp
deleted file mode 100644
index 8923a7c..0000000
--- a/tests/vadd_vx_test.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-#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 vadd_vx_test {
-namespace {
-
-using namespace test_v_helpers;
-
-uint8_t test_vector_1[MAXVL_BYTES];
-uint8_t reference_vector_1[MAXVL_BYTES];
-
-class VaddVxTest : public ::testing::Test {
- protected:
- void SetUp() override { zero_vector_registers(); }
- void TearDown() override { zero_vector_registers(); }
-};
-
-// Below is a non-macro version of the test for more convenient debugging.
-// Remove the "DISABLED_" prefix to enable this test for debugging.
-TEST_F(VaddVxTest, DISABLED_vadd_vx_demo) {
- for (int i = 0; i < AVL_COUNT; i++) {
- int32_t avl = AVLS[i];
- int vlmax;
- int vl;
- std::tie(vlmax, vl) = vector_test_setup<int8_t>(
- VLMUL::LMUL_M1, avl, test_vector_1, reference_vector_1);
- if (avl > vlmax) {
- continue;
- }
- int8_t *ptr_vec_1 = reinterpret_cast<int8_t *>(test_vector_1);
- int8_t *ptr_ref_vec_1 = reinterpret_cast<int8_t *>(reference_vector_1);
- int8_t test_val = 8;
- __asm__ volatile("vadd.vx v8, v8, %[RS1]" ::[RS1] "r"(test_val));
- softrvv::vadd_vx<int8_t>(ptr_ref_vec_1, ptr_ref_vec_1, &test_val, avl);
- __asm__ volatile("vse8.v v8, (%0)" : : "r"(ptr_vec_1));
- assert_vec_elem_eq<int8_t>(vlmax, test_vector_1, reference_vector_1);
- }
-}
-
-#define DEFINE_TEST_VADD_VX(_SEW_, _LMUL_, TEST_VAL) \
- TEST_F(VaddVxTest, vadd_vx##_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<int##_SEW_##_t>( \
- VLMUL::LMUL_M##_LMUL_, avl, test_vector_1, reference_vector_1); \
- if (avl > vlmax) { \
- continue; \
- } \
- int##_SEW_##_t *ptr_vec_1 = \
- reinterpret_cast<int##_SEW_##_t *>(test_vector_1); \
- int##_SEW_##_t *ptr_ref_vec_1 = \
- reinterpret_cast<int##_SEW_##_t *>(reference_vector_1); \
- const int##_SEW_##_t test_val = TEST_VAL; \
- __asm__ volatile("vadd.vx v8, v8, %[RS1]" ::[RS1] "r"(test_val)); \
- softrvv::vadd_vx<int##_SEW_##_t>(ptr_ref_vec_1, ptr_ref_vec_1, \
- &test_val, avl); \
- __asm__ volatile("vse" #_SEW_ ".v v8, (%0)" : : "r"(ptr_vec_1)); \
- assert_vec_elem_eq<int##_SEW_##_t>(vlmax, test_vector_1, \
- reference_vector_1); \
- } \
- }
-
-// TODO(gkielian): modify macro to permit more than one test per sew/lmul pair
-DEFINE_TEST_VADD_VX(8, 1, INT8_MIN)
-DEFINE_TEST_VADD_VX(8, 2, INT8_MAX)
-DEFINE_TEST_VADD_VX(8, 4, -1)
-DEFINE_TEST_VADD_VX(8, 8, 2)
-
-DEFINE_TEST_VADD_VX(16, 1, INT16_MIN)
-DEFINE_TEST_VADD_VX(16, 2, INT16_MAX)
-DEFINE_TEST_VADD_VX(16, 4, -1)
-DEFINE_TEST_VADD_VX(16, 8, 2)
-
-DEFINE_TEST_VADD_VX(32, 1, INT32_MIN)
-DEFINE_TEST_VADD_VX(32, 2, INT32_MAX)
-DEFINE_TEST_VADD_VX(32, 4, -1)
-DEFINE_TEST_VADD_VX(32, 8, 2)
-
-} // namespace
-} // namespace vadd_vx_test
diff --git a/tests/vec_cc_generated_test.cmake b/tests/vec_cc_generated_test.cmake
new file mode 100644
index 0000000..43a10ff
--- /dev/null
+++ b/tests/vec_cc_generated_test.cmake
@@ -0,0 +1,39 @@
+function(vec_cc_generated_test)
+ cmake_parse_arguments(
+ _RULE
+ ""
+ "NAME"
+ "OPFMT;LINKOPTS;TIMEOUT"
+ ${ARGN}
+ )
+
+set(_OPCODE "${_RULE_NAME}")
+
+foreach(_OPFMT ${_RULE_OPFMT})
+string(TOLOWER ${_OPFMT} _LOWER_OPFMT)
+set(_TEST_SRC ${CMAKE_CURRENT_BINARY_DIR}/generated/${_OPCODE}/${_OPCODE}_${_LOWER_OPFMT}_test.cpp)
+add_custom_command(
+ OUTPUT
+ ${_TEST_SRC}
+ DEPENDS
+ ${CMAKE_CURRENT_SOURCE_DIR}/templates/${_LOWER_OPFMT}_test.tpl.cpp
+ COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_vector_tests.py
+ --template-path=${CMAKE_CURRENT_SOURCE_DIR}/templates/
+ --instruction-format ${_OPFMT}
+ --op-code ${_OPCODE}
+ --out-path=${CMAKE_CURRENT_BINARY_DIR}/generated/${_OPCODE}
+)
+list (APPEND _TEST_SRCS "${_TEST_SRC}")
+endforeach()
+
+vec_cc_test(
+ NAME
+ ${_OPCODE}_test
+ SRCS
+ ${_TEST_SRCS}
+ LINKOPTS
+ ${_RULE_LINKOPTS}
+ TIMEOUT
+ ${_RULE_TIMEOUT}
+)
+endfunction()
diff --git a/tests/vmax_vx_test.cpp b/tests/vmax_vx_test.cpp
index a20c2e8..3dfed33 100644
--- a/tests/vmax_vx_test.cpp
+++ b/tests/vmax_vx_test.cpp
@@ -32,7 +32,7 @@
int vlmax;
int vl;
std::tie(vlmax, vl) = vector_test_setup<uint8_t>(
- VLMUL::LMUL_M1, avl, test_vector_1, test_vector_2);
+ VLMUL::LMUL_M1, avl, {test_vector_1, test_vector_2});
if (avl > vlmax) {
continue;
}
@@ -62,7 +62,7 @@
int vlmax; \
int vl; \
std::tie(vlmax, vl) = vector_test_setup<int##_SEW_##_t>( \
- VLMUL::LMUL_M##_LMUL_, avl, test_vector_1, test_vector_2); \
+ VLMUL::LMUL_M##_LMUL_, avl, {test_vector_1, test_vector_2}); \
if (avl > vlmax) { \
continue; \
} \
diff --git a/tests/vmv_test.cpp b/tests/vmv_test.cpp
index 3048b82..674d1bd 100644
--- a/tests/vmv_test.cpp
+++ b/tests/vmv_test.cpp
@@ -29,7 +29,7 @@
int vlmax;
int vl;
std::tie(vlmax, vl) = vector_test_setup<int8_t>(
- VLMUL::LMUL_M1, avl, test_vector_1, reference_vector_1);
+ VLMUL::LMUL_M1, avl, {test_vector_1, reference_vector_1});
if (avl > vlmax) {
continue;
}
@@ -48,7 +48,7 @@
int vlmax;
int vl;
std::tie(vlmax, vl) = vector_test_setup<int8_t>(
- VLMUL::LMUL_M1, avl, test_vector_1, reference_vector_1);
+ VLMUL::LMUL_M1, avl, {test_vector_1, reference_vector_1});
if (avl > vlmax) {
continue;
}
@@ -67,7 +67,7 @@
int vlmax; \
int vl; \
std::tie(vlmax, vl) = vector_test_setup<int##_SEW_##_t>( \
- VLMUL::LMUL_M##_LMUL_, avl, test_vector_1, reference_vector_1); \
+ VLMUL::LMUL_M##_LMUL_, avl, {test_vector_1, reference_vector_1}); \
if (avl > vlmax) { \
continue; \
} \
@@ -97,27 +97,27 @@
DEFINE_TEST_VMV_V_V_I_INTRINSIC(32, 4)
DEFINE_TEST_VMV_V_V_I_INTRINSIC(32, 8)
-#define DEFINE_TEST_VMV_V_V_I(_SEW_, _LMUL_) \
- TEST_F(VmvTest, vmv_v_v_i##_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<int##_SEW_##_t>( \
- VLMUL::LMUL_M##_LMUL_, avl, test_vector_1, reference_vector_1); \
- if (avl > vlmax) { \
- continue; \
- } \
- int##_SEW_##_t *ptr_vec_1 = \
- reinterpret_cast<int##_SEW_##_t *>(test_vector_1); \
- int##_SEW_##_t *ptr_vec_2 = \
- reinterpret_cast<int##_SEW_##_t *>(reference_vector_1); \
- __asm__ volatile("vle" #_SEW_ ".v v0, (%0)" : : "r"(ptr_vec_1)); \
- __asm__ volatile("vmv.v.v v8, v0"); \
- __asm__ volatile("vse" #_SEW_ ".v v8, (%0)" : : "r"(ptr_vec_2)); \
- assert_vec_elem_eq<int##_SEW_##_t>(vlmax, test_vector_1, \
- reference_vector_1); \
- } \
+#define DEFINE_TEST_VMV_V_V_I(_SEW_, _LMUL_) \
+ TEST_F(VmvTest, vmv_v_v_i##_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<int##_SEW_##_t>( \
+ VLMUL::LMUL_M##_LMUL_, avl, {test_vector_1, reference_vector_1}); \
+ if (avl > vlmax) { \
+ continue; \
+ } \
+ int##_SEW_##_t *ptr_vec_1 = \
+ reinterpret_cast<int##_SEW_##_t *>(test_vector_1); \
+ int##_SEW_##_t *ptr_vec_2 = \
+ reinterpret_cast<int##_SEW_##_t *>(reference_vector_1); \
+ __asm__ volatile("vle" #_SEW_ ".v v0, (%0)" : : "r"(ptr_vec_1)); \
+ __asm__ volatile("vmv.v.v v8, v0"); \
+ __asm__ volatile("vse" #_SEW_ ".v v8, (%0)" : : "r"(ptr_vec_2)); \
+ assert_vec_elem_eq<int##_SEW_##_t>(vlmax, test_vector_1, \
+ reference_vector_1); \
+ } \
}
DEFINE_TEST_VMV_V_V_I(8, 1)
@@ -141,7 +141,7 @@
int vlmax;
int vl;
std::tie(vlmax, vl) = vector_test_setup<int8_t>(
- VLMUL::LMUL_M1, avl, test_vector_1, reference_vector_1);
+ VLMUL::LMUL_M1, avl, {test_vector_1, reference_vector_1});
if (avl > vlmax) {
continue;
}
@@ -157,30 +157,30 @@
}
}
-#define DEFINE_TEST_VMV_V_X_I(_SEW_, _LMUL_, TEST_VAL) \
- TEST_F(VmvTest, vmv_v_x_e##_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<int##_SEW_##_t>( \
- VLMUL::LMUL_M##_LMUL_, avl, test_vector_1, reference_vector_1); \
- if (avl > vlmax) { \
- continue; \
- } \
- int##_SEW_##_t *ptr_vec_1 = \
- reinterpret_cast<int##_SEW_##_t *>(test_vector_1); \
- int##_SEW_##_t *ptr_vec_2 = \
- reinterpret_cast<int##_SEW_##_t *>(reference_vector_1); \
- const int##_SEW_##_t test_val = TEST_VAL; \
- __asm__ volatile("vmv.v.x v8, %[RS1]" ::[RS1] "r"(test_val)); \
- for (int i = 0; i < vl; i++) { \
- ptr_vec_1[i] = test_val; \
- } \
- __asm__ volatile("vse" #_SEW_ ".v v8, (%0)" : : "r"(ptr_vec_2)); \
- assert_vec_elem_eq<int##_SEW_##_t>(vlmax, test_vector_1, \
- reference_vector_1); \
- } \
+#define DEFINE_TEST_VMV_V_X_I(_SEW_, _LMUL_, TEST_VAL) \
+ TEST_F(VmvTest, vmv_v_x_e##_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<int##_SEW_##_t>( \
+ VLMUL::LMUL_M##_LMUL_, avl, {test_vector_1, reference_vector_1}); \
+ if (avl > vlmax) { \
+ continue; \
+ } \
+ int##_SEW_##_t *ptr_vec_1 = \
+ reinterpret_cast<int##_SEW_##_t *>(test_vector_1); \
+ int##_SEW_##_t *ptr_vec_2 = \
+ reinterpret_cast<int##_SEW_##_t *>(reference_vector_1); \
+ const int##_SEW_##_t test_val = TEST_VAL; \
+ __asm__ volatile("vmv.v.x v8, %[RS1]" ::[RS1] "r"(test_val)); \
+ for (int i = 0; i < vl; i++) { \
+ ptr_vec_1[i] = test_val; \
+ } \
+ __asm__ volatile("vse" #_SEW_ ".v v8, (%0)" : : "r"(ptr_vec_2)); \
+ assert_vec_elem_eq<int##_SEW_##_t>(vlmax, test_vector_1, \
+ reference_vector_1); \
+ } \
}
DEFINE_TEST_VMV_V_X_I(8, 1, 0xab)
@@ -204,7 +204,7 @@
int vlmax;
int vl;
std::tie(vlmax, vl) = vector_test_setup<int8_t>(
- VLMUL::LMUL_M1, avl, test_vector_1, reference_vector_1);
+ VLMUL::LMUL_M1, avl, {test_vector_1, reference_vector_1});
if (avl > vlmax) {
continue;
}
@@ -221,30 +221,30 @@
}
// TODO(gkielian): Allow mechanism for multiple tests for same sew,lmul pair
-#define DEFINE_TEST_VMV_V_I_I(_SEW_, _LMUL_, TEST_VAL) \
- TEST_F(VmvTest, vmv_v_i_e##_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<int##_SEW_##_t>( \
- VLMUL::LMUL_M##_LMUL_, avl, test_vector_1, reference_vector_1); \
- if (avl > vlmax) { \
- continue; \
- } \
- int##_SEW_##_t *ptr_vec_1 = \
- reinterpret_cast<int##_SEW_##_t *>(test_vector_1); \
- int##_SEW_##_t *ptr_vec_2 = \
- reinterpret_cast<int##_SEW_##_t *>(reference_vector_1); \
- int##_SEW_##_t test_val = TEST_VAL; \
- __asm__ volatile("vmv.v.i v8, " #TEST_VAL); \
- for (int i = 0; i < vl; i++) { \
- ptr_vec_1[i] = test_val; \
- } \
- __asm__ volatile("vse" #_SEW_ ".v v8, (%0)" : : "r"(ptr_vec_2)); \
- assert_vec_elem_eq<int##_SEW_##_t>(vlmax, test_vector_1, \
- reference_vector_1); \
- } \
+#define DEFINE_TEST_VMV_V_I_I(_SEW_, _LMUL_, TEST_VAL) \
+ TEST_F(VmvTest, vmv_v_i_e##_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<int##_SEW_##_t>( \
+ VLMUL::LMUL_M##_LMUL_, avl, {test_vector_1, reference_vector_1}); \
+ if (avl > vlmax) { \
+ continue; \
+ } \
+ int##_SEW_##_t *ptr_vec_1 = \
+ reinterpret_cast<int##_SEW_##_t *>(test_vector_1); \
+ int##_SEW_##_t *ptr_vec_2 = \
+ reinterpret_cast<int##_SEW_##_t *>(reference_vector_1); \
+ int##_SEW_##_t test_val = TEST_VAL; \
+ __asm__ volatile("vmv.v.i v8, " #TEST_VAL); \
+ for (int i = 0; i < vl; i++) { \
+ ptr_vec_1[i] = test_val; \
+ } \
+ __asm__ volatile("vse" #_SEW_ ".v v8, (%0)" : : "r"(ptr_vec_2)); \
+ assert_vec_elem_eq<int##_SEW_##_t>(vlmax, test_vector_1, \
+ reference_vector_1); \
+ } \
}
DEFINE_TEST_VMV_V_I_I(8, 1, -11)
diff --git a/vector_vset_tests/vector_vset_tests.c b/vector_vset_tests/vector_vset_tests.c
index a1c84d5..8ca47c7 100644
--- a/vector_vset_tests/vector_vset_tests.c
+++ b/vector_vset_tests/vector_vset_tests.c
@@ -90,7 +90,6 @@
};
struct subtest_s subtests[] = {
- /*
{.vtypei = "e8",
.lmul = "1/8",
.avl = 0,
@@ -106,11 +105,11 @@
.avl = 0,
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/8",
- .avl = 0,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/8",
+ // .avl = 0,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/8",
.avl = 1,
@@ -126,11 +125,11 @@
.avl = 1,
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/8",
- .avl = 1,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/8",
+ // .avl = 1,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/8",
.avl = (_TEST_VLENB >> 3) - 1,
@@ -146,11 +145,11 @@
.avl = (_TEST_VLENB >> 5) - 1,
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/8",
- .avl = (_TEST_VLENB >> 6) - 1,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/8",
+ // .avl = (_TEST_VLENB >> 6) - 1,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/8",
.avl = (_TEST_VLENB >> 3),
@@ -166,11 +165,11 @@
.avl = (_TEST_VLENB >> 5),
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/8",
- .avl = (_TEST_VLENB >> 6),
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/8",
+ // .avl = (_TEST_VLENB >> 6),
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/8",
.avl = (_TEST_VLENB >> 3) + 1,
@@ -186,11 +185,11 @@
.avl = (_TEST_VLENB >> 5) + 1,
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/8",
- .avl = (_TEST_VLENB >> 6) + 1,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/8",
+ // .avl = (_TEST_VLENB >> 6) + 1,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/4",
@@ -207,11 +206,11 @@
.avl = 0,
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/4",
- .avl = 0,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/4",
+ // .avl = 0,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/4",
.avl = 1,
@@ -227,11 +226,11 @@
.avl = 1,
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/4",
- .avl = 1,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/4",
+ // .avl = 1,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/4",
.avl = (_TEST_VLENB >> 2) - 1,
@@ -247,11 +246,11 @@
.avl = (_TEST_VLENB >> 4) - 1,
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/4",
- .avl = (_TEST_VLENB >> 5) - 1,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/4",
+ // .avl = (_TEST_VLENB >> 5) - 1,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/4",
.avl = (_TEST_VLENB >> 2),
@@ -267,11 +266,11 @@
.avl = (_TEST_VLENB >> 4),
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/4",
- .avl = (_TEST_VLENB >> 5),
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/4",
+ // .avl = (_TEST_VLENB >> 5),
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/4",
.avl = (_TEST_VLENB >> 2) + 1,
@@ -287,11 +286,11 @@
.avl = (_TEST_VLENB >> 4) + 1,
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/4",
- .avl = (_TEST_VLENB >> 5) + 1,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/4",
+ // .avl = (_TEST_VLENB >> 5) + 1,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/2",
@@ -308,11 +307,11 @@
.avl = 0,
.expected_vl = 0,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/2",
- .avl = 0,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/2",
+ // .avl = 0,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/2",
.avl = 1,
@@ -328,11 +327,11 @@
.avl = 1,
.expected_vl = 1,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/2",
- .avl = 1,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/2",
+ // .avl = 1,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/2",
.avl = (_TEST_VLENB >> 1) - 1,
@@ -348,11 +347,11 @@
.avl = (_TEST_VLENB >> 3) - 1,
.expected_vl = (_TEST_VLENB >> 3) - 1,
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/2",
- .avl = (_TEST_VLENB >> 4) - 1,
- .expected_vl = 0,
- .line = __LINE__},
+ // {.vtypei = "e64",
+ // .lmul = "1/2",
+ // .avl = (_TEST_VLENB >> 4) - 1,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1/2",
.avl = (_TEST_VLENB >> 1),
@@ -388,12 +387,11 @@
.avl = (_TEST_VLENB >> 3) + 1,
.expected_vl = (_TEST_VLENB >> 3),
.line = __LINE__},
- {.vtypei = "e64",
- .lmul = "1/2",
- .avl = (_TEST_VLENB >> 4) + 1,
- .expected_vl = 0,
- .line = __LINE__},
- */
+ // {.vtypei = "e64",
+ // .lmul = "1/2",
+ // .avl = (_TEST_VLENB >> 4) + 1,
+ // .expected_vl = 0,
+ // .line = __LINE__},
{.vtypei = "e8",
.lmul = "1",
@@ -804,10 +802,13 @@
for (uint32_t i = 0; i < len; i++) {
LOG_INFO("Subtest %u", i);
struct subtest_s subtest = subtests[i];
- subtest_vsetvl(subtest.vtypei, subtest.lmul, subtest.avl, false, false,
- subtest.expected_vl, subtest.line);
- subtest_vsetvl(subtest.vtypei, subtest.lmul, subtest.avl, false, true,
- subtest.expected_vl, subtest.line);
+ uint8_t lmul = lmul_string_to_vlmul(subtest.lmul);
+ if (lmul <= 4) { // non-fractional LMUL, vtu is supported.
+ subtest_vsetvl(subtest.vtypei, subtest.lmul, subtest.avl, false, false,
+ subtest.expected_vl, subtest.line);
+ subtest_vsetvl(subtest.vtypei, subtest.lmul, subtest.avl, false, true,
+ subtest.expected_vl, subtest.line);
+ }
subtest_vsetvl(subtest.vtypei, subtest.lmul, subtest.avl, true, false,
subtest.expected_vl, subtest.line);
subtest_vsetvl(subtest.vtypei, subtest.lmul, subtest.avl, true, true,
@@ -846,67 +847,43 @@
VSETVLI_TEST_HELPER(vtypei, "e64,m1,tu,ma", avl);
VSETVLI_TEST_HELPER(vtypei, "e64,m1,ta,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e64,m1,ta,ma", avl);
-
- VSETVLI_TEST_HELPER(vtypei, "e8,mf8,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e8,mf8,tu,ma", avl);
+ */
VSETVLI_TEST_HELPER(vtypei, "e8,mf8,ta,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e8,mf8,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e16,mf8,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e16,mf8,tu,ma", avl);
VSETVLI_TEST_HELPER(vtypei, "e16,mf8,ta,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e16,mf8,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e32,mf8,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e32,mf8,tu,ma", avl);
VSETVLI_TEST_HELPER(vtypei, "e32,mf8,ta,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e32,mf8,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf8,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf8,tu,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf8,ta,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf8,ta,ma", avl);
+ // VSETVLI_TEST_HELPER(vtypei, "e64,mf8,ta,mu", avl);
+ // VSETVLI_TEST_HELPER(vtypei, "e64,mf8,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e8,mf4,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e8,mf4,tu,ma", avl);
VSETVLI_TEST_HELPER(vtypei, "e8,mf4,ta,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e8,mf4,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e16,mf4,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e16,mf4,tu,ma", avl);
VSETVLI_TEST_HELPER(vtypei, "e16,mf4,ta,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e16,mf4,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e32,mf4,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e32,mf4,tu,ma", avl);
VSETVLI_TEST_HELPER(vtypei, "e32,mf4,ta,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e32,mf4,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf4,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf4,tu,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf4,ta,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf4,ta,ma", avl);
+ // VSETVLI_TEST_HELPER(vtypei, "e64,mf4,ta,mu", avl);
+ // VSETVLI_TEST_HELPER(vtypei, "e64,mf4,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e8,mf2,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e8,mf2,tu,ma", avl);
VSETVLI_TEST_HELPER(vtypei, "e8,mf2,ta,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e8,mf2,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e16,mf2,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e16,mf2,tu,ma", avl);
VSETVLI_TEST_HELPER(vtypei, "e16,mf2,ta,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e16,mf2,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e32,mf2,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e32,mf2,tu,ma", avl);
VSETVLI_TEST_HELPER(vtypei, "e32,mf2,ta,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e32,mf2,ta,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf2,tu,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf2,tu,ma", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf2,ta,mu", avl);
- VSETVLI_TEST_HELPER(vtypei, "e64,mf2,ta,ma", avl);
- */
+ // VSETVLI_TEST_HELPER(vtypei, "e64,mf2,ta,mu", avl);
+ // VSETVLI_TEST_HELPER(vtypei, "e64,mf2,ta,ma", avl);
+
VSETVLI_TEST_HELPER(vtypei, "e8,m1,tu,mu", avl);
VSETVLI_TEST_HELPER(vtypei, "e8,m1,tu,ma", avl);
@@ -1005,42 +982,42 @@
};
struct subtest_s subtests[] = {
- /*
+
{.vtypei = "e8,mf8", .avl = 0, .expected_vl = 0},
{.vtypei = "e16,mf8", .avl = 0, .expected_vl = 0},
{.vtypei = "e32,mf8", .avl = 0, .expected_vl = 0},
- {.vtypei = "e64,mf8", .avl = 0, .expected_vl = 0},
+ // {.vtypei = "e64,mf8", .avl = 0, .expected_vl = 0},
{.vtypei = "e8,mf8", .avl = 1, .expected_vl = 1},
{.vtypei = "e16,mf8", .avl = 1, .expected_vl = 0},
{.vtypei = "e32,mf8", .avl = 1, .expected_vl = 0},
- {.vtypei = "e64,mf8", .avl = 1, .expected_vl = 0},
+ // {.vtypei = "e64,mf8", .avl = 1, .expected_vl = 0},
{.vtypei = "e8,mf8",
.avl = (_TEST_VLENB >> 3) - 1,
.expected_vl = (_TEST_VLENB >> 3) - 1},
{.vtypei = "e16,mf8", .avl = (_TEST_VLENB >> 4) - 1, .expected_vl = 0},
{.vtypei = "e32,mf8", .avl = (_TEST_VLENB >> 5) - 1, .expected_vl = 0},
- {.vtypei = "e64,mf8", .avl = (_TEST_VLENB >> 6) - 1, .expected_vl = 0},
+ // {.vtypei = "e64,mf8", .avl = (_TEST_VLENB >> 6) - 1, .expected_vl = 0},
{.vtypei = "e8,mf8",
.avl = (_TEST_VLENB >> 3),
.expected_vl = (_TEST_VLENB >> 3)},
{.vtypei = "e16,mf8", .avl = (_TEST_VLENB >> 4), .expected_vl = 0},
{.vtypei = "e32,mf8", .avl = (_TEST_VLENB >> 5), .expected_vl = 0},
- {.vtypei = "e64,mf8", .avl = (_TEST_VLENB >> 6), .expected_vl = 0},
+ // {.vtypei = "e64,mf8", .avl = (_TEST_VLENB >> 6), .expected_vl = 0},
{.vtypei = "e8,mf8",
.avl = (_TEST_VLENB >> 3) + 1,
.expected_vl = (_TEST_VLENB >> 3)},
{.vtypei = "e16,mf8", .avl = (_TEST_VLENB >> 4) + 1, .expected_vl = 0},
{.vtypei = "e32,mf8", .avl = (_TEST_VLENB >> 5) + 1, .expected_vl = 0},
- {.vtypei = "e64,mf8", .avl = (_TEST_VLENB >> 6) + 1, .expected_vl = 0},
+ // {.vtypei = "e64,mf8", .avl = (_TEST_VLENB >> 6) + 1, .expected_vl = 0},
{.vtypei = "e8,mf4", .avl = 0, .expected_vl = 0},
{.vtypei = "e16,mf4", .avl = 0, .expected_vl = 0},
{.vtypei = "e32,mf4", .avl = 0, .expected_vl = 0},
- {.vtypei = "e64,mf4", .avl = 0, .expected_vl = 0},
+ // {.vtypei = "e64,mf4", .avl = 0, .expected_vl = 0},
{.vtypei = "e8,mf4", .avl = 1, .expected_vl = 1},
{.vtypei = "e16,mf4", .avl = 1, .expected_vl = 1},
{.vtypei = "e32,mf4", .avl = 1, .expected_vl = 0},
- {.vtypei = "e64,mf4", .avl = 1, .expected_vl = 0},
+ // {.vtypei = "e64,mf4", .avl = 1, .expected_vl = 0},
{.vtypei = "e8,mf4",
.avl = (_TEST_VLENB >> 2) - 1,
.expected_vl = (_TEST_VLENB >> 2) - 1},
@@ -1048,7 +1025,7 @@
.avl = (_TEST_VLENB >> 3) - 1,
.expected_vl = (_TEST_VLENB >> 3) - 1},
{.vtypei = "e32,mf4", .avl = (_TEST_VLENB >> 4) - 1, .expected_vl = 0},
- {.vtypei = "e64,mf4", .avl = (_TEST_VLENB >> 5) - 1, .expected_vl = 0},
+ // {.vtypei = "e64,mf4", .avl = (_TEST_VLENB >> 5) - 1, .expected_vl = 0},
{.vtypei = "e8,mf4",
.avl = (_TEST_VLENB >> 2),
.expected_vl = (_TEST_VLENB >> 2)},
@@ -1056,7 +1033,7 @@
.avl = (_TEST_VLENB >> 3),
.expected_vl = (_TEST_VLENB >> 3)},
{.vtypei = "e32,mf4", .avl = (_TEST_VLENB >> 4), .expected_vl = 0},
- {.vtypei = "e64,mf4", .avl = (_TEST_VLENB >> 5), .expected_vl = 0},
+ // {.vtypei = "e64,mf4", .avl = (_TEST_VLENB >> 5), .expected_vl = 0},
{.vtypei = "e8,mf4",
.avl = (_TEST_VLENB >> 2) + 1,
.expected_vl = (_TEST_VLENB >> 2)},
@@ -1064,16 +1041,16 @@
.avl = (_TEST_VLENB >> 3) + 1,
.expected_vl = (_TEST_VLENB >> 3)},
{.vtypei = "e32,mf4", .avl = (_TEST_VLENB >> 4) + 1, .expected_vl = 0},
- {.vtypei = "e64,mf4", .avl = (_TEST_VLENB >> 5) + 1, .expected_vl = 0},
+ // {.vtypei = "e64,mf4", .avl = (_TEST_VLENB >> 5) + 1, .expected_vl = 0},
{.vtypei = "e8,mf2", .avl = 0, .expected_vl = 0},
{.vtypei = "e16,mf2", .avl = 0, .expected_vl = 0},
{.vtypei = "e32,mf2", .avl = 0, .expected_vl = 0},
- {.vtypei = "e64,mf2", .avl = 0, .expected_vl = 0},
+ // {.vtypei = "e64,mf2", .avl = 0, .expected_vl = 0},
{.vtypei = "e8,mf2", .avl = 1, .expected_vl = 1},
{.vtypei = "e16,mf2", .avl = 1, .expected_vl = 1},
{.vtypei = "e32,mf2", .avl = 1, .expected_vl = 1},
- {.vtypei = "e64,mf2", .avl = 1, .expected_vl = 0},
+ // {.vtypei = "e64,mf2", .avl = 1, .expected_vl = 0},
{.vtypei = "e8,mf2",
.avl = (_TEST_VLENB >> 1) - 1,
.expected_vl = (_TEST_VLENB >> 1) - 1},
@@ -1083,7 +1060,7 @@
{.vtypei = "e32,mf2",
.avl = (_TEST_VLENB >> 3) - 1,
.expected_vl = (_TEST_VLENB >> 3) - 1},
- {.vtypei = "e64,mf2", .avl = (_TEST_VLENB >> 4) - 1, .expected_vl = 0},
+ // {.vtypei = "e64,mf2", .avl = (_TEST_VLENB >> 4) - 1, .expected_vl = 0},
{.vtypei = "e8,mf2",
.avl = (_TEST_VLENB >> 1),
.expected_vl = (_TEST_VLENB >> 1)},
@@ -1093,7 +1070,7 @@
{.vtypei = "e32,mf2",
.avl = (_TEST_VLENB >> 3),
.expected_vl = (_TEST_VLENB >> 3)},
- {.vtypei = "e64,mf2", .avl = (_TEST_VLENB >> 4), .expected_vl = 0},
+ // {.vtypei = "e64,mf2", .avl = (_TEST_VLENB >> 4), .expected_vl = 0},
{.vtypei = "e8,mf2",
.avl = (_TEST_VLENB >> 1) + 1,
.expected_vl = (_TEST_VLENB >> 1)},
@@ -1103,8 +1080,8 @@
{.vtypei = "e32,mf2",
.avl = (_TEST_VLENB >> 3) + 1,
.expected_vl = (_TEST_VLENB >> 3)},
- {.vtypei = "e64,mf2", .avl = (_TEST_VLENB >> 4) + 1, .expected_vl = 0},
- */
+ // {.vtypei = "e64,mf2", .avl = (_TEST_VLENB >> 4) + 1, .expected_vl = 0},
+
{.vtypei = "e8,m1", .avl = 0, .expected_vl = 0},
{.vtypei = "e16,m1", .avl = 0, .expected_vl = 0},
@@ -1295,11 +1272,12 @@
char new_vtypei[32];
uint32_t vtypei_len = strlength(subtest.vtypei);
memcpy(new_vtypei, subtest.vtypei, vtypei_len);
-
- memcpy(new_vtypei + vtypei_len, ",tu,mu\0", (size_t)7);
- subtest_vsetvli(new_vtypei, subtest.avl, subtest.expected_vl);
- memcpy(new_vtypei + vtypei_len, ",tu,ma\0", (size_t)7);
- subtest_vsetvli(new_vtypei, subtest.avl, subtest.expected_vl);
+ if (strstr(subtest.vtypei, "mf") == NULL) { // non-fractional LMUL.
+ memcpy(new_vtypei + vtypei_len, ",tu,mu\0", (size_t)7);
+ subtest_vsetvli(new_vtypei, subtest.avl, subtest.expected_vl);
+ memcpy(new_vtypei + vtypei_len, ",tu,ma\0", (size_t)7);
+ subtest_vsetvli(new_vtypei, subtest.avl, subtest.expected_vl);
+ }
memcpy(new_vtypei + vtypei_len, ",ta,mu\0", (size_t)7);
subtest_vsetvli(new_vtypei, subtest.avl, subtest.expected_vl);
memcpy(new_vtypei + vtypei_len, ",ta,ma\0", (size_t)7);
@@ -1312,42 +1290,44 @@
// vsetivli rd, uimm, vtypei # rd = new vl, uimm = AVL, vtypei = new vtype
// setting
-#define VSETIVLI_SUBTEST(AVL, VTYPEI, EXPECTED_VL) \
- do { \
- LOG_INFO("Subtest %u", subtest_count++); \
- uint32_t observed_vl = 0; \
- __asm__ volatile("vsetivli t0, " STRING_LITERAL(AVL) ", " VTYPEI \
- ", tu, mu"); \
- COPY_SCALAR_REG(observed_vl); \
- if (observed_vl != EXPECTED_VL) { \
- LOG_INFO("Subtest observed_vl = %u, expected_vl = %d", observed_vl, \
- EXPECTED_VL); \
- } \
- assert(observed_vl == EXPECTED_VL); \
- __asm__ volatile("vsetivli t0, " STRING_LITERAL(AVL) ", " VTYPEI \
- ", tu, ma"); \
- COPY_SCALAR_REG(observed_vl); \
- if (observed_vl != EXPECTED_VL) { \
- LOG_INFO("Subtest observed_vl = %u, expected_vl = %d", observed_vl, \
- EXPECTED_VL); \
- } \
- assert(observed_vl == EXPECTED_VL); \
- __asm__ volatile("vsetivli t0, " STRING_LITERAL(AVL) ", " VTYPEI \
- ", ta, mu"); \
- COPY_SCALAR_REG(observed_vl); \
- if (observed_vl != EXPECTED_VL) { \
- LOG_INFO("Subtest observed_vl = %u, expected_vl = %d", observed_vl, \
- EXPECTED_VL); \
- } \
- assert(observed_vl == EXPECTED_VL); \
- __asm__ volatile("vsetivli t0, " STRING_LITERAL(AVL) ", " VTYPEI \
- ", ta, ma"); \
- COPY_SCALAR_REG(observed_vl); \
- if (observed_vl != EXPECTED_VL) { \
- LOG_INFO("Subtest observed_vl = %u, expected_vl = %d", observed_vl, \
- EXPECTED_VL); \
- } \
- assert(observed_vl == EXPECTED_VL); \
+#define VSETIVLI_SUBTEST(AVL, VTYPEI, EXPECTED_VL) \
+ do { \
+ LOG_INFO("Subtest %u", subtest_count++); \
+ uint32_t observed_vl = 0; \
+ if (strstr(VTYPEI, "mf") == NULL) { \
+ __asm__ volatile("vsetivli t0, " STRING_LITERAL(AVL) ", " VTYPEI \
+ ", tu, mu"); \
+ COPY_SCALAR_REG(observed_vl); \
+ if (observed_vl != EXPECTED_VL) { \
+ LOG_INFO("Subtest observed_vl = %u, expected_vl = %d", observed_vl, \
+ EXPECTED_VL); \
+ } \
+ assert(observed_vl == EXPECTED_VL); \
+ __asm__ volatile("vsetivli t0, " STRING_LITERAL(AVL) ", " VTYPEI \
+ ", tu, ma"); \
+ COPY_SCALAR_REG(observed_vl); \
+ if (observed_vl != EXPECTED_VL) { \
+ LOG_INFO("Subtest observed_vl = %u, expected_vl = %d", observed_vl, \
+ EXPECTED_VL); \
+ } \
+ assert(observed_vl == EXPECTED_VL); \
+ } \
+ __asm__ volatile("vsetivli t0, " STRING_LITERAL(AVL) ", " VTYPEI \
+ ", ta, mu"); \
+ COPY_SCALAR_REG(observed_vl); \
+ if (observed_vl != EXPECTED_VL) { \
+ LOG_INFO("Subtest observed_vl = %u, expected_vl = %d", observed_vl, \
+ EXPECTED_VL); \
+ } \
+ assert(observed_vl == EXPECTED_VL); \
+ __asm__ volatile("vsetivli t0, " STRING_LITERAL(AVL) ", " VTYPEI \
+ ", ta, ma"); \
+ COPY_SCALAR_REG(observed_vl); \
+ if (observed_vl != EXPECTED_VL) { \
+ LOG_INFO("Subtest observed_vl = %u, expected_vl = %d", observed_vl, \
+ EXPECTED_VL); \
+ } \
+ assert(observed_vl == EXPECTED_VL); \
} while (0)
#if _TEST_VLEN == 256
@@ -1414,32 +1394,31 @@
// AVL immediate is 5 bits -> 31 is the max
uint32_t subtest_count = 0;
- /*
VSETIVLI_SUBTEST(0, "e8,mf8", 0);
VSETIVLI_SUBTEST(0, "e16,mf8", 0);
VSETIVLI_SUBTEST(0, "e32,mf8", 0);
- VSETIVLI_SUBTEST(0, "e64,mf8", 0);
+ // VSETIVLI_SUBTEST(0, "e64,mf8", 0);
VSETIVLI_SUBTEST(1, "e8,mf8", 1);
VSETIVLI_SUBTEST(1, "e16,mf8", 0);
VSETIVLI_SUBTEST(1, "e32,mf8", 0);
- VSETIVLI_SUBTEST(1, "e64,mf8", 0);
+ // VSETIVLI_SUBTEST(1, "e64,mf8", 0);
VSETIVLI_SUBTEST(0, "e8,mf4", 0);
VSETIVLI_SUBTEST(0, "e16,mf4", 0);
VSETIVLI_SUBTEST(0, "e32,mf4", 0);
- VSETIVLI_SUBTEST(0, "e64,mf4", 0);
+ // VSETIVLI_SUBTEST(0, "e64,mf4", 0);
VSETIVLI_SUBTEST(1, "e8,mf4", 1);
VSETIVLI_SUBTEST(1, "e16,mf4", 1);
VSETIVLI_SUBTEST(1, "e32,mf4", 0);
- VSETIVLI_SUBTEST(1, "e64,mf4", 0);
+ // VSETIVLI_SUBTEST(1, "e64,mf4", 0);
VSETIVLI_SUBTEST(0, "e8,mf2", 0);
VSETIVLI_SUBTEST(0, "e16,mf2", 0);
VSETIVLI_SUBTEST(0, "e32,mf2", 0);
- VSETIVLI_SUBTEST(0, "e64,mf2", 0);
+ // VSETIVLI_SUBTEST(0, "e64,mf2", 0);
VSETIVLI_SUBTEST(1, "e8,mf2", 1);
VSETIVLI_SUBTEST(1, "e16,mf2", 1);
VSETIVLI_SUBTEST(1, "e32,mf2", 1);
- VSETIVLI_SUBTEST(1, "e64,mf2", 0);
- */
+ // VSETIVLI_SUBTEST(1, "e64,mf2", 0);
+
VSETIVLI_SUBTEST(0, "e8,m1", 0);
VSETIVLI_SUBTEST(0, "e16,m1", 0);
VSETIVLI_SUBTEST(0, "e32,m1", 0);
@@ -1474,70 +1453,70 @@
// VSETIVLI_SUBTEST(1, "e64,m8", 1);
#if VLENB_DIV8_SUB1 < 32
- // VSETIVLI_SUBTEST(VLENB_DIV8_SUB1, "e8,mf8", VLENB_DIV8_SUB1);
- // VSETIVLI_SUBTEST(VLENB_DIV8_SUB1, "e16,mf4", VLENB_DIV8_SUB1);
- // VSETIVLI_SUBTEST(VLENB_DIV8_SUB1, "e32,mf2", VLENB_DIV8_SUB1);
+ VSETIVLI_SUBTEST(VLENB_DIV8_SUB1, "e8,mf8", VLENB_DIV8_SUB1);
+ VSETIVLI_SUBTEST(VLENB_DIV8_SUB1, "e16,mf4", VLENB_DIV8_SUB1);
+ VSETIVLI_SUBTEST(VLENB_DIV8_SUB1, "e32,mf2", VLENB_DIV8_SUB1);
// VSETIVLI_SUBTEST(VLENB_DIV8_SUB1, "e64,m1", VLENB_DIV8_SUB1);
#endif
#if VLENB_DIV8 < 32
- // VSETIVLI_SUBTEST(VLENB_DIV8, "e8,mf8", VLENB_DIV8);
- // VSETIVLI_SUBTEST(VLENB_DIV8, "e16,mf4", VLENB_DIV8);
- // VSETIVLI_SUBTEST(VLENB_DIV8, "e32,mf2", VLENB_DIV8);
+ VSETIVLI_SUBTEST(VLENB_DIV8, "e8,mf8", VLENB_DIV8);
+ VSETIVLI_SUBTEST(VLENB_DIV8, "e16,mf4", VLENB_DIV8);
+ VSETIVLI_SUBTEST(VLENB_DIV8, "e32,mf2", VLENB_DIV8);
// VSETIVLI_SUBTEST(VLENB_DIV8, "e64,m1", VLENB_DIV8);
#endif
#if VLENB_DIV8_ADD1 < 32
- // VSETIVLI_SUBTEST(VLENB_DIV8_ADD1, "e8,mf8", VLENB_DIV8);
- // VSETIVLI_SUBTEST(VLENB_DIV8_ADD1, "e16,mf4", VLENB_DIV8);
- // VSETIVLI_SUBTEST(VLENB_DIV8_ADD1, "e32,mf2", VLENB_DIV8);
+ VSETIVLI_SUBTEST(VLENB_DIV8_ADD1, "e8,mf8", VLENB_DIV8);
+ VSETIVLI_SUBTEST(VLENB_DIV8_ADD1, "e16,mf4", VLENB_DIV8);
+ VSETIVLI_SUBTEST(VLENB_DIV8_ADD1, "e32,mf2", VLENB_DIV8);
// VSETIVLI_SUBTEST(VLENB_DIV8_ADD1, "e64,m1", VLENB_DIV8);
#endif
#if VLENB_DIV4_SUB1 < 32
- // VSETIVLI_SUBTEST(VLENB_DIV4_SUB1, "e8,mf4", VLENB_DIV4_SUB1);
- // VSETIVLI_SUBTEST(VLENB_DIV4_SUB1, "e16,mf2", VLENB_DIV4_SUB1);
+ VSETIVLI_SUBTEST(VLENB_DIV4_SUB1, "e8,mf4", VLENB_DIV4_SUB1);
+ VSETIVLI_SUBTEST(VLENB_DIV4_SUB1, "e16,mf2", VLENB_DIV4_SUB1);
VSETIVLI_SUBTEST(VLENB_DIV4_SUB1, "e32,m1", VLENB_DIV4_SUB1);
// VSETIVLI_SUBTEST(VLENB_DIV4_SUB1, "e64,m2", VLENB_DIV4_SUB1);
#endif
#if VLENB_DIV4 < 32
- // VSETIVLI_SUBTEST(VLENB_DIV4, "e8,mf4", VLENB_DIV4);
- // VSETIVLI_SUBTEST(VLENB_DIV4, "e16,mf2", VLENB_DIV4);
+ VSETIVLI_SUBTEST(VLENB_DIV4, "e8,mf4", VLENB_DIV4);
+ VSETIVLI_SUBTEST(VLENB_DIV4, "e16,mf2", VLENB_DIV4);
VSETIVLI_SUBTEST(VLENB_DIV4, "e32,m1", VLENB_DIV4);
// VSETIVLI_SUBTEST(VLENB_DIV4, "e64,m2", VLENB_DIV4);
#endif
#if VLENB_DIV4_ADD1 < 32
- // VSETIVLI_SUBTEST(VLENB_DIV4_ADD1, "e8,mf4", VLENB_DIV4);
- // VSETIVLI_SUBTEST(VLENB_DIV4_ADD1, "e16,mf2", VLENB_DIV4);
+ VSETIVLI_SUBTEST(VLENB_DIV4_ADD1, "e8,mf4", VLENB_DIV4);
+ VSETIVLI_SUBTEST(VLENB_DIV4_ADD1, "e16,mf2", VLENB_DIV4);
VSETIVLI_SUBTEST(VLENB_DIV4_ADD1, "e32,m1", VLENB_DIV4);
// VSETIVLI_SUBTEST(VLENB_DIV4_ADD1, "e64,m2", VLENB_DIV4);
#endif
#if VLENB_DIV2_SUB1 < 32
- // VSETIVLI_SUBTEST(VLENB_DIV2_SUB1, "e8,mf2", VLENB_DIV2_SUB1);
+ VSETIVLI_SUBTEST(VLENB_DIV2_SUB1, "e8,mf2", VLENB_DIV2_SUB1);
VSETIVLI_SUBTEST(VLENB_DIV2_SUB1, "e16,m1", VLENB_DIV2_SUB1);
VSETIVLI_SUBTEST(VLENB_DIV2_SUB1, "e32,m2", VLENB_DIV2_SUB1);
// VSETIVLI_SUBTEST(VLENB_DIV2_SUB1, "e64,m4", VLENB_DIV2_SUB1);
#endif
#if VLENB_DIV2 < 32
- // VSETIVLI_SUBTEST(VLENB_DIV2, "e8,mf2", VLENB_DIV2);
+ VSETIVLI_SUBTEST(VLENB_DIV2, "e8,mf2", VLENB_DIV2);
VSETIVLI_SUBTEST(VLENB_DIV2, "e16,m1", VLENB_DIV2);
VSETIVLI_SUBTEST(VLENB_DIV2, "e32,m2", VLENB_DIV2);
// VSETIVLI_SUBTEST(VLENB_DIV2, "e64,m4", VLENB_DIV2);
#endif
#if VLENB_DIV2_ADD1 < 32
- // VSETIVLI_SUBTEST(VLENB_DIV2_ADD1, "e8,mf2", VLENB_DIV2);
+ VSETIVLI_SUBTEST(VLENB_DIV2_ADD1, "e8,mf2", VLENB_DIV2);
VSETIVLI_SUBTEST(VLENB_DIV2_ADD1, "e16,m1", VLENB_DIV2);
VSETIVLI_SUBTEST(VLENB_DIV2_ADD1, "e32,m2", VLENB_DIV2);
// VSETIVLI_SUBTEST(VLENB_DIV2_ADD1, "e64,m4", VLENB_DIV2);
#endif
#if VLENB_SUB1 < 32
- /*
+
VSETIVLI_SUBTEST(VLENB_SUB1, "e16,mf8", 0);
VSETIVLI_SUBTEST(VLENB_SUB1, "e32,mf8", 0);
VSETIVLI_SUBTEST(VLENB_SUB1, "e64,mf8", 0);
@@ -1552,11 +1531,11 @@
VSETIVLI_SUBTEST(VLENB_SUB1, "e32,mf4", 0);
VSETIVLI_SUBTEST(VLENB_SUB1, "e64,mf4", 0);
VSETIVLI_SUBTEST(VLENB_SUB1, "e32,mf4", 0);
- VSETIVLI_SUBTEST(VLENB_SUB1, "e64,mf4", 0);
- VSETIVLI_SUBTEST(VLENB_SUB1, "e64,mf2", 0);
- VSETIVLI_SUBTEST(VLENB_SUB1, "e64,mf2", 0);
- VSETIVLI_SUBTEST(VLENB_SUB1, "e64,mf2", 0);
- */
+ // VSETIVLI_SUBTEST(VLENB_SUB1, "e64,mf4", 0);
+ // VSETIVLI_SUBTEST(VLENB_SUB1, "e64,mf2", 0);
+ // VSETIVLI_SUBTEST(VLENB_SUB1, "e64,mf2", 0);
+ // VSETIVLI_SUBTEST(VLENB_SUB1, "e64,mf2", 0);
+
VSETIVLI_SUBTEST(VLENB_SUB1, "e8,m1", VLENB_SUB1);
VSETIVLI_SUBTEST(VLENB_SUB1, "e16,m2", VLENB_SUB1);
VSETIVLI_SUBTEST(VLENB_SUB1, "e32,m4", VLENB_SUB1);