Download code/hamer/kernels/cmm/help_prefetch.cpp from changh95/hamer-p150: direct link, hf CLI and curl.
- Browser
- Download file 1.36 kB
-
https://huggingface.co/changh95/hamer-p150/resolve/main/code/hamer/kernels/cmm/help_prefetch.cpp
- Command line
-
hf download hf://changh95/hamer-p150/code/hamer/kernels/cmm/help_prefetch.cpp
-
curl -L -o help_prefetch.cpp https://huggingface.co/changh95/hamer-p150/resolve/main/code/hamer/kernels/cmm/help_prefetch.cpp
1.36 kB
| // SPDX-FileCopyrightText: © 2026 Tenstorrent Inc. | |
| // SPDX-License-Identifier: Apache-2.0 | |
| // Round 8: cross-op weight prefetch by the cores a cmm program leaves idle. Each helper copies its chunks of a LATER | |
| // cmm's packed weight blocks from DRAM into the persistent L1 prefetch buffer of their owner (a top-row sender, | |
| // tt_kernels.CmmPrefetch): DRAM -> local scratch CB 22 -> remote L1. No semaphores: the consumer is a later program. | |
| // runtime: w_addr, n, then n x (bank, bank offset, dst x, dst y, dst addr, bytes) (fixed length). | |
| void kernel_main() { | |
| const uint32_t w_addr = get_arg_val<uint32_t>(0); | |
| const uint32_t n = get_arg_val<uint32_t>(1); | |
| const uint32_t buf = get_write_ptr(22); | |
| for (uint32_t i = 0; i < n; ++i) { | |
| const uint32_t a = 2 + 6 * i; | |
| const uint32_t bank = get_arg_val<uint32_t>(a), off = get_arg_val<uint32_t>(a + 1); | |
| const uint32_t dx = get_arg_val<uint32_t>(a + 2), dy = get_arg_val<uint32_t>(a + 3); | |
| const uint32_t dst = get_arg_val<uint32_t>(a + 4), bytes = get_arg_val<uint32_t>(a + 5); | |
| noc_async_read(get_noc_addr_from_bank_id<true>(bank, w_addr + off), buf, bytes); | |
| noc_async_read_barrier(); | |
| noc_async_write(buf, get_noc_addr(dx, dy, dst), bytes); | |
| noc_async_write_barrier(); | |
| } | |
| } | |