3 // SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC
5 // SPDX-License-Identifier: Apache-2.0
7 #ifndef TTMLIR_TARGET_TTKERNEL_LLKS_EXPERIMENTAL_TILIZE_LLKS_H
8 #define TTMLIR_TARGET_TTKERNEL_LLKS_EXPERIMENTAL_TILIZE_LLKS_H
10 namespace experimental {
14 ALWI void llk_unpack_tilize(uint32_t operand, uint32_t tile_index,
15 uint32_t block_ct_dim, uint32_t start_tile_index) {
16 const uint32_t operand_id = get_operand_id(operand);
17 const uint32_t page_bytes = get_local_cb_interface(operand_id).fifo_page_size;
18 const uint32_t face_r_dim = get_operand_face_r_dim(operand_id);
19 const uint32_t num_faces = get_operand_num_faces(operand_id);
20 const bool narrow_tile = get_operand_narrow_tile(operand_id);
22 const uint32_t base_address = get_local_cb_interface(operand_id).fifo_rd_ptr -
23 1; // Remove header size added by descriptor
26 _llk_unpack_tilize_(base_address + (start_tile_index * page_bytes),
27 tile_index, unpack_src_format[operand_id], block_ct_dim,
28 face_r_dim, num_faces, narrow_tile);
32 ALWI void llk_unpack_tilize_block(uint32_t operand, uint32_t block_c_tiles,
33 uint32_t start_tile_idx) {
34 for (uint32_t tile_index = 0; tile_index < block_c_tiles; tile_index++) {
35 llk_unpack_tilize(operand, tile_index, block_c_tiles, start_tile_idx);
38 #endif // TRISC_UNPACK
40 ALWI void tilize_block(uint32_t icb, uint32_t ocb, uint32_t block_r,
42 uint32_t start_tile_idx = 0;
43 for (uint32_t i = 0; i < block_r; i++) {
44 UNPACK((llk_unpack_tilize_block(icb, block_c, start_tile_idx)));
46 for (uint32_t t = 0; t < block_c; t++) {
48 MATH((llk_math_wait_for_dest_available()));
49 PACK((llk_packer_wait_for_math_done()));
52 MATH((llk_math_eltwise_unary_datacopy<A2D, BroadcastType::NONE,
53 DST_ACCUM_MODE, UnpackToDestEn>(
55 PACK((llk_pack<false, false>(0 /*tile index*/, ocb)));
58 MATH((llk_math_dest_section_done<DST_ACCUM_MODE>()));
59 PACK((llk_pack_dest_section_done<DST_ACCUM_MODE>()));
61 start_tile_idx += block_c;
64 } // namespace experimental
66 #endif // TTMLIR_TARGET_TTKERNEL_LLKS_EXPERIMENTAL_TILIZE_LLKS_H
static constexpr char experimental_tilize_llks_generated[]
Definition: experimental_tilize_llks_generated.h:2
static constexpr unsigned int experimental_tilize_llks_generated_len
Definition: experimental_tilize_llks_generated.h:68