hamer-p150 / code /hamer /kernels /eltwise /writer.cpp
changh95's picture
Optimized build (2026-10-03): model call 3.49 ms, device 3.36 ms
58ba6df verified
Raw History Blame Contribute Delete
961 Bytes
// 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();
}