Skip to content

Commit

Permalink
Set GPU context before {cu,hip}MemHostRegister.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D95856
  • Loading branch information
chsigg committed Feb 3, 2021
1 parent 39fbb5c commit 8a43ec7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions mlir/tools/mlir-cuda-runner/cuda-runtime-wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ extern "C" void mgpuMemcpy(void *dst, void *src, uint64_t sizeBytes,
// Allows to register byte array with the CUDA runtime. Helpful until we have
// transfer functions implemented.
extern "C" void mgpuMemHostRegister(void *ptr, uint64_t sizeBytes) {
ScopedContext scopedContext;
CUDA_REPORT_IF_ERROR(cuMemHostRegister(ptr, sizeBytes, /*flags=*/0));
}

Expand Down
1 change: 1 addition & 0 deletions mlir/tools/mlir-rocm-runner/rocm-runtime-wrappers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ extern "C" void mgpuMemcpy(void *dst, void *src, uint64_t sizeBytes,
// Allows to register byte array with the ROCM runtime. Helpful until we have
// transfer functions implemented.
extern "C" void mgpuMemHostRegister(void *ptr, uint64_t sizeBytes) {
ScopedContext scopedContext;
HIP_REPORT_IF_ERROR(hipHostRegister(ptr, sizeBytes, /*flags=*/0));
}

Expand Down

0 comments on commit 8a43ec7

Please sign in to comment.