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

Method __init__

tinygrad/runtime/support/memory.py:175–184  ·  view source on GitHub ↗
(self, dev, vram_size:int, boot_size:int, pt_t, va_bits:int, va_shifts:list[int], va_base:int,
               palloc_ranges:list[tuple[int, int]], first_lv:int=0, reserve_ptable=False)

Source from the content-addressed store, hash-verified

173 va_allocator: ClassVar[TLSFAllocator|None] = None
174
175 def __init__(self, dev, vram_size:int, boot_size:int, pt_t, va_bits:int, va_shifts:list[int], va_base:int,
176 palloc_ranges:list[tuple[int, int]], first_lv:int=0, reserve_ptable=False):
177 self.dev, self.vram_size, self.va_shifts, self.va_base, lvl_msb = dev, vram_size, va_shifts, va_base, va_shifts + [va_bits + 1]
178 self.pte_covers, self.pte_cnt = [1 << x for x in va_shifts][::-1], [1 << (lvl_msb[i+1] - lvl_msb[i]) for i in range(len(lvl_msb) - 1)][::-1]
179 self.pt_t, self.palloc_ranges, self.level_cnt, self.va_bits, self.reserve_ptable = pt_t, palloc_ranges, len(va_shifts), va_bits, reserve_ptable
180
181 self.boot_allocator = TLSFAllocator(boot_size, base=0)
182 self.ptable_allocator = TLSFAllocator(round_up(vram_size // 512, 1 << 20) if self.reserve_ptable else 0, base=self.boot_allocator.size)
183 self.pa_allocator = TLSFAllocator(vram_size - (off_sz:=self.boot_allocator.size + self.ptable_allocator.size), base=off_sz)
184 self.root_page_table = pt_t(self.dev, self.palloc(0x1000, zero=not self.dev.smi_dev, boot=True), lv=first_lv)
185
186 def _frag_size(self, va, sz, must_cover=True):
187 """

Callers

nothing calls this directly

Calls 3

pallocMethod · 0.95
round_upFunction · 0.90
TLSFAllocatorClass · 0.70

Tested by

no test coverage detected