diff --git a/test/core/vector/CMakeLists.txt b/test/core/vector/CMakeLists.txt index 4f6fde31..f66b4459 100644 --- a/test/core/vector/CMakeLists.txt +++ b/test/core/vector/CMakeLists.txt @@ -13,22 +13,7 @@ file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vsetvli_vaddvv_e32m1ta.json ${ file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vsetvl_vaddvv_e64m1ta.json ${CMAKE_CURRENT_BINARY_DIR}/vsetvl_vaddvv_e64m1ta.json SYMBOLIC) file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vsetivli_vaddvv_tail_e8m8ta.json ${CMAKE_CURRENT_BINARY_DIR}/vsetivli_vaddvv_tail_e8m8ta.json SYMBOLIC) file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/multiple_vset.json ${CMAKE_CURRENT_BINARY_DIR}/multiple_vset.json SYMBOLIC) -file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vmulvx_e8m4.json ${CMAKE_CURRENT_BINARY_DIR}/vmulvx_e8m4.json SYMBOLIC) -file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vwmulvv_e8m4.json ${CMAKE_CURRENT_BINARY_DIR}/vwmulvv_e8m4.json SYMBOLIC) -file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vmseqvv_e8m4.json ${CMAKE_CURRENT_BINARY_DIR}/vmseqvv_e8m4.json SYMBOLIC) file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vrgather.json ${CMAKE_CURRENT_BINARY_DIR}/vrgather.json SYMBOLIC) -file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vsadd.json ${CMAKE_CURRENT_BINARY_DIR}/vsadd.json SYMBOLIC) - -sparta_named_test(Vector_test_vsetivli Vector_test -l top info vsetivli.out -c test_cores/test_big_core.yaml --input-file vsetivli_vaddvv_e8m4.json) -sparta_named_test(Vector_test_vsetvli Vector_test -l top info vsetvli.out -c test_cores/test_big_core.yaml --input-file vsetvli_vaddvv_e32m1ta.json) -sparta_named_test(Vector_test_vsetvl Vector_test -l top info vsetvl.out -c test_cores/test_big_core.yaml --input-file vsetvl_vaddvv_e64m1ta.json) -sparta_named_test(Vector_test_vsetivli_tail Vector_test -l top info vsetivli_tail.out -c test_cores/test_big_core.yaml --input-file vsetivli_vaddvv_tail_e8m8ta.json) -sparta_named_test(Vector_test_multiple_vset Vector_test -l top info mulitple_vset.out -c test_cores/test_big_core.yaml --input-file multiple_vset.json) -sparta_named_test(Vector_test_vmulvx Vector_test -l top info vmulvx.out -c test_cores/test_big_core.yaml --input-file vmulvx_e8m4.json) -sparta_named_test(Vector_test_vmulvv Vector_test -l top info vmulvv.out -c test_cores/test_big_core.yaml --input-file vwmulvv_e8m4.json) -sparta_named_test(Vector_test_vmseqvv Vector_test -l top info vmseqvv.out -c test_cores/test_big_core.yaml --input-file vmseqvv_e8m4.json) -sparta_named_test(Vector_test_vsadd Vector_test -l top info vsadd.out -c test_cores/test_big_core.yaml --input-file vsadd.json) -sparta_named_test(Vector_unsupported_test Vector_test -l top info unsupported.out -c test_cores/test_big_core.yaml --input-file vrgather.json) file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/elementwise.json ${CMAKE_CURRENT_BINARY_DIR}/elementwise.json SYMBOLIC) file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/widening.json ${CMAKE_CURRENT_BINARY_DIR}/widening.json SYMBOLIC) @@ -39,28 +24,22 @@ file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/mac_widening.json ${CMAKE_CURRENT_B file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/single_dest.json ${CMAKE_CURRENT_BINARY_DIR}/single_dest.json SYMBOLIC) file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/int_ext.json ${CMAKE_CURRENT_BINARY_DIR}/int_ext.json SYMBOLIC) -sparta_named_test(Vector_test_elementwise - Vector_test -l top info vuop_elementwise.out -c test_cores/test_big_core.yaml --input-file elementwise.json -) -sparta_named_test(Vector_test_widening - Vector_test -l top info vuop_widening.out -c test_cores/test_big_core.yaml --input-file widening.json -) -sparta_named_test(Vector_test_widening_mixed - Vector_test -l top info vuop_widening_mixed.out -c test_cores/test_big_core.yaml --input-file widening_mixed.json -) -sparta_named_test(Vector_test_narrowing - Vector_test -l top info vuop_narrowing.out -c test_cores/test_big_core.yaml --input-file narrowing.json -) -sparta_named_test(Vector_test_mac - Vector_test -l top info vuop_mac.out -c test_cores/test_big_core.yaml --input-file mac.json -) -sparta_named_test(Vector_test_mac_widening - Vector_test -l top info vuop_mac_widening.out -c test_cores/test_big_core.yaml --input-file mac_widening.json -) -sparta_named_test(Vector_test_single_dest - Vector_test -l top info vuop_single_dest.out -c test_cores/test_big_core.yaml --input-file single_dest.json -) +# Vset tests +sparta_named_test(Vector_test_vsetivli Vector_test -l top info vsetivli.out -c test_cores/test_big_core.yaml --input-file vsetivli_vaddvv_e8m4.json --expected-num-uops 4) +sparta_named_test(Vector_test_vsetvli Vector_test -l top info vsetvli.out -c test_cores/test_big_core.yaml --input-file vsetvli_vaddvv_e32m1ta.json --expected-num-uops 1) +sparta_named_test(Vector_test_vsetvl Vector_test -l top info vsetvl.out -c test_cores/test_big_core.yaml --input-file vsetvl_vaddvv_e64m1ta.json --expected-num-uops 1) +sparta_named_test(Vector_test_vsetivli_tail Vector_test -l top info vsetivli_tail.out -c test_cores/test_big_core.yaml --input-file vsetivli_vaddvv_tail_e8m8ta.json --expected-num-uops 8) +sparta_named_test(Vector_test_multiple_vset Vector_test -l top info mulitple_vset.out -c test_cores/test_big_core.yaml --input-file multiple_vset.json --expected-num-uops 15) + +# Unsupported test +sparta_named_test(Vector_unsupported_test Vector_test -l top info unsupported.out -c test_cores/test_big_core.yaml --input-file vrgather.json) -sparta_named_test(Vector_test_int_ext - Vector_test -l top info vuop_int_ext.out -c test_cores/test_big_core.yaml --input-file int_ext.json -) +# Vector sequencing tests +sparta_named_test(Vector_test_elementwise Vector_test -l top info vuop_elementwise.out -c test_cores/test_big_core.yaml --input-file elementwise.json --expected-num-uops 8) +sparta_named_test(Vector_test_widening Vector_test -l top info vuop_widening.out -c test_cores/test_big_core.yaml --input-file widening.json --expected-num-uops 8) +sparta_named_test(Vector_test_widening_mixed Vector_test -l top info vuop_widening_mixed.out -c test_cores/test_big_core.yaml --input-file widening_mixed.json --expected-num-uops 8) +sparta_named_test(Vector_test_narrowing Vector_test -l top info vuop_narrowing.out -c test_cores/test_big_core.yaml --input-file narrowing.json --expected-num-uops 8) +sparta_named_test(Vector_test_mac Vector_test -l top info vuop_mac.out -c test_cores/test_big_core.yaml --input-file mac.json --expected-num-uops 4) +sparta_named_test(Vector_test_mac_widening Vector_test -l top info vuop_mac_widening.out -c test_cores/test_big_core.yaml --input-file mac_widening.json --expected-num-uops 8) +sparta_named_test(Vector_test_single_dest Vector_test -l top info vuop_single_dest.out -c test_cores/test_big_core.yaml --input-file single_dest.json --expected-num-uops 4) +sparta_named_test(Vector_test_int_ext Vector_test -l top info vuop_int_ext.out -c test_cores/test_big_core.yaml --input-file int_ext.json --expected-num-uops 12) diff --git a/test/core/vector/Vector_test.cpp b/test/core/vector/Vector_test.cpp index f8e976bc..9345e514 100644 --- a/test/core/vector/Vector_test.cpp +++ b/test/core/vector/Vector_test.cpp @@ -101,14 +101,18 @@ void runTests(int argc, char** argv) { DEFAULTS.auto_summary_default = "off"; std::string input_file; + uint32_t expected_num_uops; sparta::app::CommandLineSimulator cls(USAGE, DEFAULTS); auto & app_opts = cls.getApplicationOptions(); - app_opts.add_options()( - "input-file", - sparta::app::named_value("INPUT_FILE", &input_file)->default_value(""), - "Provide a JSON instruction stream", - "Provide a JSON file with instructions to run through Execute"); + app_opts.add_options() + ("input-file", + sparta::app::named_value("INPUT_FILE", &input_file)->default_value(""), + "Provide a JSON instruction stream", + "Provide a JSON file with instructions to run through Execute") + ("expected-num-uops", + sparta::app::named_value("EXPECTED_NUM_UOPS", &expected_num_uops)->default_value(0), + ""); int err_code = 0; if (!cls.parse(argc, argv, err_code)) @@ -153,6 +157,9 @@ void runTests(int argc, char** argv) decode_tester.test_sew(8); decode_tester.test_vlmax(512); + // Test Vector Uop Generation + vuop_tester.test_num_vuops_generated(expected_num_uops); + // Test Retire rob_tester.test_num_insts_retired(2); // vset + 4 vadd.vv uops @@ -171,6 +178,9 @@ void runTests(int argc, char** argv) decode_tester.test_sew(32); decode_tester.test_vlmax(32); + // Test Vector Uop Generation + vuop_tester.test_num_vuops_generated(expected_num_uops); + // Test Retire rob_tester.test_num_insts_retired(2); // vset + 1 vadd.vv uop @@ -189,6 +199,9 @@ void runTests(int argc, char** argv) decode_tester.test_sew(64); decode_tester.test_vlmax(16); + // Test Vector Uop Generation + vuop_tester.test_num_vuops_generated(expected_num_uops); + // Test Retire rob_tester.test_num_insts_retired(2); // vset + 1 vadd.vv uop @@ -206,6 +219,9 @@ void runTests(int argc, char** argv) decode_tester.test_sew(8); decode_tester.test_vlmax(1024); + // Test Vector Uop Generation + vuop_tester.test_num_vuops_generated(expected_num_uops); + // Test Retire rob_tester.test_num_insts_retired(2); // vset + 8 vadd.vv uop @@ -224,47 +240,14 @@ void runTests(int argc, char** argv) decode_tester.test_sew(8); decode_tester.test_vlmax(1024); + // Test Vector Uop Generation + vuop_tester.test_num_vuops_generated(expected_num_uops); + // Test Retire rob_tester.test_num_insts_retired(8); // vset + 1 vadd.vv + vset + 2 vadd.vv + vset + 4 vadd.vv uop + vset + 8 vadd.vv rob_tester.test_num_uops_retired(19); } - else if (input_file.find("vmulvx_e8m4.json") != std::string::npos) - { - cls.runSimulator(&sim); - - // Test Retire - rob_tester.test_num_insts_retired(3); - // vadd + 4 vmul.vx uop - rob_tester.test_num_uops_retired(6); - rob_tester.test_last_inst_has_tail(false); - - // TODO: Test source values for all uops - } - else if (input_file.find("vwmulvv_e8m4.json") != std::string::npos) - { - cls.runSimulator(&sim); - - // Test Retire - rob_tester.test_num_insts_retired(2); - // vadd + 8 vwmul.vv uop - rob_tester.test_num_uops_retired(9); - rob_tester.test_last_inst_has_tail(false); - - // TODO: Test destination values for all uops - } - else if (input_file.find("vmseqvv_e8m4.json") != std::string::npos) - { - cls.runSimulator(&sim); - - // Test Retire - rob_tester.test_num_insts_retired(2); - // vadd + 4 vmseq.vv uops - rob_tester.test_num_uops_retired(5); - rob_tester.test_last_inst_has_tail(false); - - // TODO: Test destination values for all uops - } else if (input_file.find("vrgather.json") != std::string::npos) { // Unsupported vector instructions are expected to make the simulator to throw @@ -279,115 +262,12 @@ void runTests(int argc, char** argv) } EXPECT_TRUE(sparta_exception_fired); } - else if (input_file.find("vsadd.json") != std::string::npos) - { - cls.runSimulator(&sim); - - rob_tester.test_num_insts_retired(2); - rob_tester.test_num_uops_retired(5); - rob_tester.test_last_inst_has_tail(false); - - vuop_tester.test_num_vuops_generated(4); - } - else if (input_file.find("elementwise.json") != std::string::npos) - { - cls.runSimulator(&sim); - - decode_tester.test_lmul(4); - decode_tester.test_vl(256); - decode_tester.test_vta(false); - decode_tester.test_sew(32); - decode_tester.test_vlmax(128); - - vuop_tester.test_num_vuops_generated(4); - } - else if (input_file.find("widening.json") != std::string::npos) - { - cls.runSimulator(&sim); - - decode_tester.test_lmul(4); - decode_tester.test_vl(256); - decode_tester.test_vta(false); - decode_tester.test_sew(32); - decode_tester.test_vlmax(128); - - vuop_tester.test_num_vuops_generated(8); - } - else if (input_file.find("widening_mixed.json") != std::string::npos) - { - cls.runSimulator(&sim); - - decode_tester.test_lmul(4); - decode_tester.test_vl(256); - decode_tester.test_vta(false); - decode_tester.test_sew(32); - decode_tester.test_vlmax(128); - - vuop_tester.test_num_vuops_generated(8); - } - else if (input_file.find("mac.json") != std::string::npos) - { - cls.runSimulator(&sim); - - decode_tester.test_lmul(4); - decode_tester.test_vl(256); - decode_tester.test_vta(false); - decode_tester.test_sew(32); - decode_tester.test_vlmax(128); - - vuop_tester.test_num_vuops_generated(4); - } - else if (input_file.find("mac_widening.json") != std::string::npos) - { - cls.runSimulator(&sim); - - decode_tester.test_lmul(4); - decode_tester.test_vl(256); - decode_tester.test_vta(false); - decode_tester.test_sew(32); - decode_tester.test_vlmax(128); - - vuop_tester.test_num_vuops_generated(8); - } - else if (input_file.find("single_dest.json") != std::string::npos) - { - cls.runSimulator(&sim); - - decode_tester.test_lmul(4); - decode_tester.test_vl(256); - decode_tester.test_vta(false); - decode_tester.test_sew(32); - decode_tester.test_vlmax(128); - - vuop_tester.test_num_vuops_generated(4); - } - else if (input_file.find("narrowing.json") != std::string::npos) - { - cls.runSimulator(&sim); - - decode_tester.test_lmul(4); - decode_tester.test_vl(256); - decode_tester.test_vta(false); - decode_tester.test_sew(32); - decode_tester.test_vlmax(128); - - vuop_tester.test_num_vuops_generated(8); - } - else if (input_file.find("int_ext.json") != std::string::npos) + else { cls.runSimulator(&sim); - decode_tester.test_lmul(4); - decode_tester.test_vl(256); - decode_tester.test_vta(false); - decode_tester.test_sew(64); - decode_tester.test_vlmax(64); - - vuop_tester.test_num_vuops_generated(12); - } - else - { - sparta_assert(false, "Invalid input file: " << input_file); + // Test Vector Uop Generation + vuop_tester.test_num_vuops_generated(expected_num_uops); } } diff --git a/test/core/vector/elementwise.json b/test/core/vector/elementwise.json index 5c63fb3d..b342e326 100644 --- a/test/core/vector/elementwise.json +++ b/test/core/vector/elementwise.json @@ -12,5 +12,17 @@ "vd": 12, "vs2": 4, "vs1": 8 + }, + { + "mnemonic": "add", + "rs1": 1, + "rs2": 2, + "rd": 3 + }, + { + "mnemonic": "vmul.vx", + "vd": 5, + "vs2": 4, + "rs1": 3 } ] diff --git a/test/core/vector/vmulvx_e8m4.json b/test/core/vector/vmulvx_e8m4.json deleted file mode 100644 index c6f97e61..00000000 --- a/test/core/vector/vmulvx_e8m4.json +++ /dev/null @@ -1,22 +0,0 @@ -[ - { - "mnemonic": "vsetivli", - "rs1": 5, - "rd": 1, - "vtype": "0x2", - "vl": 512, - "vta": 0 - }, - { - "mnemonic": "add", - "rs1": 1, - "rs2": 2, - "rd": 3 - }, - { - "mnemonic": "vmul.vx", - "vd": 5, - "vs2": 4, - "rs1": 3 - } -] diff --git a/test/core/vector/vsadd.json b/test/core/vector/vsadd.json deleted file mode 100644 index 6e4925d6..00000000 --- a/test/core/vector/vsadd.json +++ /dev/null @@ -1,16 +0,0 @@ -[ - { - "mnemonic": "vsetvli", - "rs1": 1, - "vtype": "0x2", - "rd": 0, - "vl": 256, - "vta": 0 - }, - { - "mnemonic": "vsadd.vv", - "vd": 12, - "vs2": 8, - "vs1": 4 - } -]