MCPcopy Index your code
hub / github.com/tinygrad/tinygrad / palloc

Method palloc

tinygrad/runtime/support/memory.py:274–279  ·  view source on GitHub ↗
(self, size:int, align:int=0x1000, zero=True, boot=False, ptable=False)

Source from the content-addressed store, hash-verified

272 for paddr, _ in vm.paddrs: self.pfree(paddr)
273
274 def palloc(self, size:int, align:int=0x1000, zero=True, boot=False, ptable=False) -> int:
275 assert self.dev.is_booting == boot, "During booting, only boot memory can be allocated"
276 allocator = self.boot_allocator if boot else (self.ptable_allocator if self.reserve_ptable and ptable else self.pa_allocator)
277 paddr = allocator.alloc(round_up(size, 0x1000), align)
278 if zero: self.dev.vram[paddr:paddr+size] = bytes(size)
279 return paddr
280
281 def pfree(self, paddr:int, ptable=False): (self.ptable_allocator if self.reserve_ptable and ptable else self.pa_allocator).free(paddr)

Callers 9

__init__Method · 0.95
vallocMethod · 0.95
level_downMethod · 0.80
init_swMethod · 0.80
init_swMethod · 0.80
init_swMethod · 0.80
_alloc_ringMethod · 0.80
init_swMethod · 0.80
_alloc_boot_memMethod · 0.80

Calls 2

round_upFunction · 0.90
allocMethod · 0.45

Tested by

no test coverage detected