Skip to content

Commit

Permalink
mpl/cuda: Only initialize hooks from free functions
Browse files Browse the repository at this point in the history
Instead of initializing all GPU infrastructure, just setup hooks. This
still avoids crashes and won't cause consume resources if the user is
simply allocating and freeing device memory not for use with MPI.
  • Loading branch information
raffenet committed Jan 16, 2024
1 parent 96894a6 commit f8c71c3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/mpl/src/gpu/mpl_gpu_cuda.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,9 +508,8 @@ __attribute__ ((visibility("default")))
CUresult CUDAAPI cuMemFree(CUdeviceptr dptr)
{
CUresult result;
if (!gpu_initialized) {
int ret = MPL_gpu_init(0);
assert(ret == 0);
if (!sys_cuMemFree) {
gpu_mem_hook_init();
}

gpu_free_hooks_cb((void *) dptr);
Expand All @@ -524,9 +523,8 @@ __attribute__ ((visibility("default")))
cudaError_t CUDARTAPI cudaFree(void *dptr)
{
cudaError_t result;
if (!gpu_initialized) {
int ret = MPL_gpu_init(0);
assert(ret == 0);
if (!sys_cudaFree) {
gpu_mem_hook_init();
}

gpu_free_hooks_cb(dptr);
Expand Down

0 comments on commit f8c71c3

Please sign in to comment.