Skip to content

Commit

Permalink
Use hipGetDevice and hipSetDevice to ensure RTC threads are on the co…
Browse files Browse the repository at this point in the history
…rrect device.
  • Loading branch information
malcolmroberts authored Nov 21, 2022
1 parent 979a451 commit 6005bfa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions library/src/rtc_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ std::shared_future<std::unique_ptr<RTCKernel>> 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);
Expand All @@ -122,6 +129,10 @@ std::shared_future<std::unique_ptr<RTCKernel>> 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<char> code = cached_compile(
Expand Down

0 comments on commit 6005bfa

Please sign in to comment.