Skip to content

Commit

Permalink
Vector tester clean up (#241)
Browse files Browse the repository at this point in the history
Added a parameter to the Vector tester to be able to reduce code size.
Also removed several redundant tests.
  • Loading branch information
kathlenemagnus authored Dec 18, 2024
1 parent 0a1d7b4 commit 175595f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 224 deletions.
57 changes: 18 additions & 39 deletions test/core/vector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
174 changes: 27 additions & 147 deletions test/core/vector/Vector_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>("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<std::string>("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<uint32_t>("EXPECTED_NUM_UOPS", &expected_num_uops)->default_value(0),
"");

int err_code = 0;
if (!cls.parse(argc, argv, err_code))
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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);
}
}

Expand Down
12 changes: 12 additions & 0 deletions test/core/vector/elementwise.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
22 changes: 0 additions & 22 deletions test/core/vector/vmulvx_e8m4.json

This file was deleted.

16 changes: 0 additions & 16 deletions test/core/vector/vsadd.json

This file was deleted.

0 comments on commit 175595f

Please sign in to comment.