Expand description
LOGOS → Tenstorrent (TT-Metalium) AOT codegen tier. Emits a complete
single-Tensix-core TT-Metalium program — a host orchestrator plus a
data-movement compute kernel that runs on one baby RISC-V core
(DataMovementProcessor::RISCV_0) — for the scalar-compute fragment of the
benchmark suite.
§Why the C backend is the compute source
A Tensix baby core is a RISC-V CPU and a TT-Metalium kernel is C++; the
canonical add_2_integers_in_riscv kernel is literally dat0[0] = dat0[0] + dat1[0]. So the kernel’s compute body is the SAME self-contained C the
crate::codegen_c backend already emits — which is byte-for-byte ≡ the VM
(locked by assert_c_output). The Tenstorrent tier does not re-lower
arithmetic; it wraps that proven compute in the TT-Metalium host/kernel
split and routes Show to the host DPRINT stream. See wrap.
§What is verified, and when
- Pre-hardware (now, no card): the compute is executably ≡ VM via the C
oracle (
TtArtifact::oracle_c, run through gcc exactly like the C tier), and the emitted host/kernel/CMake carry the correct TT-Metalium API surface. - On-hardware (Phase 5, gated on a Wormhole/Blackhole card + tt-metal SDK):
the host+kernel build against tt-metal and run on the Tensix core, DPRINT
output compared to the VM. That path is
#[ignore]d untilTT_METAL_HOMEis present, so nothing here fabricates an on-silicon result.
§Totality discipline (mirrors the RISC-V / WASM tiers)
Any program using an op outside the single-baby-core fragment — CONCURRENCY
(channels/tasks/select, which need a ucontext scheduler + multiple contexts;
the genuine multi-baby-core mesh tier in concurrency_mesh lowers those) —
returns TtLowerError::Unsupported: a SOUND refusal, never a miscompile.
OFFLINE networking (TT_NET_OPS) is served on-core through the newlib-clean
C net runtime (wrapped verbatim). The tenstorrent_op_coverage_lock ratchet
forces the off-core set onto a shrink-only ledger so nothing is silently dropped.
Modules§
- concurrency_
mesh - LOGOS concurrency pattern RECOGNIZERS — the source-reading half of the concurrency tier.
- matmul_
lower - Genuine LOGOS → Tensix matrix-engine lowering — an AFFINE GEMM-idiom recognizer.
Structs§
- TtArtifact
- A complete single-Tensix-core TT-Metalium program emitted from a LOGOS program.
Enums§
- TtLower
Error - An op / shape outside the current phase’s single-baby-core fragment. The
&strnames what is not yet lowered. A refusal — the backend declines to emit rather than emit wrong code (mirrorscrate::codegen_riscv::RiscVLowerError).
Constants§
- KERNEL_
FILE_ NAME - The single canonical name of the generated kernel source (referenced by the
host
CreateKernelcall and the CMake glue). - TT_
HOST_ TEMPLATE - The host orchestrator. Opens a 1x1 unit mesh on device 0, creates a program
with a single data-movement kernel on
RISCV_0, launches it, waits, and closes. Targets the current TT-MetaliumMeshDeviceAPI (as in theadd_2_integers_in_riscvexample).{KERNEL_FILE}is the kernel source path. - TT_
KERNEL_ PREAMBLE - Prepended to the LOGOS→C compute body to form the compute kernel. Brings in
the TT-Metalium data-movement + DPRINT APIs and bridges the C backend’s
printf/puts(howShowis emitted) to the host DPRINT stream, so kernel output is textually identical to the VM’s. - TT_
NET_ OPS - The OFFLINE NETWORKING ops the single Tensix baby core serves via the loopback transport
(
crate::codegen_c’sC_NET_RUNTIME, wrapped verbatim).Connect/Listen/Syncare no-ops,MakePeeris identity,Send/Streamenqueue a 64-bit message into a per-address FIFO,Awaitdequeues it. That runtime is newlib-clean (strcmp/strdup+ static arrays — noucontext, unlike the concurrency runtime), so it rides the SAME wrap the scalar body does and a single-nodeSend X to peer; Await …round-trips ≡ the VM’s offlineNetInbox. Every op here iscrate::aot_unsupported::Offload::Net; excluded from the refusal below (device-served, not host-only). The CUDA analogue iscodegen_cuda::CUDA_NET_OPS; bound bytenstorrent_op_coverage_lock.
Functions§
- codegen_
program_ tt - Emit
programas a single-Tensix-core TT-Metalium program.oracle_cis the self-contained C translation of the SAME program (fromcrate::compile::compile_to_c); its compute body becomes the kernel. ReturnsTtLowerError::Unsupportedif the program uses any op outside the single-baby-core fragment. - unsupported_
reason - Returns
Some(reason)ifprogramuses an op that cannot run on a single Tensix baby core in this phase — concurrency (a Tensix mesh is SPMD, not a shared-memory thread pool with a scheduler; the concurrency runtime needsucontext, which a baby core has no libc for). Everything else — including single-replica CRDT counters (in-memory maps in the C body) and the OFFLINE networking loopback (TT_NET_OPS, the newlib-cleanC_NET_RUNTIME) — lowers through the proven C compute body.Sleepis virtual-time (a scheduler primitive) and is refused with the concurrency set. - wrap_
as_ tt - Build the TT-Metalium artifact from the self-contained C translation of the
program. The C body is reused verbatim except: system
#include <...>lines are dropped (the kernel preamble supplies the on-core headers) andmainis renamed tologos_main, whichkernel_maininvokes.