superpoint-p150 / code /kernels /sp_desc /sm_writer.cpp
changh95's picture
Optimized build (2026-10-03): trace 3.73 -> 0.50 ms
c699c4c verified
Raw History Blame Contribute Delete
1.06 kB
// SPDX-FileCopyrightText: © 2026 Tenstorrent USA, Inc.
// SPDX-License-Identifier: Apache-2.0
//
// Score softmax core (SP_HEAD_SM=1), PROC 1: write each softmax tile row (3 tiles) to the s_sm tensor
// (TILE [N, 65], pages = tiles, row-major tile order). RT args: dst_addr, nrows, first tile row.
#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 nrows = get_arg_val<uint32_t>(1);
const uint32_t row0 = get_arg_val<uint32_t>(2);
constexpr uint32_t cb_out = get_compile_time_arg_val(0);
constexpr auto o_args = TensorAccessorArgs<1>();
const auto oacc = TensorAccessor(o_args, dst_addr, 2048);
for (uint32_t i = 0; i < nrows; ++i) {
cb_wait_front(cb_out, 3);
const uint32_t l1 = get_read_ptr(cb_out);
for (uint32_t j = 0; j < 3; ++j) {
noc_async_write(l1 + j * 2048, oacc.get_noc_addr((row0 + i) * 3 + j), 2048);
}
noc_async_write_barrier();
cb_pop_front(cb_out, 3);
}
}