File size: 1,359 Bytes
58ba6df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// SPDX-FileCopyrightText: © 2026 Tenstorrent Inc.
// SPDX-License-Identifier: Apache-2.0
// Round 8: cross-op weight prefetch by the cores a cmm program leaves idle.  Each helper copies its chunks of a LATER
// cmm's packed weight blocks from DRAM into the persistent L1 prefetch buffer of their owner (a top-row sender,
// tt_kernels.CmmPrefetch): DRAM -> local scratch CB 22 -> remote L1.  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)  (fixed length).
#include <stdint.h>
#include "api/dataflow/dataflow_api.h"

void kernel_main() {
    const uint32_t w_addr = get_arg_val<uint32_t>(0);
    const uint32_t n = get_arg_val<uint32_t>(1);
    const uint32_t buf = get_write_ptr(22);
    for (uint32_t i = 0; i < n; ++i) {
        const uint32_t a = 2 + 6 * i;
        const uint32_t bank = get_arg_val<uint32_t>(a), off = get_arg_val<uint32_t>(a + 1);
        const uint32_t dx = get_arg_val<uint32_t>(a + 2), dy = get_arg_val<uint32_t>(a + 3);
        const uint32_t dst = get_arg_val<uint32_t>(a + 4), bytes = get_arg_val<uint32_t>(a + 5);
        noc_async_read(get_noc_addr_from_bank_id<true>(bank, w_addr + off), buf, bytes);
        noc_async_read_barrier();
        noc_async_write(buf, get_noc_addr(dx, dy, dst), bytes);
        noc_async_write_barrier();
    }
}