changh95's picture
Optimized build (2026-10-03): model call 3.49 ms, device 3.36 ms
58ba6df verified
Raw History Blame Contribute Delete
1.31 kB
// SPDX-FileCopyrightText: © 2026 Tenstorrent Inc.
// SPDX-License-Identifier: Apache-2.0
// multicast bandwidth micro-benchmark: senders mcast `size` bytes `reps` times into a rectangle
// (no flags; data lands in a scratch CB at the same address on every core).
// runtime: active, sx, sy, ex, ey (min/max corner), ndest, size, reps, loopback
#include <stdint.h>
#include "api/dataflow/dataflow_api.h"
void kernel_main() {
if (!get_arg_val<uint32_t>(0)) {
return;
}
const uint32_t sx = get_arg_val<uint32_t>(1), sy = get_arg_val<uint32_t>(2);
const uint32_t ex = get_arg_val<uint32_t>(3), ey = get_arg_val<uint32_t>(4);
const uint32_t nd = get_arg_val<uint32_t>(5), size = get_arg_val<uint32_t>(6), reps = get_arg_val<uint32_t>(7);
const uint32_t lb = get_arg_val<uint32_t>(8);
const uint32_t buf = get_write_ptr(0);
const uint64_t dst = noc_index == 1 ? get_noc_multicast_addr(ex, ey, sx, sy, buf) : get_noc_multicast_addr(sx, sy, ex, ey, buf);
for (uint32_t r = 0; r < reps; ++r) {
if (lb) {
noc_async_write_multicast_loopback_src(buf, dst, size, nd);
} else {
noc_async_write_multicast(buf, dst, size, nd);
}
#ifdef MC_BARRIER_EACH
noc_async_write_barrier();
#endif
}
noc_async_write_barrier();
}