Skip to content

Commit 9e496cb

Browse files
abslock128wcharris
authored andcommitted
TST: fix POWER VSX feature mapping (numpy#30801)
1 parent 8052c4b commit 9e496cb

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

numpy/_core/tests/test_cpu_features.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,42 @@ def load_flags(self):
378378
@pytest.mark.skipif(not is_linux or not is_power, reason="Only for Linux and Power")
379379
class Test_POWER_Features(AbstractTest):
380380
features = ["VSX", "VSX2", "VSX3", "VSX4"]
381-
features_map = {"VSX2": "ARCH_2_07", "VSX3": "ARCH_3_00", "VSX4": "ARCH_3_1"}
381+
features_map = {
382+
"VSX": "ARCH_2_06",
383+
"VSX2": "ARCH_2_07",
384+
"VSX3": "ARCH_3_00",
385+
"VSX4": "ARCH_3_1B"
386+
}
382387

383388
def load_flags(self):
384389
self.load_flags_auxv()
390+
platform = self._get_platform()
391+
392+
if platform:
393+
power_match = re.search(r'power(\d+)', platform, re.IGNORECASE)
394+
if power_match:
395+
power_gen = int(power_match.group(1))
396+
if power_gen >= 7:
397+
self.features_flags.add("ARCH_2_06")
398+
if power_gen >= 8:
399+
self.features_flags.add("ARCH_2_07")
400+
if power_gen >= 9:
401+
self.features_flags.add("ARCH_3_00")
402+
if power_gen >= 10:
403+
self.features_flags.add("ARCH_3_1B")
404+
405+
def _get_platform(self):
406+
"""Get the AT_PLATFORM value from AUXV"""
407+
try:
408+
auxv = subprocess.check_output(['/bin/true'], env={"LD_SHOW_AUXV": "1"})
409+
for line in auxv.split(b'\n'):
410+
if line.startswith(b'AT_PLATFORM'):
411+
parts = line.split(b':', 1)
412+
if len(parts) == 2:
413+
return parts[1].strip().decode().lower()
414+
except Exception:
415+
pass
416+
return None
385417

386418

387419
is_zarch = re.match(r"^(s390x)", machine, re.IGNORECASE)

0 commit comments

Comments
 (0)