MCPcopy
hub / github.com/tinygrad/tinygrad / bind

Method bind

tinygrad/runtime/ops_amd.py:512–522  ·  view source on GitHub ↗
(self, dev:AMDDevice)

Source from the content-addressed store, hash-verified

510 return self
511
512 def bind(self, dev:AMDDevice):
513 if not getenv("AMD_SDMA_BIND", 0) or not dev.is_am(): return
514
515 self.binded_device = dev
516 self.hw_page = dev.allocator.alloc((qsz:=round_up(len(self._q), 8)) * 4, BufferSpec(cpu_access=True, nolru=True, uncached=True))
517 hw_view = self.hw_page.cpu_view().view(fmt='I')
518 for i in range(qsz): hw_view[i] = self._q[i] if i < len(self._q) else 0
519
520 self.indirect_cmd = [self.sdma.SDMA_OP_INDIRECT | self.sdma.SDMA_PKT_INDIRECT_HEADER_VMID(0), *data64_le(self.hw_page.va_addr), qsz,
521 *data64_le(0)]
522 self._q, self.cmd_sizes = hw_view, [len(self.indirect_cmd)]
523
524 def _submit(self, dev:AMDDevice):
525 sdma_queue = dev.sdma_queue(self.queue_idx)

Callers

nothing calls this directly

Calls 8

getenvFunction · 0.90
round_upFunction · 0.90
BufferSpecClass · 0.90
data64_leFunction · 0.90
is_amMethod · 0.45
allocMethod · 0.45
viewMethod · 0.45
cpu_viewMethod · 0.45

Tested by

no test coverage detected