do not sleep immediately in amd's wait_signal (#4859)

* that was slow python in hlb

* wait actibely for 5s

* just this

* revert this back

* fix
This commit is contained in:
nimlgen
2024-06-07 16:33:46 +03:00
committed by GitHub
parent 66dfd5e7bf
commit 688b14c933

View File

@@ -464,10 +464,11 @@ class AMDDevice(Compiled):
assert signal.event_id != 0, "can't wait on this signal"
evt_arr = (kfd.struct_kfd_event_data)(event_id=signal.event_id)
# Wait active for 5s, then going to sleep.
start_time = time.time() * 1000
while (time.time() * 1000 - start_time) < timeout:
while (time_spent:=time.time() * 1000 - start_time) < timeout:
if signal.value >= value: return
kio.wait_events(AMDDevice.kfd, events_ptr=ctypes.addressof(evt_arr), num_events=1, wait_for_all=1, timeout=100)
if time_spent > 5000: kio.wait_events(AMDDevice.kfd, events_ptr=ctypes.addressof(evt_arr), num_events=1, wait_for_all=1, timeout=1000)
raise RuntimeError(f"wait_signal: not set to {value}, but {signal.value}, {timeout} ms TIMEOUT!")
def __init__(self, device:str=""):