diff --git a/bindings/sysman/python/source/examples/pyzes_black_box_test.py b/bindings/sysman/python/source/examples/pyzes_black_box_test.py index 978f19d0..be4371b9 100755 --- a/bindings/sysman/python/source/examples/pyzes_black_box_test.py +++ b/bindings/sysman/python/source/examples/pyzes_black_box_test.py @@ -436,6 +436,10 @@ def test_global_operation(driver_handle, device_handle, device_index): ProcessArray = pz.zes_process_state_t * process_count.value processes = ProcessArray() + for i in range(process_count.value): + processes[i].stype = pz.ZES_STRUCTURE_TYPE_PROCESS_STATE + processes[i].pNext = None + rc = pz.zesDeviceProcessesGetState( device_handle, byref(process_count), processes ) @@ -447,11 +451,10 @@ def test_global_operation(driver_handle, device_handle, device_index): for i in range(process_count.value): process = processes[i] print_verbose(f" Process {i}:") - print_verbose(f" PID: {process.pid}") + print_verbose(f" PID: {process.processId}") print_verbose(f" Memory Size: {process.memSize} bytes") - print_verbose(f" Shared Memory Size: {process.sharedMemSize} bytes") - print_verbose(f" Engine Type Flags: 0x{process.engineType:08X}") - print_verbose(f" Subdevice ID: {process.subdeviceId}") + print_verbose(f" Shared Memory Size: {process.sharedSize} bytes") + print_verbose(f" Engine Type Flags: 0x{process.engines:08X}") return True @@ -475,6 +478,10 @@ def test_device_processes(device_handle, device_index): ProcessArray = pz.zes_process_state_t * process_count.value processes = ProcessArray() + for i in range(process_count.value): + processes[i].stype = pz.ZES_STRUCTURE_TYPE_PROCESS_STATE + processes[i].pNext = None + rc = pz.zesDeviceProcessesGetState(device_handle, byref(process_count), processes) if not check_rc(f"zesDeviceProcessesGetState(device {device_index}, handles)", rc): return False @@ -482,11 +489,10 @@ def test_device_processes(device_handle, device_index): for i in range(process_count.value): process = processes[i] print_verbose(f" Process {i}:") - print_verbose(f" PID: {process.pid}") + print_verbose(f" PID: {process.processId}") print_verbose(f" Memory Size: {process.memSize} bytes") - print_verbose(f" Shared Memory Size: {process.sharedMemSize} bytes") - print_verbose(f" Engine Type Flags: 0x{process.engineType:08X}") - print_verbose(f" Subdevice ID: {process.subdeviceId}") + print_verbose(f" Shared Memory Size: {process.sharedSize} bytes") + print_verbose(f" Engine Type Flags: 0x{process.engines:08X}") return True @@ -849,13 +855,13 @@ def test_temperature_sensors(device_handle, device_index): print_verbose(" Temperature Config:") print_verbose(f" Critical Enabled: {bool(temp_config.enableCritical)}") print_verbose( - f" Threshold 1: {temp_config.threshold1:.1f} °C" - if temp_config.threshold1 >= 0 + f" Threshold 1: {temp_config.threshold1.threshold:.1f} °C" + if temp_config.threshold1.threshold >= 0 else " Threshold 1: Not set" ) print_verbose( - f" Threshold 2: {temp_config.threshold2:.1f} °C" - if temp_config.threshold2 >= 0 + f" Threshold 2: {temp_config.threshold2.threshold:.1f} °C" + if temp_config.threshold2.threshold >= 0 else " Threshold 2: Not set" ) else: diff --git a/bindings/sysman/python/source/pyzes.py b/bindings/sysman/python/source/pyzes.py index f7841f50..a1fdcde6 100644 --- a/bindings/sysman/python/source/pyzes.py +++ b/bindings/sysman/python/source/pyzes.py @@ -334,6 +334,7 @@ class zes_engine_handle_t(c_void_p): # Structure type enum values ZES_STRUCTURE_TYPE_DEVICE_PROPERTIES = 0x1 +ZES_STRUCTURE_TYPE_PROCESS_STATE = 0x16 ZES_STRUCTURE_TYPE_DEVICE_EXT_PROPERTIES = 0x2D # from zes_structure_type_t ZES_STRUCTURE_TYPE_SUBDEVICE_EXP_PROPERTIES = 0x2E # Experimental subdevice properties ZES_STRUCTURE_TYPE_MEM_PROPERTIES = 0xB @@ -396,14 +397,14 @@ class zes_device_properties_t(_PrintableStructure): ## Sysman zes_process_state_t ## class zes_process_state_t(_PrintableStructure): _fields_ = [ - ("pid", c_uint32), - ("command", c_char * ZES_STRING_PROPERTY_SIZE), - ("memSize", c_uint64), # in bytes - ("sharedMemSize", c_uint64), # in bytes - ("engineType", zes_engine_type_flags_t), - ("subdeviceId", c_uint32), + ("stype", c_int32), + ("pNext", c_void_p), + ("processId", c_uint32), + ("memSize", c_uint64), + ("sharedSize", c_uint64), + ("engines", zes_engine_type_flags_t), ] - _fmt_ = {"memSize": "%d bytes", "sharedMemSize": "%d bytes"} + _fmt_ = {"memSize": "%d bytes", "sharedSize": "%d bytes"} ## Sysman zes_uuid_t ## @@ -524,15 +525,23 @@ class zes_temp_properties_t(_PrintableStructure): _fmt_ = {"maxTemperature": "%.1f °C"} +class zes_temp_threshold_t(_PrintableStructure): + _fields_ = [ + ("enableLowToHigh", ze_bool_t), + ("enableHighToLow", ze_bool_t), + ("threshold", c_double), + ] + _fmt_ = {"threshold": "%.1f °C"} + + class zes_temp_config_t(_PrintableStructure): _fields_ = [ ("stype", c_int32), # ZES_STRUCTURE_TYPE_TEMP_CONFIG ("pNext", c_void_p), ("enableCritical", ze_bool_t), # enable critical temperature event - ("threshold1", c_double), # threshold 1 in degrees Celsius - ("threshold2", c_double), # threshold 2 in degrees Celsius + ("threshold1", zes_temp_threshold_t), + ("threshold2", zes_temp_threshold_t), ] - _fmt_ = {"threshold1": "%.1f °C", "threshold2": "%.1f °C"} ## Engine structures ## diff --git a/bindings/sysman/python/test/unit_tests/test_global_operations.py b/bindings/sysman/python/test/unit_tests/test_global_operations.py index b74a5db5..da6e2460 100644 --- a/bindings/sysman/python/test/unit_tests/test_global_operations.py +++ b/bindings/sysman/python/test/unit_tests/test_global_operations.py @@ -130,28 +130,28 @@ def test_GivenValidDeviceHandleWhenCallingZesDeviceProcessesGetStateWithArrayThe self, mock_get_func ): mock_process_count = 2 - mock_pid_1 = 1234 - mock_pid_2 = 5678 + mock_process_id_1 = 1234 + mock_process_id_2 = 5678 mock_mem_size_1 = 1073741824 # 1GB mock_mem_size_2 = 2147483648 # 2GB - mock_shared_mem_size_1 = 536870912 # 512MB - mock_shared_mem_size_2 = 1073741824 # 1GB - mock_subdevice_id_1 = 0 - mock_subdevice_id_2 = 1 + mock_shared_size_1 = 536870912 # 512MB + mock_shared_size_2 = 1073741824 # 1GB + mock_engines_1 = 0x3 + mock_engines_2 = 0x5 def mock_get_processes_state_with_data(device_handle, count_ptr, processes_ptr): if processes_ptr: # Fill in process data for first process - processes_ptr[0].pid = mock_pid_1 + processes_ptr[0].processId = mock_process_id_1 processes_ptr[0].memSize = mock_mem_size_1 - processes_ptr[0].sharedMemSize = mock_shared_mem_size_1 - processes_ptr[0].subdeviceId = mock_subdevice_id_1 + processes_ptr[0].sharedSize = mock_shared_size_1 + processes_ptr[0].engines = mock_engines_1 # Fill in process data for second process - processes_ptr[1].pid = mock_pid_2 + processes_ptr[1].processId = mock_process_id_2 processes_ptr[1].memSize = mock_mem_size_2 - processes_ptr[1].sharedMemSize = mock_shared_mem_size_2 - processes_ptr[1].subdeviceId = mock_subdevice_id_2 + processes_ptr[1].sharedSize = mock_shared_size_2 + processes_ptr[1].engines = mock_engines_2 else: count_ptr._obj.value = mock_process_count return self.pyzes.ZE_RESULT_SUCCESS @@ -164,6 +164,9 @@ def mock_get_processes_state_with_data(device_handle, count_ptr, processes_ptr): # Create array for process states process_array = (self.pyzes.zes_process_state_t * mock_process_count)() + for i in range(mock_process_count): + process_array[i].stype = self.pyzes.ZES_STRUCTURE_TYPE_PROCESS_STATE + process_array[i].pNext = None result = self.pyzes.zesDeviceProcessesGetState( device_handle, byref(count), process_array @@ -172,16 +175,16 @@ def mock_get_processes_state_with_data(device_handle, count_ptr, processes_ptr): self.assertEqual(result, self.pyzes.ZE_RESULT_SUCCESS) # Validate first process data - self.assertEqual(process_array[0].pid, mock_pid_1) + self.assertEqual(process_array[0].processId, mock_process_id_1) self.assertEqual(process_array[0].memSize, mock_mem_size_1) - self.assertEqual(process_array[0].sharedMemSize, mock_shared_mem_size_1) - self.assertEqual(process_array[0].subdeviceId, mock_subdevice_id_1) + self.assertEqual(process_array[0].sharedSize, mock_shared_size_1) + self.assertEqual(process_array[0].engines, mock_engines_1) # Validate second process data - self.assertEqual(process_array[1].pid, mock_pid_2) + self.assertEqual(process_array[1].processId, mock_process_id_2) self.assertEqual(process_array[1].memSize, mock_mem_size_2) - self.assertEqual(process_array[1].sharedMemSize, mock_shared_mem_size_2) - self.assertEqual(process_array[1].subdeviceId, mock_subdevice_id_2) + self.assertEqual(process_array[1].sharedSize, mock_shared_size_2) + self.assertEqual(process_array[1].engines, mock_engines_2) mock_get_func.assert_called_with("zesDeviceProcessesGetState") mock_func.assert_called_once() diff --git a/bindings/sysman/python/test/unit_tests/test_temperature.py b/bindings/sysman/python/test/unit_tests/test_temperature.py index d59414ca..adde881c 100644 --- a/bindings/sysman/python/test/unit_tests/test_temperature.py +++ b/bindings/sysman/python/test/unit_tests/test_temperature.py @@ -105,8 +105,8 @@ def test_GivenValidTemperatureHandleWhenCallingZesTemperatureGetConfigThenCallSu def mock_get_config(temp_handle, config_ptr): config_ptr._obj.enableCritical = mock_enable_critical - config_ptr._obj.threshold1 = mock_threshold1 - config_ptr._obj.threshold2 = mock_threshold2 + config_ptr._obj.threshold1.threshold = mock_threshold1 + config_ptr._obj.threshold2.threshold = mock_threshold2 return self.pyzes.ZE_RESULT_SUCCESS mock_func = MagicMock(side_effect=mock_get_config) @@ -118,8 +118,8 @@ def mock_get_config(temp_handle, config_ptr): self.assertEqual(result, self.pyzes.ZE_RESULT_SUCCESS) self.assertEqual(temp_config.enableCritical, mock_enable_critical) - self.assertEqual(temp_config.threshold1, mock_threshold1) - self.assertEqual(temp_config.threshold2, mock_threshold2) + self.assertEqual(temp_config.threshold1.threshold, mock_threshold1) + self.assertEqual(temp_config.threshold2.threshold, mock_threshold2) mock_get_func.assert_called_with("zesTemperatureGetConfig") mock_func.assert_called_once() diff --git a/bindings/sysman/python/test/unit_tests/test_utils.py b/bindings/sysman/python/test/unit_tests/test_utils.py index bb60640b..fce9c0c5 100644 --- a/bindings/sysman/python/test/unit_tests/test_utils.py +++ b/bindings/sysman/python/test/unit_tests/test_utils.py @@ -32,8 +32,8 @@ def test_GivenPrintableStructureWhenConvertedToStringThenProvidesFormattedOutput # Test _PrintableStructure string formatting functionality temp_state = self.pyzes.zes_temp_config_t() temp_state.enableCritical = True - temp_state.threshold1 = 75.0 - temp_state.threshold2 = 80.0 + temp_state.threshold1.threshold = 75.0 + temp_state.threshold2.threshold = 80.0 # Test string representation functionality str_repr = str(temp_state)