diff --git a/api/hip/hip_module.cpp b/api/hip/hip_module.cpp index f17d5ae719..97723d52dc 100644 --- a/api/hip/hip_module.cpp +++ b/api/hip/hip_module.cpp @@ -144,8 +144,14 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, amd::Kernel* kernel = as_amd(reinterpret_cast(f)); amd::Device* device = g_context->devices()[0]; - amd::HostQueue* queue = as_amd(reinterpret_cast(hStream))->asHostQueue(); - + amd::HostQueue* queue; + if (hStream == nullptr) { + queue = new amd::HostQueue(*g_context, *device, 0, + amd::CommandQueue::RealTimeDisabled, + amd::CommandQueue::Priority::Normal); + } else { + queue = as_amd(reinterpret_cast(hStream))->asHostQueue(); + } if (!queue) { return hipErrorOutOfMemory; } @@ -194,6 +200,10 @@ hipError_t hipModuleLaunchKernel(hipFunction_t f, command->awaitCompletion(); command->release(); + if (hStream == nullptr) { + queue->release(); + } + return hipSuccess; }