From 6005bfac9e14c07a602afc2eb967ca97a8b04af5 Mon Sep 17 00:00:00 2001 From: Malcolm Roberts Date: Mon, 21 Nov 2022 15:51:13 -0700 Subject: [PATCH] Use hipGetDevice and hipSetDevice to ensure RTC threads are on the correct device. --- library/src/rtc_kernel.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/library/src/rtc_kernel.cpp b/library/src/rtc_kernel.cpp index 05388f13..21b050e3 100644 --- a/library/src/rtc_kernel.cpp +++ b/library/src/rtc_kernel.cpp @@ -114,6 +114,13 @@ std::shared_future> RTCKernel::runtime_compile( { #ifdef ROCFFT_RUNTIME_COMPILE + + int deviceId = 0; + if(hipGetDevice(&deviceId) != hipSuccess) + { + throw std::runtime_error("failed to get device"); + } + RTCGenerator generator; // try each type of generator until one is valid generator = RTCKernelStockham::generate_from_node(node, gpu_arch, enable_callbacks); @@ -122,6 +129,10 @@ std::shared_future> RTCKernel::runtime_compile( std::string kernel_name = generator.generate_name(); auto compile = [=]() { + if(hipSetDevice(deviceId) != hipSuccess) + { + throw std::runtime_error("failed to set device"); + } try { std::vector code = cached_compile(