|
1 | 1 | """
|
2 | 2 | Test the AArch64 SVE registers dynamic resize with multiple threads.
|
| 3 | +
|
| 4 | +This test assumes a minimum supported vector length (VL) of 256 bits |
| 5 | +and will test 512 bits if possible. We refer to "vg" which is the |
| 6 | +register shown in lldb. This is in units of 64 bits. 256 bit VL is |
| 7 | +the same as a vg of 4. |
3 | 8 | """
|
4 | 9 |
|
5 | 10 | import lldb
|
|
9 | 14 |
|
10 | 15 |
|
11 | 16 | class RegisterCommandsTestCase(TestBase):
|
| 17 | + def get_supported_vg(self): |
| 18 | + # Changing VL trashes the register state, so we need to run the program |
| 19 | + # just to test this. Then run it again for the test. |
| 20 | + exe = self.getBuildArtifact("a.out") |
| 21 | + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
| 22 | + |
| 23 | + main_thread_stop_line = line_number("main.c", "// Break in main thread") |
| 24 | + lldbutil.run_break_set_by_file_and_line(self, "main.c", main_thread_stop_line) |
| 25 | + |
| 26 | + self.runCmd("run", RUN_SUCCEEDED) |
| 27 | + |
| 28 | + self.expect( |
| 29 | + "thread info 1", |
| 30 | + STOPPED_DUE_TO_BREAKPOINT, |
| 31 | + substrs=["stop reason = breakpoint"], |
| 32 | + ) |
| 33 | + |
| 34 | + # Write back the current vg to confirm read/write works at all. |
| 35 | + current_vg = self.match("register read vg", ["(0x[0-9]+)"]) |
| 36 | + self.assertTrue(current_vg is not None) |
| 37 | + self.expect("register write vg {}".format(current_vg.group())) |
| 38 | + |
| 39 | + # Aka 128, 256 and 512 bit. |
| 40 | + supported_vg = [] |
| 41 | + for vg in [2, 4, 8]: |
| 42 | + # This could mask other errors but writing vg is tested elsewhere |
| 43 | + # so we assume the hardware rejected the value. |
| 44 | + self.runCmd("register write vg {}".format(vg), check=False) |
| 45 | + if not self.res.GetError(): |
| 46 | + supported_vg.append(vg) |
| 47 | + |
| 48 | + return supported_vg |
| 49 | + |
12 | 50 | def check_sve_registers(self, vg_test_value):
|
13 | 51 | z_reg_size = vg_test_value * 8
|
14 | 52 | p_reg_size = int(z_reg_size / 8)
|
@@ -56,13 +94,18 @@ def check_sve_registers(self, vg_test_value):
|
56 | 94 | def test_sve_registers_dynamic_config(self):
|
57 | 95 | """Test AArch64 SVE registers multi-threaded dynamic resize."""
|
58 | 96 |
|
| 97 | + if not self.isAArch64SVE(): |
| 98 | + self.skipTest("SVE registers must be supported.") |
| 99 | + |
59 | 100 | self.build()
|
| 101 | + supported_vg = self.get_supported_vg() |
| 102 | + |
| 103 | + if not (2 in supported_vg and 4 in supported_vg): |
| 104 | + self.skipTest("Not all required SVE vector lengths are supported.") |
| 105 | + |
60 | 106 | exe = self.getBuildArtifact("a.out")
|
61 | 107 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
62 | 108 |
|
63 |
| - if not self.isAArch64SVE(): |
64 |
| - self.skipTest("SVE registers must be supported.") |
65 |
| - |
66 | 109 | main_thread_stop_line = line_number("main.c", "// Break in main thread")
|
67 | 110 | lldbutil.run_break_set_by_file_and_line(self, "main.c", main_thread_stop_line)
|
68 | 111 |
|
@@ -90,7 +133,10 @@ def test_sve_registers_dynamic_config(self):
|
90 | 133 | substrs=["stop reason = breakpoint"],
|
91 | 134 | )
|
92 | 135 |
|
93 |
| - self.check_sve_registers(8) |
| 136 | + if 8 in supported_vg: |
| 137 | + self.check_sve_registers(8) |
| 138 | + else: |
| 139 | + self.check_sve_registers(4) |
94 | 140 |
|
95 | 141 | self.runCmd("process continue", RUN_SUCCEEDED)
|
96 | 142 |
|
|
0 commit comments