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

Method __init__

tinygrad/runtime/ops_dsp.py:123–137  ·  view source on GitHub ↗
(self, mock:bool=False)

Source from the content-addressed store, hash-verified

121
122class DSPCompiler(Compiler):
123 def __init__(self, mock:bool=False):
124 compiler_args = "--target=hexagon -mcpu=hexagonv65 -fuse-ld=lld -nostdlib -mhvx=v65 -mhvx-length=128b"
125 if mock: self.args = f"-static {compiler_args}"
126 else:
127 # Generate link script to pass into clang. Aligning all used sections to 4k fixes invoke problem.
128 sections = ['text', 'rela.plt', 'rela.dyn', 'plt', 'data', 'bss', 'hash', 'dynamic',
129 'got', 'got.plt', 'dynsym', 'dynstr', 'symtab', 'shstrtab', 'strtab']
130 sections_link = '\n'.join([f'.{n} : ALIGN(4096) {{ *(.{n}) }}' for n in sections])
131 with tempfile.NamedTemporaryFile(delete=False) as self.link_ld:
132 self.link_ld.write(f"SECTIONS {{ . = 0x0; {sections_link}\n /DISCARD/ : {{ *(.note .note.* .gnu.hash .comment) }} }}".encode())
133 self.link_ld.flush()
134
135 self.args = f"-shared {compiler_args} -T{self.link_ld.name}"
136
137 super().__init__(None if mock else "compile_dsp")
138
139 def compile(self, src:str) -> bytes:
140 # TODO: remove file write. sadly clang doesn't like the use of /dev/stdout here

Callers

nothing calls this directly

Calls 4

flushMethod · 0.80
writeMethod · 0.45
encodeMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected