hcq move map to allocator (#5610)

* hcq move map to allocator

* fix
This commit is contained in:
nimlgen
2024-07-20 19:02:45 +03:00
committed by GitHub
parent ac99ecd94e
commit 0de5812032
4 changed files with 9 additions and 5 deletions

View File

@@ -362,6 +362,8 @@ class AMDAllocator(HCQAllocator):
def _free(self, opaque, options:BufferOptions): self.device._gpu_free(opaque)
def map(self, buf:HCQBuffer): self.device._gpu_map(buf._base if hasattr(buf, '_base') else buf)
MAP_FIXED, MAP_NORESERVE = 0x10, 0x400
@dataclass
@@ -380,7 +382,6 @@ class AMDDevice(HCQCompiled):
gpus:List[pathlib.Path] = []
def _gpu_map(self, mem):
mem = mem._base if hasattr(mem, '_base') else mem
if self.gpu_id in getattr(mem, "mapped_gpu_ids", []): return
mem.__setattr__("mapped_gpu_ids", getattr(mem, "mapped_gpu_ids", []) + [self.gpu_id])
c_gpus = (ctypes.c_int32 * len(mem.mapped_gpu_ids))(*mem.mapped_gpu_ids)