Skip to content

Commit 78ebade

Browse files
authored
Merge pull request tinygrad#9408 from nimlgen/hcq_progress_during_wait
hcq: reset timer on progress in singal.wait
2 parents e174c6c + 4d09ea4 commit 78ebade

File tree

1 file changed

+3
-2
lines changed
  • tinygrad/runtime/support

1 file changed

+3
-2
lines changed

tinygrad/runtime/support/hcq.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,12 @@ def wait(self, value:int, timeout:int=getenv("HCQDEV_WAIT_TIMEOUT_MS", 30000)):
246246
247247
Args:
248248
value: The value to wait for.
249-
timeout: Maximum time to wait in milliseconds. Defaults to 10s.
249+
timeout: Maximum time to wait in milliseconds. Defaults to 30s.
250250
"""
251251
start_time = int(time.perf_counter() * 1000)
252-
while self.value < value and (time_spent:=int(time.perf_counter() * 1000) - start_time) < timeout:
252+
while (prev_value:=self.value) < value and (time_spent:=int(time.perf_counter() * 1000) - start_time) < timeout:
253253
self._sleep(time_spent)
254+
if self.value != prev_value: start_time = int(time.perf_counter() * 1000) # progress was made, reset timer
254255
if self.value < value: raise RuntimeError(f"Wait timeout: {timeout} ms! (the signal is not set to {value}, but {self.value})")
255256

256257
@contextlib.contextmanager

0 commit comments

Comments
 (0)