add HCQDEV_WAIT_TIMEOUT_MS (#6968)

This commit is contained in:
nimlgen 2024-10-09 19:50:00 +03:00 committed by GitHub
parent 35cf48659b
commit f90d8493cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -44,7 +44,7 @@ class AMDSignal(HCQSignal):
def _get_value(self) -> int: return self._signal[0]
def _get_timestamp(self) -> decimal.Decimal: return decimal.Decimal(self._signal[1]) / decimal.Decimal(100)
def _set_value(self, new_value:int): self._signal[0] = new_value
def wait(self, value:int, timeout:int=10000):
def wait(self, value:int, timeout:int=getenv("HCQDEV_WAIT_TIMEOUT_MS", 30000)):
start_time = time.time() * 1000
while (time_spent:=time.time() * 1000 - start_time) < timeout:
if self._signal[0] >= value: return

View File

@ -1,7 +1,7 @@
from __future__ import annotations
from typing import List, Optional, Dict, Tuple, Any, cast, Protocol, Type, Union
import contextlib, decimal, statistics, random, json, atexit, time, array, ctypes
from tinygrad.helpers import PROFILEPATH, PROFILE, from_mv
from tinygrad.helpers import PROFILEPATH, PROFILE, from_mv, getenv
from tinygrad.renderer import Renderer
from tinygrad.device import BufferOptions, Allocator, Compiler, Compiled, LRUAllocator
@ -219,7 +219,7 @@ class HCQSignal:
return self._get_timestamp()
def _get_timestamp(self) -> decimal.Decimal: raise NotImplementedError("_get_timestamp() method must be implemented")
def wait(self, value:int, timeout:int=10000):
def wait(self, value:int, timeout:int=getenv("HCQDEV_WAIT_TIMEOUT_MS", 30000)):
"""
Waits the signal is greater than or equal to a specific value.