File size: 1,311 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
26
27
28
29
30
// 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();
}