From bf2a0907bef25ec50602cece95131f2b3f6318ed Mon Sep 17 00:00:00 2001 From: George Hotz <72895+geohot@users.noreply.github.com> Date: Fri, 23 May 2025 11:44:02 -0700 Subject: [PATCH] gate the mockdsp behind MOCKDSP=1 [pr] (#10486) --- .github/workflows/test.yml | 2 ++ tinygrad/runtime/ops_dsp.py | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7f50c60dc1..be11a87151 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -544,6 +544,8 @@ jobs: tags: qemu-hexagon:latest cache-from: type=gha cache-to: type=gha,mode=min + - name: Set MOCKDSP env + run: printf "MOCKDSP=1" >> $GITHUB_ENV - name: Run test_tiny on DSP run: DEBUG=2 DSP=1 python test/test_tiny.py - name: Test transcendentals diff --git a/tinygrad/runtime/ops_dsp.py b/tinygrad/runtime/ops_dsp.py index 3264be212f..449f8936f2 100644 --- a/tinygrad/runtime/ops_dsp.py +++ b/tinygrad/runtime/ops_dsp.py @@ -130,7 +130,9 @@ class ClangCompiler(Compiler): class DSPDevice(Compiled): def __init__(self, device:str=""): compiler_args = ["--target=hexagon", "-mcpu=hexagonv65", "-fuse-ld=lld", "-nostdlib", "-mhvx=v65", "-mhvx-length=128b"] - try: + if getenv("MOCKDSP"): + super().__init__(device, MallocAllocator, MockDSPRenderer(), ClangCompiler(None, ["-static"] + compiler_args, 'llvm-objdump'), MockDSPProgram) + else: self.ion_fd = os.open('/dev/ion', os.O_RDONLY) # Generate link script to pass into clang. Aligning all used sections to 4k fixes invoke problem. sections = ['text', 'rela.plt', 'rela.dyn', 'plt', 'data', 'bss', 'hash', 'dynamic', @@ -150,8 +152,6 @@ class DSPDevice(Compiled): self.init_dsp() RPCListener(self).start() - except FileNotFoundError: - super().__init__(device, MallocAllocator, MockDSPRenderer(), ClangCompiler(None, ["-static"] + compiler_args, 'llvm-objdump'), MockDSPProgram) def open_lib(self, lib): self.binded_lib, self.binded_lib_off = lib, 0