rocr: Fix memory leak on non-visible GPUs

Fix memory leak for memory regions objects when GPU is masked using
ROCR_VISIBLE_DEVICES.

Change-Id: I610842a18adbc3cdc854b12650844e271bc00592
This commit is contained in:
David Yat Sin
2024-09-30 21:10:18 +00:00
parent 0ae064fe2d
commit dbae8da515
@@ -236,33 +236,33 @@ GpuAgent::GpuAgent(HSAuint32 node, const HsaNodeProperties& node_props, bool xna
}
GpuAgent::~GpuAgent() {
if (!(this)->Enabled()) return;
for (auto& blit : blits_) {
if (!blit.empty()) {
hsa_status_t status = blit->Destroy(*this);
assert(status == HSA_STATUS_SUCCESS);
if (this->Enabled()) {
for (auto& blit : blits_) {
if (!blit.empty()) {
hsa_status_t status = blit->Destroy(*this);
assert(status == HSA_STATUS_SUCCESS);
}
}
}
if (ape1_base_ != 0) {
_aligned_free(reinterpret_cast<void*>(ape1_base_));
}
if (ape1_base_ != 0) {
_aligned_free(reinterpret_cast<void*>(ape1_base_));
}
scratch_cache_.trim(true);
scratch_cache_.free_reserve();
scratch_cache_.trim(true);
scratch_cache_.free_reserve();
if (scratch_pool_.base() != NULL) {
hsaKmtFreeMemory(scratch_pool_.base(), scratch_pool_.size());
}
if (scratch_pool_.base() != NULL) {
hsaKmtFreeMemory(scratch_pool_.base(), scratch_pool_.size());
}
for (int i = 0; i < QueueCount; i++)
queues_[i].reset();
for (int i = 0; i < QueueCount; i++)
queues_[i].reset();
system_deallocator()(doorbell_queue_map_);
system_deallocator()(doorbell_queue_map_);
if (trap_code_buf_ != NULL) {
ReleaseShader(trap_code_buf_, trap_code_buf_size_);
if (trap_code_buf_ != NULL) {
ReleaseShader(trap_code_buf_, trap_code_buf_size_);
}
}
std::for_each(regions_.begin(), regions_.end(), DeleteObject());