Only request residency once (#2051)

This commit is contained in:
Awni Hannun
2025-04-07 10:47:51 -07:00
committed by GitHub
parent f2c85308c1
commit 60c4154346

View File

@@ -22,6 +22,7 @@ ResidencySet::ResidencySet(MTL::Device* d) {
} }
throw std::runtime_error(msg.str()); throw std::runtime_error(msg.str());
} }
wired_set_->requestResidency();
} }
} }
@@ -32,7 +33,6 @@ void ResidencySet::insert(MTL::Allocation* buf) {
if (wired_set_->allocatedSize() + buf->allocatedSize() <= capacity_) { if (wired_set_->allocatedSize() + buf->allocatedSize() <= capacity_) {
wired_set_->addAllocation(buf); wired_set_->addAllocation(buf);
wired_set_->commit(); wired_set_->commit();
wired_set_->requestResidency();
} else { } else {
unwired_set_.insert(buf); unwired_set_.insert(buf);
} }
@@ -76,7 +76,6 @@ void ResidencySet::resize(size_t size) {
} }
} }
wired_set_->commit(); wired_set_->commit();
wired_set_->requestResidency();
} else if (current_size > size) { } else if (current_size > size) {
auto pool = new_scoped_memory_pool(); auto pool = new_scoped_memory_pool();
// Remove wired allocations until under capacity // Remove wired allocations until under capacity