Runtime Overview¤
Overview¤
A typical runtime consists of the following parts:
Compiled¤
The Compiled
class is responsible for initializing and managing a device.
Compiled
¤
Compiled(
device: str,
allocator: Allocator,
renderer: Optional[Renderer],
compiler: Optional[Compiler],
runtime,
graph=None,
)
synchronize
¤
synchronize()
Synchronize all pending operations on the device.
This method ensures that all previously queued operations on the device have been completed before proceeding.
Allocator¤
The Allocator
class is responsible for managing memory on the device. There is also a version called the LRUAllocator
, which caches allocated buffers to optimize performance.
Allocator
¤
LRUAllocator
¤
LRUAllocator()
Bases: Allocator
The LRU Allocator is responsible for caching buffers. It ensures that buffers are not freed until it is absolutely necessary, optimizing performance.
Program¤
The Program
class is created for each loaded program. It is responsible for compiling and executing the program on the device. As an example, here is a ClangProgram
implementation which loads program and runs it.
ClangProgram
¤
Source code in tinygrad/runtime/ops_clang.py
20 21 22 23 24 25 26 |
|
Compiler¤
The Compiler
class compiles the output from the Renderer
and produces it in a device-specific format.
Compiler
¤
Source code in tinygrad/device.py
177 |
|
compile
¤
Source code in tinygrad/device.py
178 |
|
compile_cached
¤
Source code in tinygrad/device.py
179 180 181 182 183 184 |
|