Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13609: Uplift dram and l1 allocators to use dram/l1 specific alignment #13762

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

abhullar-tt
Copy link
Contributor

@abhullar-tt abhullar-tt commented Oct 11, 2024

Ticket

#13609

Problem description

Using the max of DRAM and L1 alignment for both DRAM and L1 buffers was causing pcc mismatches in i2s and s2i.

What's changed

Use L1/DRAM specific alignment for respective allocations. This will require some ops to be uplifted to handle re-alignment
@yugaoTT and @ntarafdar to add corresponding op changes

Checklist

Below post commits were triggered 12/03

@abhullar-tt abhullar-tt linked an issue Oct 11, 2024 that may be closed by this pull request
@tt-aho tt-aho self-requested a review December 19, 2024 21:54
@tt-rkim tt-rkim dismissed tt-aho’s stale review December 19, 2024 22:14

Because he asked me to

@@ -1653,7 +1653,7 @@ operation::ProgramWithCallbacks pad_rm_sharded_width_only(

// FIXME: assumes that this was sharded using DRAM alignment so that gaps are left in the tensor.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this comment be udpated as well?

@@ -63,7 +63,7 @@ uint32_t shard_size = shard_height * shard_width;
uint32_t input_unit_size = sizeof(uint32_t);
uint32_t shard_width_bytes = shard_width * data_size;
uint32_t num_units_per_row = shard_width * input_unit_size;
uint32_t padded_offset_bytes = align(input_unit_size, device->get_allocator_alignment());
uint32_t padded_offset_bytes = align(input_unit_size, device->get_allocator_alignment(BufferType::L1));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to add more info about when you need or when the infra uses different alignments and why.

@@ -676,7 +676,7 @@ operation::ProgramWithCallbacks transpose_hc_multi_core(
// TODO: noc_async_write only require 16B alignment for both DRAM and L1 for Blackhole, so instead of reading in
// face-lines from C tiles to form a single tile, we can load a single tile and then write out its face-lines to C
// tiles
uint32_t alignment = dst_buffer->buffer_type() == tt::tt_metal::BufferType::DRAM ? DRAM_ALIGNMENT : L1_ALIGNMENT;
uint32_t alignment = device->get_allocator_alignment(dst_buffer->buffer_type());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use dst_buffer->alignment() instead

@@ -1653,7 +1653,7 @@ operation::ProgramWithCallbacks pad_rm_sharded_width_only(

// FIXME: assumes that this was sharded using DRAM alignment so that gaps are left in the tensor.
// if this changes, we should change the stick step to be 16B (L1 alignment).
auto dram_alignment_bytes = tt::tt_metal::hal.get_alignment(tt::tt_metal::HalMemType::DRAM);
auto dram_alignment_bytes = tt::tt_metal::hal.get_alignment(tt::tt_metal::HalMemType::L1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be renamed to l1_alignment_bytes?

tt_metal/impl/device/device.hpp Outdated Show resolved Hide resolved
tt_metal/impl/device/device.cpp Outdated Show resolved Hide resolved
@@ -921,9 +941,10 @@ struct InterleavedPow2AddrGen {
const uint32_t bank_base_address;
const uint32_t log_base_2_of_page_size; // WARNING: This struct is used for optimized get_noc_addr in which case
// you know that bank_unit_size is a power of 2
const uint32_t aligned_log_base_2_of_page_size = this->log_base_2_of_page_size > LOG_BASE_2_OF_ALLOCATOR_ALIGNMENT
const uint32_t log_base_2_of_allocator_alignment = interleaved_addr_gen::get_log_base2_of_allocator_alignment<DRAM>();

This comment was marked as resolved.

@@ -1019,9 +1040,10 @@ template <bool DRAM>
struct InterleavedPow2AddrGenFast {
uint32_t bank_base_address; // Base address for the whole tensor.
const uint32_t log_base_2_of_page_size; // Num bytes in bank unit.
const uint32_t aligned_log_base_2_of_page_size = this->log_base_2_of_page_size > LOG_BASE_2_OF_ALLOCATOR_ALIGNMENT
const uint32_t log_base_2_of_allocator_alignment = interleaved_addr_gen::get_log_base2_of_allocator_alignment<DRAM>();

This comment was marked as resolved.

@llongTT llongTT requested a review from nardoTT as a code owner December 20, 2024 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allocator uses 32B alignment for both DRAM and L1
6 participants