mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-04 07:18:50 +00:00
serve telemetry: the Windows AMD reader reads only AMD adapters and only the engine's own card (#4884 follow-up)
Found by the Linux suites (Boston) and a Windows run of tools/test_windows_amd_gpu.py on a PC with an NVIDIA card beside an AMD iGPU: - ADL's adapter list can hold another vendor's adapter: rows without VEN_1002 / vendor 0x1002 are never a card (the Monitor named the RTX 5070 as the AMD card). - an ADL row is used only when its name matches the registry's name of HIP's card (no positional fallback when the registry lists AMD cards): otherwise the Monitor shows what it showed before. - _Adl loads atiadlxx.dll only on a real Windows (sys.platform win32 too): a test that sets os.name to nt on Linux reached ctypes' Windows branch (ModuleNotFoundError: nt). - tests/terminal/test_no_debugger_children.py lists the new PowerShell spawn site of serve/telemetry.py. Tests: serve/test_telemetry_adl.py (vendor filter, no match = no reading), tools/test_windows_amd_gpu.py, test_no_debugger_children, test_monitor, test_prometheus: 55 passed.
This commit is contained in:
1 parent
3c39183e1a
commit
e46fd29a0a
3 files changed
+16
-8
No files matched your search
+10
-6
@@ -330,7 +330,7 @@ class _Adl:
|
||||
|
||||
def __init__(self):
|
||||
self.lib = None
|
||||
if os.name != "nt":
|
||||
if os.name != "nt" or sys.platform != "win32": # (sys.platform too: a test that sets os.name to "nt" on Linux must not reach a Windows DLL load)
|
||||
return
|
||||
try:
|
||||
self.lib = ctypes.CDLL("atiadlxx.dll")
|
||||
@@ -342,7 +342,7 @@ class _Adl:
|
||||
self.crt.malloc.restype = ctypes.c_void_p
|
||||
self.crt.malloc.argtypes = [ctypes.c_size_t]
|
||||
self.ALLOC = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_int)(self._alloc)
|
||||
except (OSError, TypeError, ValueError, AttributeError):
|
||||
except (OSError, TypeError, ValueError, AttributeError, ImportError):
|
||||
self.lib = None
|
||||
|
||||
|
||||
@@ -356,6 +356,8 @@ def _adl_cards(buf, count):
|
||||
if not nm or not (buf[i].Present or buf[i].Exist):
|
||||
continue
|
||||
udid = buf[i].UDID or b""
|
||||
if buf[i].VendorID not in (0x1002, 1002) and b"VEN_1002" not in udid.upper(): # ADL can list another vendor's adapter (an NVIDIA card beside the iGPU)
|
||||
continue
|
||||
dev = udid.split(b"DEV_", 1)[1].split(b"&", 1)[0] if b"DEV_" in udid else None
|
||||
key = dev or nm
|
||||
if key in seen:
|
||||
@@ -537,13 +539,15 @@ class _AmdWin:
|
||||
|
||||
def _pick_card(adl_names, index, hip_names):
|
||||
"""Which of ADL's card rows is HIP's card `index`: the k-th row named like hip_names[index] (k = how many cards of
|
||||
that name come before it in HIP's order), else row `index`; None when there is no such row."""
|
||||
if 0 <= index < len(hip_names):
|
||||
that name come before it in HIP's order); None when no row has that name (the Monitor then shows what it showed before
|
||||
rather than another card's readings). Only when the registry lists no AMD card at all: row `index`."""
|
||||
if hip_names:
|
||||
if not 0 <= index < len(hip_names):
|
||||
return None
|
||||
want = hip_names[index].strip().lower()
|
||||
k = sum(1 for n in hip_names[:index] if n.strip().lower() == want)
|
||||
rows = [r for r, n in enumerate(adl_names) if n.strip().lower() == want]
|
||||
if k < len(rows):
|
||||
return rows[k]
|
||||
return rows[k] if k < len(rows) else None
|
||||
return index if 0 <= index < len(adl_names) else None
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class OnlyTheMonitor(unittest.TestCase):
|
||||
with mock.patch.object(t.os, "name", "posix"), mock.patch.object(t, "_AmdWin") as win:
|
||||
self.assertIsInstance(t.monitor_reader(0, amd=True), t._Amd)
|
||||
win.assert_not_called()
|
||||
with mock.patch.object(t.os, "name", "nt"), mock.patch.object(t, "_AmdWin") as win:
|
||||
with mock.patch.object(t.os, "name", "nt"), mock.patch.object(t, "_AmdWin") as win, mock.patch.object(t, "_Nvml"), mock.patch.object(t, "_Metal"):
|
||||
t.monitor_reader(0, amd=False) # NVIDIA / Metal: never ADL2
|
||||
win.assert_not_called()
|
||||
|
||||
@@ -95,6 +95,7 @@ class Mapping(unittest.TestCase):
|
||||
self.assertEqual([t._pick_card(same, i, same) for i in (0, 1)], [0, 1]) # two of one name
|
||||
self.assertEqual(t._pick_card(adl, 1, []), 1) # no registry list
|
||||
self.assertIsNone(t._pick_card(adl, 2, []))
|
||||
self.assertIsNone(t._pick_card(["AMD Radeon(TM) Graphics"], 0, ["AMD Radeon RX 6900 XT"])) # no ADL row for the HIP card: no reading
|
||||
|
||||
def test_cards_skip_the_igpu_beside_a_card_and_keep_an_apu_alone(self):
|
||||
A = t._Adl.AdapterInfo
|
||||
@@ -107,6 +108,9 @@ class Mapping(unittest.TestCase):
|
||||
buf = rows((b"AMD Radeon(TM) Graphics", b"164e"), (b"AMD Radeon RX 9070 XT", b"7550"), (b"AMD Radeon RX 9070 XT", b"7550"))
|
||||
self.assertEqual(t._adl_cards(buf, 3), [(1, "7550", "AMD Radeon RX 9070 XT", False)]) # one row per card, no iGPU
|
||||
apu = rows((b"AMD Radeon(TM) 8060S Graphics", b"1586"), (b"AMD Radeon(TM) 8060S Graphics", b"1586"))
|
||||
nv = rows((b"NVIDIA GeForce RTX 5070", b"2F04"), (b"AMD Radeon(TM) Graphics", b"164E"))
|
||||
nv[0].UDID = b"PCI_VEN_10DE&DEV_2F04"
|
||||
self.assertEqual(t._adl_cards(nv, 2), [(1, "164E", "AMD Radeon(TM) Graphics", True)]) # another vendor's adapter is never a card
|
||||
self.assertEqual(t._adl_cards(apu, 2), [(0, "1586", "AMD Radeon(TM) 8060S Graphics", True)])
|
||||
|
||||
def test_link_fields(self):
|
||||
|
||||
@@ -162,7 +162,7 @@ STRATA_PROGRAMS = {
|
||||
}
|
||||
OTHER_PROGRAMS = {
|
||||
"serve/mcp.py": 2, # the person's MCP servers and taskkill
|
||||
"serve/telemetry.py": 2, # sysctl, a Metal tool
|
||||
"serve/telemetry.py": 3, # sysctl, a Metal tool, PowerShell's Get-PnpDevice (the Windows AMD PCIe link, #4884)
|
||||
"strata_control/doctor.py": 1,
|
||||
"strata_control/engine_component.py": 4, # nvidia-smi, powershell, lspci-style probes
|
||||
"strata_control/gpu_roles.py": 1, # python -c
|
||||
|
||||
Reference in new issue
Block a user