// SPDX-FileCopyrightText: © 2026 Tenstorrent Inc. // SPDX-License-Identifier: Apache-2.0 // Round 11: cores a cmm program leaves idle copy the first K blocks of a LATER xmm's packed weight from DRAM into the // persistent L1 prefetch buffers of that xmm's weight senders (tt_kernels.XmmPrefetch): their own buffer directly, other // cores' through a local scratch CB 22 (DRAM -> scratch -> NoC write, two scratch halves so a write overlaps the next // read). No semaphores: the consumer is a later program. // runtime: w_addr, n, then n x (bank, bank offset, dst x, dst y, dst addr, bytes, local) (fixed length). #include #include "api/dataflow/dataflow_api.h" void kernel_main() { const uint32_t w_addr = get_arg_val(0); const uint32_t n = get_arg_val(1); if (n == 0) { return; } const uint32_t scr = get_write_ptr(22); const uint32_t half = get_local_cb_interface(22).fifo_size / 2; // local entries first: plain reads into this core's own buffer for (uint32_t i = 0; i < n; ++i) { const uint32_t a = 2 + 7 * i; if (get_arg_val(a + 6)) { noc_async_read(get_noc_addr_from_bank_id(get_arg_val(a), w_addr + get_arg_val(a + 1)), get_arg_val(a + 4), get_arg_val(a + 5)); } } uint32_t k = 0; for (uint32_t i = 0; i < n; ++i) { const uint32_t a = 2 + 7 * i; if (get_arg_val(a + 6)) { continue; } const uint32_t buf = scr + (k & 1) * half; const uint32_t bytes = get_arg_val(a + 5); // this half was last the source of the write two remote entries ago: every issued write has left L1 (flushed) noc_async_writes_flushed(); noc_async_read(get_noc_addr_from_bank_id(get_arg_val(a), w_addr + get_arg_val(a + 1)), buf, bytes); noc_async_read_barrier(); noc_async_write(buf, get_noc_addr(get_arg_val(a + 2), get_arg_val(a + 3), get_arg_val(a + 4)), bytes); ++k; } noc_async_read_barrier(); noc_async_write_barrier(); }