Skip to content

Commit

Permalink
#0: Scheduling fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sminakov-tt committed Oct 29, 2024
1 parent b85798a commit ed11135
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tt_metal/impl/buffers/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ std::shared_ptr<Buffer> Buffer::create(
}

buffer->device_->push_work([buffer] {
AllocationStatus next_status = AllocationStatus::ALLOCATED;
try {
buffer->address_ = detail::AllocateBuffer(buffer.get());
} catch(...) {
Expand Down Expand Up @@ -299,8 +298,7 @@ void Buffer::deleter(Buffer* buffer) {
}

void Buffer::deallocate_impl() {
auto status = allocation_status_.load(std::memory_order::relaxed);
if (status == AllocationStatus::DEALLOCATED || status == AllocationStatus::ALLOCATION_FAILED) {
if (allocation_status_.load(std::memory_order::relaxed) != AllocationStatus::ALLOCATED) {
return;
}

Expand Down Expand Up @@ -330,6 +328,10 @@ uint32_t Buffer::address() const {
return address_;
}

if (device_->can_use_passthrough_scheduling()) {
return address_;
}

std::unique_lock lock(allocation_mutex_);
allocation_cv_.wait(lock, [this] { return this->allocation_status_.load(std::memory_order::relaxed) != AllocationStatus::ALLOCATION_REQUESTED; });
return address_;
Expand Down

0 comments on commit ed11135

Please sign in to comment.