Use the context variant of getNullStream

Do not create a new queue to call finish in hipFree if none was
created earlier elsewhere.
Change-Id: I87bb191e6b186ddbe607ab29d11e3ae5bc2ac8e6
Этот коммит содержится в:
Saleel Kudchadker committed 2020-02-25 00:13:43 -08:00
1 родитель 2203093159
Коммит 631fd65be4
2 files changed
+6 -2

No files matched your search

+1
Просмотреть файл
@@ -103,6 +103,7 @@ amd::HostQueue* getNullStream(Device& dev) {
} }
return stream->second; return stream->second;
} }
amd::HostQueue* getNullStream(amd::Context& ctx) { amd::HostQueue* getNullStream(amd::Context& ctx) {
for (auto& it : g_nullStreams) { for (auto& it : g_nullStreams) {
if (it.first->asContext() == &ctx) { if (it.first->asContext() == &ctx) {
+5 -2
Просмотреть файл
@@ -224,8 +224,11 @@ hipError_t hipFree(void* ptr) {
} }
if (amd::SvmBuffer::malloced(ptr)) { if (amd::SvmBuffer::malloced(ptr)) {
hip::syncStreams(); hip::syncStreams();
for (size_t i=0; i<g_devices.size(); ++i) { for (auto& dev : g_devices) {
hip::getNullStream(*g_devices[i])->finish(); amd::HostQueue* queue = hip::getNullStream(*dev->asContext());
if (queue != nullptr) {
queue->finish();
}
} }
amd::SvmBuffer::free(*hip::getCurrentDevice()->asContext(), ptr); amd::SvmBuffer::free(*hip::getCurrentDevice()->asContext(), ptr);
HIP_RETURN(hipSuccess); HIP_RETURN(hipSuccess);