Skip to content

Commit

Permalink
fix hip kernel and device sync multithreaded benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
cwpearson committed Jul 12, 2023
1 parent ef1b7f7 commit b87d652
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions src/hip/hipDeviceSynchronize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,16 @@ auto Comm_hipDeviceSynchronize = [](benchmark::State &state, const int gpu,
const int numaId) {
numa::ScopedBind binder(numaId);

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

OR_SKIP_AND_RETURN(hipSetDevice(gpu), "");
OR_SKIP_AND_RETURN(hipFree(0), "failed to init");
OR_SKIP_AND_RETURN(hipDeviceSynchronize(), "failed to init sync");

hipError_t err = hipSuccess;
for (auto _ : state) {
err = hipDeviceSynchronize();
}

OR_SKIP_AND_RETURN(err, "failed to lsync");
OR_SKIP_AND_RETURN(err, "failed to sync");

state.SetItemsProcessed(state.iterations());
state.counters["gpu"] = gpu;
Expand Down
8 changes: 2 additions & 6 deletions src/hip/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@ auto Comm_hip_kernel = [](benchmark::State &state, const int gpu,
const int numaId) {
numa::ScopedBind binder(numaId);

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

OR_SKIP_AND_RETURN(hipSetDevice(gpu), "");
OR_SKIP_AND_RETURN(hipFree(0), "failed to init");
OR_SKIP_AND_RETURN(hipDeviceSynchronize(), "failed to init sync");

const size_t nArgs = state.range(0);

Expand Down Expand Up @@ -59,10 +55,10 @@ auto Comm_hip_kernel = [](benchmark::State &state, const int gpu,
}
#undef LAUNCH
OR_SKIP_AND_RETURN(hipGetLastError(), "failed to launch kernel");
OR_SKIP_AND_RETURN(hipDeviceSynchronize(), "failed to synchronize");

state.SetItemsProcessed(state.iterations());
state.counters["gpu"] = gpu;
OR_SKIP_AND_RETURN(hipDeviceSynchronize(), "failed to synchronize");
};

static void registerer() {
Expand Down

0 comments on commit b87d652

Please sign in to comment.