From b9b982247e4e6c2dab5f36115d2aa12dc0eb84b4 Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Wed, 8 Jul 2020 17:30:38 -0400 Subject: [PATCH] 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 --- rocclr/hip_context.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/rocclr/hip_context.cpp b/rocclr/hip_context.cpp index 7c42c65159..ef6a01928d 100755 --- a/rocclr/hip_context.cpp +++ b/rocclr/hip_context.cpp @@ -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;