From 4c4a7cb6969accaa46e7cb3f080cb22911fa89fa Mon Sep 17 00:00:00 2001 From: Edgar Date: Wed, 27 Apr 2022 12:18:29 -0400 Subject: [PATCH] fix cmake logic to handle old and new include dirs Starting from rocm 5.2 there is a reorganization of the include directories. This pr allows to compile rccl on both the old and the new directory layout. This solution is using find_package() for identifying correct settings for rocm_smi starting from rocm-5.2, and the original (manual) settings for all previous releases. Tested with rocm-5.2, 5.1.1, 5.0.2, and 4.5.2. --- CMakeLists.txt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89bd866ad5..839d041da6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,7 +222,18 @@ if(COLLTRACE) add_definitions(-DENABLE_COLLTRACE) endif() -CHECK_INCLUDE_FILE_CXX("${ROCM_PATH}/rocm_smi/include/rocm_smi/rocm_smi64Config.h" HAVE_ROCM_SMI64CONFIG) + +find_package(rocm_smi PATHS ${ROCM_PATH}/lib/cmake/rocm_smi) +if (rocm_smi_FOUND) + message ("-- Found rocm_smi at ${ROCM_SMI_INCLUDE_DIR}") + CHECK_INCLUDE_FILE_CXX("${ROCM_SMI_INCLUDE_DIR}/rocm_smi/rocm_smi64Config.h" HAVE_ROCM_SMI64CONFIG) +else() + message ("-- Checking old include directory structure for rocm_smi") + set(ROCM_SMI_INCLUDE_DIR "${ROCM_PATH}/rocm_smi/include") + set(ROCM_SMI_LIB_DIR "${ROCM_PATH}/rocm_smi/lib") + set(ROCM_SMI_LIBRARIES rocm_smi64) + CHECK_INCLUDE_FILE_CXX("${ROCM_SMI_INCLUDE_DIR}/rocm_smi/rocm_smi64Config.h" HAVE_ROCM_SMI64CONFIG) +endif() IF(HAVE_ROCM_SMI64CONFIG) add_definitions(-DUSE_ROCM_SMI64CONFIG) ENDIF() @@ -265,8 +276,8 @@ if("${HIP_COMPILER}" MATCHES "hcc") endif() endif() -target_include_directories(rccl PRIVATE ${ROCM_PATH}/rocm_smi/include) -target_link_libraries(rccl PRIVATE hip::device dl -lrocm_smi64 -L${ROCM_PATH}/rocm_smi/lib) +target_include_directories(rccl PRIVATE ${ROCM_SMI_INCLUDE_DIR}) +target_link_libraries(rccl PRIVATE hip::device dl -l${ROCM_SMI_LIBRARIES} -L${ROCM_SMI_LIB_DIR}) target_link_libraries(rccl INTERFACE hip::host) #Setup librccl.so version