Skip to content

Commit

Permalink
Cal setdevice when creating events on-demand
Browse files Browse the repository at this point in the history
  • Loading branch information
G-071 committed Jun 29, 2023
1 parent 3999ecc commit 46b477a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions libs/core/async_cuda/include/hpx/async_cuda/cuda_event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ namespace hpx { namespace cuda { namespace experimental {
// pop an event off the pool, if that fails, create a new one
while (!free_lists_[device].pop(event))
{
// Set correct device in case if required
int original_device = -1;
check_cuda_error(cudaGetDevice(&original_device));
if (original_device != device)
check_cuda_error(cudaSetDevice(device));
add_event_to_pool(device);
// reset to original device if required
if (original_device != device)
check_cuda_error(cudaSetDevice(original_device));
}
return true;
}
Expand Down

0 comments on commit 46b477a

Please sign in to comment.