Skip to content

Commit

Permalink
#0: move packing into loading
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-TT committed Dec 11, 2024
1 parent 95c9404 commit c8d2b0f
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tt_metal/llrt/tt_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,30 @@ memory::memory(std::string const& path, Packing pack_type, Relocate relo_type) {
text_addr_ = segments[0].address;
set_text_size(segments[0].contents.size() * sizeof(word_t));
set_packed_size(data_.size() * sizeof(uint32_t));

TT_ASSERT(this->link_spans_.size() != 0);
TT_ASSERT(link_spans_.size() <= 2);

std::vector<word_t> new_data2;

bool text_is_second = link_spans_.size() == 2 && link_spans_[1].addr == text_addr_;
auto const& text = link_spans_[text_is_second];

span new_span2 = text;

uint32_t offset = text_is_second ? link_spans_[0].len : 0;
new_data2.insert(new_data2.end(), &data_[offset], &data_[offset] + text.len);

if (link_spans_.size() == 2) {
offset = text_is_second ? 0 : text.len;
auto const& data = link_spans_[!text_is_second];
new_span2.len += data.len;
new_data2.insert(new_data2.end(), &data_[offset], &data_[offset] + data.len);
}

this->link_spans_.resize(1);
this->link_spans_[0] = new_span2;
this->data_ = new_data2;
}

bool memory::operator==(const memory& other) const { return data_ == other.data_ && link_spans_ == other.link_spans_; }
Expand Down Expand Up @@ -94,6 +118,7 @@ void memory::process_spans(
// Spans get packed for kernels so they can be loaded in one NOC transaction
// A symbol at the end of the text segment allows the FW to find the data segment to copy into place
void memory::pack_data_into_text(std::uint64_t, std::uint64_t) {
#if 0
TT_ASSERT(this->link_spans_.size() != 0);
TT_ASSERT(link_spans_.size() <= 2);

Expand All @@ -117,6 +142,7 @@ void memory::pack_data_into_text(std::uint64_t, std::uint64_t) {
this->link_spans_.resize(1);
this->link_spans_[0] = new_span2;
this->data_ = new_data2;
#endif
}

} // namespace ll_api

0 comments on commit c8d2b0f

Please sign in to comment.