Skip to content

Commit

Permalink
Merge pull request #572 from abouteiller/new/hip-peeraccess
Browse files Browse the repository at this point in the history
HAVE_PEER_ACCESS is always present in all relevant versions of CUDA or
  • Loading branch information
bosilca authored Sep 7, 2023
2 parents 0a971a9 + 43b830b commit c174b39
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
12 changes: 2 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -696,18 +696,10 @@ int main(int argc, char *argv[]) {
message(STATUS "Using PGI internal CUDA SDK in ${CUDAToolkit_ROOT}")
endif(_path_pgcuda)
endif (_match_pgi)
find_package(CUDAToolkit)
find_package(CUDAToolkit 4)
set(PARSEC_HAVE_CUDA ${CUDAToolkit_FOUND} CACHE BOOL "True if PaRSEC provide support for CUDA")
if (CUDAToolkit_FOUND)
message(STATUS "Found CUDA ${CUDAToolkit_VERSION} in ${CUDAToolkit_LIBRARY_DIR}")
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES CUDA::cudart)
if(CUDAToolkit_VERSION VERSION_LESS "4.0")
set(PARSEC_HAVE_PEER_DEVICE_MEMORY_ACCESS 0)
else()
check_function_exists(cudaDeviceCanAccessPeer PARSEC_HAVE_PEER_DEVICE_MEMORY_ACCESS)
endif()
cmake_pop_check_state()
get_target_property(extra_cuda_libs CUDA::cudart INTERFACE_LINK_LIBRARIES)
if(extra_cuda_libs)
list(APPEND EXTRA_LIBS ${extra_cuda_libs})
Expand All @@ -725,7 +717,7 @@ int main(int argc, char *argv[]) {
# This is kinda ugly but the PATH and HINTS don't get transmitted to sub-dependents
set(CMAKE_SYSTEM_PREFIX_PATH_save ${CMAKE_SYSTEM_PREFIX_PATH})
list(APPEND CMAKE_SYSTEM_PREFIX_PATH /opt/rocm)
find_package(HIP QUIET) #quiet because hip-config.cmake is not part of core-cmake and will spam a loud warning when hip/rocm is not installed
find_package(HIP 1.9 QUIET) #quiet because hip-config.cmake is not part of core-cmake and will spam a loud warning when hip/rocm is not installed
set(CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_SYSTEM_PREFIX_PATH_save})
if(HIP_FOUND AND PARSEC_HAVE_CUDA)
# the underlying reason is that the generated ptg code cannot include at the same time
Expand Down
1 change: 0 additions & 1 deletion parsec/include/parsec/parsec_options.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
#cmakedefine PARSEC_GPU_WITH_HIP
#cmakedefine PARSEC_GPU_HIP_ALLOC_PER_TILE
#cmakedefine PARSEC_GPU_WITH_OPENCL
#cmakedefine PARSEC_HAVE_PEER_DEVICE_MEMORY_ACCESS

/* debug */
#cmakedefine PARSEC_DEBUG
Expand Down
18 changes: 7 additions & 11 deletions parsec/mca/device/cuda/device_cuda_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ parsec_device_base_component_t parsec_device_cuda_component = {
/* Component name and version */
"cuda",
/* Component options */
#if defined(PARSEC_HAVE_PEER_DEVICE_MEMORY_ACCESS)
"+peer_access"
#endif
"",
PARSEC_VERSION_MAJOR,
PARSEC_VERSION_MINOR,
Expand All @@ -78,12 +76,12 @@ parsec_device_base_component_t parsec_device_cuda_component = {
},
NULL
};

mca_base_component_t * device_cuda_static_component(void)
{
return (mca_base_component_t *)&parsec_device_cuda_component;
}

static int device_cuda_component_query(mca_base_module_t **module, int *priority)
{
int i, j, rc;
Expand Down Expand Up @@ -117,7 +115,6 @@ static int device_cuda_component_query(mca_base_module_t **module, int *priority
parsec_device_cuda_component.modules[j] = NULL;
}

#if defined(PARSEC_HAVE_PEER_DEVICE_MEMORY_ACCESS)
parsec_device_cuda_module_t *source_gpu, *target_gpu;
cudaError_t cudastatus;

Expand All @@ -127,7 +124,7 @@ static int device_cuda_component_query(mca_base_module_t **module, int *priority

if( ! ( (1<<i) & cuda_nvlink_mask ) )
continue; /* The user disabled NVLINK for that GPU */

cudastatus = cudaSetDevice( source_gpu->cuda_index );
PARSEC_CUDA_CHECK_ERROR( "(parsec_device_cuda_component_query) cudaSetDevice ", cudastatus,
{continue;} );
Expand All @@ -148,15 +145,14 @@ static int device_cuda_component_query(mca_base_module_t **module, int *priority
}
}
}
#endif

parsec_gpu_enable_debug();

/* module type should be: const mca_base_module_t ** */
void *ptr = parsec_device_cuda_component.modules;
*priority = 10;
*module = (mca_base_module_t *)ptr;

return MCA_SUCCESS;
}

Expand Down Expand Up @@ -285,15 +281,15 @@ static int device_cuda_component_close(void)
rc = parsec_cuda_module_fini((parsec_device_module_t*)cdev);
if( PARSEC_SUCCESS != rc ) {
PARSEC_DEBUG_VERBOSE(0, parsec_gpu_output_stream,
"GPU[%d] Failed to release resources on CUDA device\n",
"GPU[%d] Failed to release resources on CUDA device\n",
cdev->cuda_index);
}

/* unregister the device from PaRSEC */
rc = parsec_mca_device_remove((parsec_device_module_t*)cdev);
if( PARSEC_SUCCESS != rc ) {
PARSEC_DEBUG_VERBOSE(0, parsec_gpu_output_stream,
"GPU[%d] Failed to unregister CUDA device %d\n",
"GPU[%d] Failed to unregister CUDA device %d\n",
cdev->cuda_index, cdev->cuda_index);
}

Expand All @@ -308,7 +304,7 @@ static int device_cuda_component_close(void)

PARSEC_DEBUG_VERBOSE(0, parsec_gpu_output_stream,
"GPU[%d] CUDA device still registered with PaRSEC at the end of CUDA finalize.\n"
" Please contact the developers or fill an issue.\n",
" Please contact the developers or fill an issue.\n",
cdev->cuda_index);
}
#endif /* defined(PARSEC_DEBUG_NOISIER) */
Expand Down

0 comments on commit c174b39

Please sign in to comment.