Skip to content

Commit

Permalink
#15407: manually release blocks on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
marty1885 authored and abhullar-tt committed Nov 26, 2024
1 parent f3108ee commit bedf250
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tt_metal/impl/allocator/algorithms/free_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,21 @@ FreeList::FreeList(DeviceAddr max_size_bytes, DeviceAddr offset_bytes, DeviceAdd
this->init();
}

FreeList::~FreeList() {
this->clear();
}

void FreeList::init() {
boost::local_shared_ptr<FreeList::Block> curr_block = this->block_head_;
while (curr_block != nullptr) {
auto next_block = curr_block->next_block;
curr_block->prev_block = nullptr;
curr_block->next_block = nullptr;
curr_block->prev_free = nullptr;
curr_block->next_free = nullptr;
curr_block = next_block;
}

this->shrink_size_ = 0;
auto block = boost::make_local_shared<Block>(0, this->max_size_bytes_);
this->block_head_ = block;
Expand Down
1 change: 1 addition & 0 deletions tt_metal/impl/allocator/algorithms/free_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FreeList : public Algorithm {
};

FreeList(DeviceAddr max_size_bytes, DeviceAddr offset_bytes, DeviceAddr min_allocation_size, DeviceAddr alignment, SearchPolicy search_policy);
~FreeList();
void init();

std::vector<std::pair<DeviceAddr, DeviceAddr>> available_addresses(DeviceAddr size_bytes) const;
Expand Down

0 comments on commit bedf250

Please sign in to comment.