mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-09 06:58:11 -05:00
fix HCQGraph.__del__ bug when finalizing (#13298)
* fix _do_ioctl import * fix circular import * suppress_finalizing instead
This commit is contained in:
committed by
GitHub
parent
8c1e2a42fd
commit
b2af92c821
@@ -1,6 +1,6 @@
|
||||
import collections, time
|
||||
from typing import Any, cast
|
||||
from tinygrad.helpers import round_up, PROFILE, merge_dicts, getenv, dedup
|
||||
from tinygrad.helpers import round_up, PROFILE, merge_dicts, getenv, dedup, suppress_finalizing
|
||||
from tinygrad.runtime.support.hcq import HCQCompiled, HCQAllocator, HCQSignal, HCQBuffer, HWQueue, HCQArgsState, BumpAllocator, MMIOInterface
|
||||
from tinygrad.device import Buffer, BufferSpec, Compiled, Device, ProfileGraphEntry, ProfileGraphEvent
|
||||
from tinygrad.dtype import dtypes
|
||||
@@ -221,6 +221,7 @@ class HCQGraph(MultiGraphRunner):
|
||||
|
||||
def dev_name(self, dev) -> str: return dev.device.replace(":", "_")
|
||||
|
||||
@suppress_finalizing
|
||||
def __del__(self):
|
||||
for dev in self.devices: self.last_timeline[dev][0].wait(self.last_timeline[dev][1])
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ class QCOMComputeQueue(HWQueue):
|
||||
self.dev = dev
|
||||
super().__init__()
|
||||
|
||||
@suppress_finalizing
|
||||
def __del__(self):
|
||||
if self.binded_device is not None: self.binded_device.allocator.free(self.hw_page, self.hw_page.size, BufferSpec(cpu_access=True, nolru=True))
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import ctypes, functools, sys
|
||||
from typing import TYPE_CHECKING
|
||||
from tinygrad.helpers import flatten
|
||||
from tinygrad.helpers import flatten, WIN
|
||||
from _ctypes import _SimpleCData
|
||||
|
||||
def _do_ioctl(__idir, __base, __nr, __struct, __fd, *args, __payload=None, **kwargs):
|
||||
assert not WIN, "ioctl not supported"
|
||||
import tinygrad.runtime.support.hcq as hcq, fcntl
|
||||
ioctl = __fd.ioctl if isinstance(__fd, hcq.FileIOInterface) else functools.partial(fcntl.ioctl, __fd)
|
||||
if (rc:=ioctl((__idir<<30)|(ctypes.sizeof(out:=(__payload or __struct(*args, **kwargs)))<<16)|(__base<<8)|__nr, out)):
|
||||
|
||||
Reference in New Issue
Block a user