Host device context should return a valid queue

Host memory allocations use shared device context, which allows
to have access from any device. That breaks default queue detection.

Change-Id: I27ad1234d49ab0ea8f5edd6f2e3ffa93c47d4b1f
This commit is contained in:
German Andryeyev
2020-07-08 17:30:38 -04:00
parent 77ae61cff7
commit b9b982247e
+14 -6
Vedi File
@@ -92,15 +92,23 @@ amd::HostQueue* getQueue(hipStream_t stream) {
}
}
// ================================================================================================
amd::HostQueue* getNullStream(amd::Context& ctx) {
for (auto& it : g_devices) {
if (it->asContext() == &ctx) {
return it->NullStream();
}
}
return nullptr;
for (auto& it : g_devices) {
if (it->asContext() == &ctx) {
return it->NullStream();
}
}
// If it's a pure SVM allocation with system memory access, then it shouldn't matter which device
// runtime selects by default
if (hip::host_device->asContext() == &ctx) {
// Return current...
return getNullStream();
}
return nullptr;
}
// ================================================================================================
amd::HostQueue* getNullStream() {
Device* device = getCurrentDevice();
return device ? device->NullStream() : nullptr;