Skip to content

Commit 175595f

Browse files
Vector tester clean up (#241)
Added a parameter to the Vector tester to be able to reduce code size. Also removed several redundant tests.
1 parent 0a1d7b4 commit 175595f

File tree

5 files changed

+57
-224
lines changed

5 files changed

+57
-224
lines changed

test/core/vector/CMakeLists.txt

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,7 @@ file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vsetvli_vaddvv_e32m1ta.json ${
1313
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vsetvl_vaddvv_e64m1ta.json ${CMAKE_CURRENT_BINARY_DIR}/vsetvl_vaddvv_e64m1ta.json SYMBOLIC)
1414
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vsetivli_vaddvv_tail_e8m8ta.json ${CMAKE_CURRENT_BINARY_DIR}/vsetivli_vaddvv_tail_e8m8ta.json SYMBOLIC)
1515
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/multiple_vset.json ${CMAKE_CURRENT_BINARY_DIR}/multiple_vset.json SYMBOLIC)
16-
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vmulvx_e8m4.json ${CMAKE_CURRENT_BINARY_DIR}/vmulvx_e8m4.json SYMBOLIC)
17-
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vwmulvv_e8m4.json ${CMAKE_CURRENT_BINARY_DIR}/vwmulvv_e8m4.json SYMBOLIC)
18-
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vmseqvv_e8m4.json ${CMAKE_CURRENT_BINARY_DIR}/vmseqvv_e8m4.json SYMBOLIC)
1916
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vrgather.json ${CMAKE_CURRENT_BINARY_DIR}/vrgather.json SYMBOLIC)
20-
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/vsadd.json ${CMAKE_CURRENT_BINARY_DIR}/vsadd.json SYMBOLIC)
21-
22-
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)
23-
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)
24-
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)
25-
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)
26-
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)
27-
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)
28-
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)
29-
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)
30-
sparta_named_test(Vector_test_vsadd Vector_test -l top info vsadd.out -c test_cores/test_big_core.yaml --input-file vsadd.json)
31-
sparta_named_test(Vector_unsupported_test Vector_test -l top info unsupported.out -c test_cores/test_big_core.yaml --input-file vrgather.json)
3217

3318
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/elementwise.json ${CMAKE_CURRENT_BINARY_DIR}/elementwise.json SYMBOLIC)
3419
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
3924
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/single_dest.json ${CMAKE_CURRENT_BINARY_DIR}/single_dest.json SYMBOLIC)
4025
file(CREATE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/int_ext.json ${CMAKE_CURRENT_BINARY_DIR}/int_ext.json SYMBOLIC)
4126

42-
sparta_named_test(Vector_test_elementwise
43-
Vector_test -l top info vuop_elementwise.out -c test_cores/test_big_core.yaml --input-file elementwise.json
44-
)
45-
sparta_named_test(Vector_test_widening
46-
Vector_test -l top info vuop_widening.out -c test_cores/test_big_core.yaml --input-file widening.json
47-
)
48-
sparta_named_test(Vector_test_widening_mixed
49-
Vector_test -l top info vuop_widening_mixed.out -c test_cores/test_big_core.yaml --input-file widening_mixed.json
50-
)
51-
sparta_named_test(Vector_test_narrowing
52-
Vector_test -l top info vuop_narrowing.out -c test_cores/test_big_core.yaml --input-file narrowing.json
53-
)
54-
sparta_named_test(Vector_test_mac
55-
Vector_test -l top info vuop_mac.out -c test_cores/test_big_core.yaml --input-file mac.json
56-
)
57-
sparta_named_test(Vector_test_mac_widening
58-
Vector_test -l top info vuop_mac_widening.out -c test_cores/test_big_core.yaml --input-file mac_widening.json
59-
)
60-
sparta_named_test(Vector_test_single_dest
61-
Vector_test -l top info vuop_single_dest.out -c test_cores/test_big_core.yaml --input-file single_dest.json
62-
)
27+
# Vset tests
28+
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)
29+
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)
30+
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)
31+
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)
32+
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)
33+
34+
# Unsupported test
35+
sparta_named_test(Vector_unsupported_test Vector_test -l top info unsupported.out -c test_cores/test_big_core.yaml --input-file vrgather.json)
6336

64-
sparta_named_test(Vector_test_int_ext
65-
Vector_test -l top info vuop_int_ext.out -c test_cores/test_big_core.yaml --input-file int_ext.json
66-
)
37+
# Vector sequencing tests
38+
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)
39+
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)
40+
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)
41+
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)
42+
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)
43+
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)
44+
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)
45+
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)

test/core/vector/Vector_test.cpp

Lines changed: 27 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,18 @@ void runTests(int argc, char** argv)
101101
{
102102
DEFAULTS.auto_summary_default = "off";
103103
std::string input_file;
104+
uint32_t expected_num_uops;
104105

105106
sparta::app::CommandLineSimulator cls(USAGE, DEFAULTS);
106107
auto & app_opts = cls.getApplicationOptions();
107-
app_opts.add_options()(
108-
"input-file",
109-
sparta::app::named_value<std::string>("INPUT_FILE", &input_file)->default_value(""),
110-
"Provide a JSON instruction stream",
111-
"Provide a JSON file with instructions to run through Execute");
108+
app_opts.add_options()
109+
("input-file",
110+
sparta::app::named_value<std::string>("INPUT_FILE", &input_file)->default_value(""),
111+
"Provide a JSON instruction stream",
112+
"Provide a JSON file with instructions to run through Execute")
113+
("expected-num-uops",
114+
sparta::app::named_value<uint32_t>("EXPECTED_NUM_UOPS", &expected_num_uops)->default_value(0),
115+
"");
112116

113117
int err_code = 0;
114118
if (!cls.parse(argc, argv, err_code))
@@ -153,6 +157,9 @@ void runTests(int argc, char** argv)
153157
decode_tester.test_sew(8);
154158
decode_tester.test_vlmax(512);
155159

160+
// Test Vector Uop Generation
161+
vuop_tester.test_num_vuops_generated(expected_num_uops);
162+
156163
// Test Retire
157164
rob_tester.test_num_insts_retired(2);
158165
// vset + 4 vadd.vv uops
@@ -171,6 +178,9 @@ void runTests(int argc, char** argv)
171178
decode_tester.test_sew(32);
172179
decode_tester.test_vlmax(32);
173180

181+
// Test Vector Uop Generation
182+
vuop_tester.test_num_vuops_generated(expected_num_uops);
183+
174184
// Test Retire
175185
rob_tester.test_num_insts_retired(2);
176186
// vset + 1 vadd.vv uop
@@ -189,6 +199,9 @@ void runTests(int argc, char** argv)
189199
decode_tester.test_sew(64);
190200
decode_tester.test_vlmax(16);
191201

202+
// Test Vector Uop Generation
203+
vuop_tester.test_num_vuops_generated(expected_num_uops);
204+
192205
// Test Retire
193206
rob_tester.test_num_insts_retired(2);
194207
// vset + 1 vadd.vv uop
@@ -206,6 +219,9 @@ void runTests(int argc, char** argv)
206219
decode_tester.test_sew(8);
207220
decode_tester.test_vlmax(1024);
208221

222+
// Test Vector Uop Generation
223+
vuop_tester.test_num_vuops_generated(expected_num_uops);
224+
209225
// Test Retire
210226
rob_tester.test_num_insts_retired(2);
211227
// vset + 8 vadd.vv uop
@@ -224,47 +240,14 @@ void runTests(int argc, char** argv)
224240
decode_tester.test_sew(8);
225241
decode_tester.test_vlmax(1024);
226242

243+
// Test Vector Uop Generation
244+
vuop_tester.test_num_vuops_generated(expected_num_uops);
245+
227246
// Test Retire
228247
rob_tester.test_num_insts_retired(8);
229248
// vset + 1 vadd.vv + vset + 2 vadd.vv + vset + 4 vadd.vv uop + vset + 8 vadd.vv
230249
rob_tester.test_num_uops_retired(19);
231250
}
232-
else if (input_file.find("vmulvx_e8m4.json") != std::string::npos)
233-
{
234-
cls.runSimulator(&sim);
235-
236-
// Test Retire
237-
rob_tester.test_num_insts_retired(3);
238-
// vadd + 4 vmul.vx uop
239-
rob_tester.test_num_uops_retired(6);
240-
rob_tester.test_last_inst_has_tail(false);
241-
242-
// TODO: Test source values for all uops
243-
}
244-
else if (input_file.find("vwmulvv_e8m4.json") != std::string::npos)
245-
{
246-
cls.runSimulator(&sim);
247-
248-
// Test Retire
249-
rob_tester.test_num_insts_retired(2);
250-
// vadd + 8 vwmul.vv uop
251-
rob_tester.test_num_uops_retired(9);
252-
rob_tester.test_last_inst_has_tail(false);
253-
254-
// TODO: Test destination values for all uops
255-
}
256-
else if (input_file.find("vmseqvv_e8m4.json") != std::string::npos)
257-
{
258-
cls.runSimulator(&sim);
259-
260-
// Test Retire
261-
rob_tester.test_num_insts_retired(2);
262-
// vadd + 4 vmseq.vv uops
263-
rob_tester.test_num_uops_retired(5);
264-
rob_tester.test_last_inst_has_tail(false);
265-
266-
// TODO: Test destination values for all uops
267-
}
268251
else if (input_file.find("vrgather.json") != std::string::npos)
269252
{
270253
// Unsupported vector instructions are expected to make the simulator to throw
@@ -279,115 +262,12 @@ void runTests(int argc, char** argv)
279262
}
280263
EXPECT_TRUE(sparta_exception_fired);
281264
}
282-
else if (input_file.find("vsadd.json") != std::string::npos)
283-
{
284-
cls.runSimulator(&sim);
285-
286-
rob_tester.test_num_insts_retired(2);
287-
rob_tester.test_num_uops_retired(5);
288-
rob_tester.test_last_inst_has_tail(false);
289-
290-
vuop_tester.test_num_vuops_generated(4);
291-
}
292-
else if (input_file.find("elementwise.json") != std::string::npos)
293-
{
294-
cls.runSimulator(&sim);
295-
296-
decode_tester.test_lmul(4);
297-
decode_tester.test_vl(256);
298-
decode_tester.test_vta(false);
299-
decode_tester.test_sew(32);
300-
decode_tester.test_vlmax(128);
301-
302-
vuop_tester.test_num_vuops_generated(4);
303-
}
304-
else if (input_file.find("widening.json") != std::string::npos)
305-
{
306-
cls.runSimulator(&sim);
307-
308-
decode_tester.test_lmul(4);
309-
decode_tester.test_vl(256);
310-
decode_tester.test_vta(false);
311-
decode_tester.test_sew(32);
312-
decode_tester.test_vlmax(128);
313-
314-
vuop_tester.test_num_vuops_generated(8);
315-
}
316-
else if (input_file.find("widening_mixed.json") != std::string::npos)
317-
{
318-
cls.runSimulator(&sim);
319-
320-
decode_tester.test_lmul(4);
321-
decode_tester.test_vl(256);
322-
decode_tester.test_vta(false);
323-
decode_tester.test_sew(32);
324-
decode_tester.test_vlmax(128);
325-
326-
vuop_tester.test_num_vuops_generated(8);
327-
}
328-
else if (input_file.find("mac.json") != std::string::npos)
329-
{
330-
cls.runSimulator(&sim);
331-
332-
decode_tester.test_lmul(4);
333-
decode_tester.test_vl(256);
334-
decode_tester.test_vta(false);
335-
decode_tester.test_sew(32);
336-
decode_tester.test_vlmax(128);
337-
338-
vuop_tester.test_num_vuops_generated(4);
339-
}
340-
else if (input_file.find("mac_widening.json") != std::string::npos)
341-
{
342-
cls.runSimulator(&sim);
343-
344-
decode_tester.test_lmul(4);
345-
decode_tester.test_vl(256);
346-
decode_tester.test_vta(false);
347-
decode_tester.test_sew(32);
348-
decode_tester.test_vlmax(128);
349-
350-
vuop_tester.test_num_vuops_generated(8);
351-
}
352-
else if (input_file.find("single_dest.json") != std::string::npos)
353-
{
354-
cls.runSimulator(&sim);
355-
356-
decode_tester.test_lmul(4);
357-
decode_tester.test_vl(256);
358-
decode_tester.test_vta(false);
359-
decode_tester.test_sew(32);
360-
decode_tester.test_vlmax(128);
361-
362-
vuop_tester.test_num_vuops_generated(4);
363-
}
364-
else if (input_file.find("narrowing.json") != std::string::npos)
365-
{
366-
cls.runSimulator(&sim);
367-
368-
decode_tester.test_lmul(4);
369-
decode_tester.test_vl(256);
370-
decode_tester.test_vta(false);
371-
decode_tester.test_sew(32);
372-
decode_tester.test_vlmax(128);
373-
374-
vuop_tester.test_num_vuops_generated(8);
375-
}
376-
else if (input_file.find("int_ext.json") != std::string::npos)
265+
else
377266
{
378267
cls.runSimulator(&sim);
379268

380-
decode_tester.test_lmul(4);
381-
decode_tester.test_vl(256);
382-
decode_tester.test_vta(false);
383-
decode_tester.test_sew(64);
384-
decode_tester.test_vlmax(64);
385-
386-
vuop_tester.test_num_vuops_generated(12);
387-
}
388-
else
389-
{
390-
sparta_assert(false, "Invalid input file: " << input_file);
269+
// Test Vector Uop Generation
270+
vuop_tester.test_num_vuops_generated(expected_num_uops);
391271
}
392272
}
393273

test/core/vector/elementwise.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,17 @@
1212
"vd": 12,
1313
"vs2": 4,
1414
"vs1": 8
15+
},
16+
{
17+
"mnemonic": "add",
18+
"rs1": 1,
19+
"rs2": 2,
20+
"rd": 3
21+
},
22+
{
23+
"mnemonic": "vmul.vx",
24+
"vd": 5,
25+
"vs2": 4,
26+
"rs1": 3
1527
}
1628
]

test/core/vector/vmulvx_e8m4.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

test/core/vector/vsadd.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)