File size: 961 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
// SPDX-FileCopyrightText: © 2026 Tenstorrent Inc.
// SPDX-License-Identifier: Apache-2.0
// Unary eltwise writer: cb 16 -> destination pages [start, start+n), one tile at a time.
// compile-time: TensorAccessorArgs(dst).  runtime: dst_addr, start, n
#include <stdint.h>
#include "api/dataflow/dataflow_api.h"

void kernel_main() {
    const uint32_t dst_addr = get_arg_val<uint32_t>(0);
    const uint32_t start = get_arg_val<uint32_t>(1);
    const uint32_t n = get_arg_val<uint32_t>(2);
    constexpr auto dst_args = TensorAccessorArgs<0>();
    constexpr uint32_t cb = 16;
    const uint32_t page = get_local_cb_interface(cb).fifo_page_size;
    const auto dst = TensorAccessor(dst_args, dst_addr, page);
    for (uint32_t i = 0; i < n; ++i) {
        cb_wait_front(cb, 1);
        noc_async_write(get_read_ptr(cb), dst.get_noc_addr(start + i), page);
        noc_async_writes_flushed();
        cb_pop_front(cb, 1);
    }
    noc_async_write_barrier();
}