Skip to main content

TT_KERNEL_PREAMBLE

Constant TT_KERNEL_PREAMBLE 

Source
pub const TT_KERNEL_PREAMBLE: &str = r#"// Auto-generated by LOGOS codegen_tt — do not edit.
// TT-Metalium compute kernel: runs a whole LOGOS program on ONE Tensix baby
// RISC-V core (DataMovementProcessor::RISCV_0). `Show` output is streamed to the
// host via the DPRINT server. The compute body below is the LOGOS→C lowering —
// byte-for-byte equal to the VM (locked by the host oracle in tenstorrent_aot_lock).
#include "dataflow_api.h"
#include "debug/dprint.h"

// --- Show bridge -------------------------------------------------------------
// The C backend prints with printf/puts; on-core we format into a small stack
// buffer and stream it through DPRINT so the host sees identical text.
#ifndef LOGOS_TT_SHOW_BRIDGE
#define LOGOS_TT_SHOW_BRIDGE
#define printf(...) do { char _logos_lb[256]; snprintf(_logos_lb, sizeof _logos_lb, __VA_ARGS__); DPRINT << _logos_lb; } while (0)
#define puts(_s)    do { DPRINT << (_s) << ENDL(); } while (0)
#endif
// --- LOGOS→C compute body ----------------------------------------------------
"#;
Expand description

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 (how Show is emitted) to the host DPRINT stream, so kernel output is textually identical to the VM’s.