Skip to content

Commit

Permalink
Add file changes from papi_cupti_common.
Browse files Browse the repository at this point in the history
  • Loading branch information
Treece Burgess committed Feb 14, 2025
1 parent cb47152 commit fe2a676
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/components/cuda/papi_cupti_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,6 @@ int cuptic_ctxarr_update_current(cuptic_info_t info, int evt_dev_id)
if (cuda_err != CUDA_SUCCESS) {
return PAPI_EMISC;
}

if (info[dev_id].ctx == NULL) {
// Store current user created CUDA context
cuda_err = cuCtxGetCurrentPtr(&info[dev_id].ctx);
Expand All @@ -639,11 +638,14 @@ int cuptic_ctxarr_update_current(cuptic_info_t info, int evt_dev_id)
// for them. Note, that for machine with multiple devices, we need to
// call cudaSetDevice.
else {
cudaArtCheckErrors(cudaSetDevicePtr(evt_dev_id), return PAPI_EMISC);
cudaArtCheckErrors(cudaFreePtr(NULL), return PAPI_EMISC);

cudaCheckErrors(cuCtxGetCurrentPtr(&info[evt_dev_id].ctx), return PAPI_EMISC);
cudaCheckErrors(cuCtxPopCurrentPtr(&pctx), PAPI_EMISC);
// Guard against a user PopCurrent
if (info[evt_dev_id].ctx == NULL) {
cudaArtCheckErrors(cudaSetDevicePtr(evt_dev_id), return PAPI_EMISC);
cudaArtCheckErrors(cudaFreePtr(NULL), return PAPI_EMISC);

cudaCheckErrors(cuCtxGetCurrentPtr(&info[evt_dev_id].ctx), return PAPI_EMISC);
cudaCheckErrors(cuCtxPopCurrentPtr(&pctx), PAPI_EMISC);
}
}

return PAPI_OK;
Expand Down

0 comments on commit fe2a676

Please sign in to comment.