diff --git a/vdi/hip_context.cpp b/vdi/hip_context.cpp index ebc6f88ee3..f28ca48239 100644 --- a/vdi/hip_context.cpp +++ b/vdi/hip_context.cpp @@ -103,6 +103,7 @@ amd::HostQueue* getNullStream(Device& dev) { } return stream->second; } + amd::HostQueue* getNullStream(amd::Context& ctx) { for (auto& it : g_nullStreams) { if (it.first->asContext() == &ctx) { diff --git a/vdi/hip_memory.cpp b/vdi/hip_memory.cpp index 58c27cb89d..77d48a4368 100644 --- a/vdi/hip_memory.cpp +++ b/vdi/hip_memory.cpp @@ -224,8 +224,11 @@ hipError_t hipFree(void* ptr) { } if (amd::SvmBuffer::malloced(ptr)) { hip::syncStreams(); - for (size_t i=0; ifinish(); + for (auto& dev : g_devices) { + amd::HostQueue* queue = hip::getNullStream(*dev->asContext()); + if (queue != nullptr) { + queue->finish(); + } } amd::SvmBuffer::free(*hip::getCurrentDevice()->asContext(), ptr); HIP_RETURN(hipSuccess);