Skip to content

Commit 335bc04

Browse files
committed
feature: Add more APIs to L0 Sysman python binding
Related-To: NEO-18602 Added following APIs to python binding: 1. zesDevicePciGetProperties 2. zesDevicePciGetStats 3. zesDeviceEccAvailable 4. zesDeviceEccConfigurable 5. zesDeviceGetEccState 6. zesDeviceSetEccState 7. zesPowerGetLimitsExt 8. zesPowerSetLimitsExt 9. zesFrequencyGetAvailableClocks 10. zesFrequencyGetRange 11. zesFrequencySetRange 12. zesFrequencyGetThrottleTime 13. zesDevicePciGetState 14. zesPowerGetProperties 15. zesFrequencyGetProperties Signed-off-by: Aviral Nigam <aviral.nigam@intel.com>
1 parent 7ad2583 commit 335bc04

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

bindings/sysman/python/source/examples/pyzes_black_box_test.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,22 @@ def setup_environment():
5959
setup_environment()
6060

6161
verbose = True
62+
ZE_RESULT_NAMES = {
63+
value: name
64+
for name, value in vars(pz).items()
65+
if name.startswith("ZE_RESULT_") and isinstance(value, int)
66+
}
67+
68+
69+
def get_result_string(result):
70+
"""Convert ze_result_t value to enum name."""
71+
return ZE_RESULT_NAMES.get(result, f"UNKNOWN_ZE_RESULT_{result}")
6272

6373

6474
def check_rc(label, rc):
6575
"""Check return code and exit on error"""
6676
if rc != pz.ZE_RESULT_SUCCESS:
67-
print(f"ERROR: {label} failed with ze_result_t={rc}")
77+
print(f"ERROR: {label} failed with {get_result_string(rc)}")
6878
return False
6979
return True
7080

@@ -321,7 +331,7 @@ def check_rc_allow_action_required(label, rc):
321331
"""Accept ZE_RESULT_SUCCESS and ZE_RESULT_WARNING_ACTION_REQUIRED"""
322332
if rc in (pz.ZE_RESULT_SUCCESS, pz.ZE_RESULT_WARNING_ACTION_REQUIRED):
323333
return True
324-
print(f"ERROR: {label} failed with ze_result_t={rc}")
334+
print(f"ERROR: {label} failed with {get_result_string(rc)}")
325335
return False
326336

327337

@@ -531,7 +541,7 @@ def test_global_operation(driver_handle, device_handle, device_index):
531541
print_verbose(f" On subdevice: {bool(on_subdevice.value)}")
532542
print_verbose(f" Subdevice ID: {subdevice_id.value}")
533543
else:
534-
print_verbose(f" UUID mapping failed with return code: {ret}")
544+
print_verbose(f" UUID mapping failed with {get_result_string(ret)}")
535545

536546
except Exception:
537547
print_verbose(" UUID mapping test failed with exception")
@@ -976,11 +986,7 @@ def test_power_module(device_handle, device_index):
976986

977987
limit_descs = None
978988
limit_count = c_uint32(0)
979-
if properties.onSubdevice:
980-
print_verbose(
981-
" Skipping power limit APIs for subdevice-scoped power domain"
982-
)
983-
else:
989+
if not properties.onSubdevice:
984990
rc = pz.zesPowerGetLimitsExt(power_handles[i], byref(limit_count), None)
985991
if not check_rc(f"zesPowerGetLimitsExt(power {i}, count)", rc):
986992
continue
@@ -1331,7 +1337,9 @@ def test_temperature_sensors(device_handle, device_index):
13311337
else " Threshold 2: Not set"
13321338
)
13331339
else:
1334-
print_verbose(f" Temperature Config: Not available (rc={rc})")
1340+
print_verbose(
1341+
f" Temperature Config: Not available ({get_result_string(rc)})"
1342+
)
13351343

13361344
return True
13371345

bindings/sysman/python/source/pyzes.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import sys
1313
import threading
1414
from ctypes import *
15-
from ctypes.util import find_library
1615
from typing import Any, Dict
1716

1817
libLoadLock = threading.Lock()
@@ -68,7 +67,7 @@ def _LoadZeLibrary():
6867
# load the library
6968
libName = "ze_loader"
7069
if sys.platform.startswith("linux"):
71-
libName = find_library(libName) or "libze_loader.so.1"
70+
libName = "/usr/lib/x86_64-linux-gnu/lib" + libName + ".so.1"
7271
else:
7372
# Try multiple common locations for Windows Intel GPU drivers
7473
possible_paths = [

0 commit comments

Comments
 (0)