|
24 | 24 |
|
25 | 25 | # Add the source directory to Python path so we can import pyzes |
26 | 26 | script_dir = os.path.dirname(os.path.abspath(__file__)) |
27 | | -source_dir = os.path.join(script_dir, "..", "source") |
| 27 | +source_dir = os.path.join(script_dir, "..") |
28 | 28 | source_dir = os.path.abspath(source_dir) |
29 | 29 | if source_dir not in sys.path: |
30 | 30 | sys.path.insert(0, source_dir) |
|
38 | 38 | os.environ["ZELLO_SYSMAN_USE_ZESINIT"] = "1" |
39 | 39 |
|
40 | 40 |
|
41 | | -##################################################################################################################################### |
| 41 | +############################################################################### |
42 | 42 | # Helper utilities ## |
43 | 43 | def zes_driver_get_device_by_uuid(hDriver, uuid_bytes: bytes): |
44 | | - """Helper: given a 16-byte UUID (from core device properties), retrieve the corresponding Sysman device handle. |
| 44 | + """Helper: given a 16-byte UUID (from core device properties), retrieve |
| 45 | + the corresponding Sysman device handle. |
45 | 46 | Returns (result_code, device_handle, on_subdevice(bool), subdevice_id(int)). |
46 | 47 | """ |
47 | 48 | if len(uuid_bytes) != ZES_MAX_UUID_SIZE: |
@@ -187,7 +188,9 @@ def enumerate_devices(hDriver, devices, dev_count): |
187 | 188 | if rc2 == 0: |
188 | 189 | same = handle_val(mapped_handle) == handle_val(devices[i]) |
189 | 190 | print( |
190 | | - f" zesDriverGetDeviceByUuidExp: SUCCESS same_handle={same} on_subdevice={on_sub} subdevice_id={sub_id}" |
| 191 | + f" zesDriverGetDeviceByUuidExp: SUCCESS " |
| 192 | + f"same_handle={same} on_subdevice={on_sub} " |
| 193 | + f"subdevice_id={sub_id}" |
191 | 194 | ) |
192 | 195 | else: |
193 | 196 | print(f" zesDriverGetDeviceByUuidExp: rc={rc2}") |
@@ -330,7 +333,9 @@ def demonstrate_memory_state(hDriver, devices, dev_count): |
330 | 333 | continue |
331 | 334 | print(f" Bandwidth: {mem_bandwidth}") |
332 | 335 | print( |
333 | | - f" Max Bandwidth: {mem_bandwidth.maxBandwidth:,} bytes/sec ({mem_bandwidth.maxBandwidth / (1024**3):.2f} GB/s)" |
| 336 | + f" Max Bandwidth: {mem_bandwidth.maxBandwidth:,} " |
| 337 | + f"bytes/sec " |
| 338 | + f"({mem_bandwidth.maxBandwidth / (1024**3):.2f} GB/s)" |
334 | 339 | ) |
335 | 340 | print(f" Read Counter: {mem_bandwidth.readCounter:,} bytes") |
336 | 341 | print(f" Write Counter: {mem_bandwidth.writeCounter:,} bytes") |
@@ -440,17 +445,20 @@ def demonstrate_power_energy(hDriver, devices, dev_count): |
440 | 445 | energy_counter2.timestamp - energy_counter.timestamp |
441 | 446 | ) / 1000000.0 |
442 | 447 |
|
443 | | - print(f" Second reading:") |
| 448 | + print(" Second reading:") |
444 | 449 | print( |
445 | | - f" Energy: {energy_counter2.energy} microjoules ({energy_counter2.energy / 1000000.0:.6f} joules)" |
| 450 | + f" Energy: {energy_counter2.energy} microjoules " |
| 451 | + f"({energy_counter2.energy / 1000000.0:.6f} joules)" |
446 | 452 | ) |
447 | 453 | print( |
448 | | - f" Energy consumed: {energy_diff} microjoules ({energy_diff / 1000000.0:.6f} joules)" |
| 454 | + f" Energy consumed: {energy_diff} microjoules " |
| 455 | + f"({energy_diff / 1000000.0:.6f} joules)" |
449 | 456 | ) |
450 | 457 | if time_diff > 0: |
451 | 458 | avg_power = (energy_diff / 1000000.0) / time_diff # Watts |
452 | 459 | print( |
453 | | - f" Average power: {avg_power:.6f} watts over {time_diff:.6f} seconds" |
| 460 | + f" Average power: {avg_power:.6f} watts " |
| 461 | + f"over {time_diff:.6f} seconds" |
454 | 462 | ) |
455 | 463 |
|
456 | 464 | except Exception as e: |
|
0 commit comments