Skip to content

Commit

Permalink
fixes for cudaDeviceSynchronize multithreaded
Browse files Browse the repository at this point in the history
  • Loading branch information
cwpearson committed Jul 12, 2023
1 parent 3116a95 commit 693026d
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/libcudart/cudaDeviceSynchronize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ auto Comm_cudaDeviceSynchronize = [](benchmark::State &state, const int gpu,
const int numaId) {
numa::ScopedBind binder(numaId);

if (0 == state.thread_index()) {
OR_SKIP_AND_RETURN(scope::cuda_reset_device(gpu),
"failed to reset CUDA device");
}

// need each thread to set the device, but there's no way to reset
// the device on a single thread first, because there's no thread barrier
OR_SKIP_AND_RETURN(cudaSetDevice(gpu), "");
OR_SKIP_AND_RETURN(cudaFree(0), "failed to init");
OR_SKIP_AND_RETURN(cudaDeviceSynchronize(), "failed to sync");

cudaError_t err = cudaSuccess;
for (auto _ : state) {
Expand Down

0 comments on commit 693026d

Please sign in to comment.