2020-01-15 17:54:27 -07:00
|
|
|
# Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved.
|
2019-07-05 15:43:00 -07:00
|
|
|
|
2020-08-06 11:19:43 -06:00
|
|
|
cmake_minimum_required(VERSION 3.5)
|
2019-07-05 15:43:00 -07:00
|
|
|
|
2019-11-15 10:39:48 -08:00
|
|
|
# We use C++14 features, this will add compile option: -std=c++14
|
|
|
|
|
set( CMAKE_CXX_STANDARD 14 )
|
|
|
|
|
# Without this line, it will add -std=gnu++14 instead, which has some issues.
|
|
|
|
|
set( CMAKE_CXX_EXTENSIONS OFF )
|
|
|
|
|
|
2019-07-05 15:43:00 -07:00
|
|
|
set(CMAKE_INSTALL_PREFIX "/opt/rocm" CACHE PATH "")
|
|
|
|
|
|
|
|
|
|
project(rccl CXX)
|
|
|
|
|
|
2021-04-14 08:29:00 -07:00
|
|
|
include(cmake/Dependencies.cmake)
|
|
|
|
|
|
2020-12-04 13:55:56 -08:00
|
|
|
# Detect compiler support for target ID
|
2021-04-14 08:29:00 -07:00
|
|
|
# This section is deprecated. Please use rocm_check_target_ids for future use.
|
2020-12-04 13:55:56 -08:00
|
|
|
if( CMAKE_CXX_COMPILER MATCHES ".*/hipcc$" )
|
2021-04-14 08:29:00 -07:00
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} "--help"
|
|
|
|
|
OUTPUT_VARIABLE CXX_OUTPUT
|
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
|
ERROR_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
string(REGEX MATCH ".mcode\-object\-version" TARGET_ID_SUPPORT ${CXX_OUTPUT})
|
2020-12-04 13:55:56 -08:00
|
|
|
endif()
|
|
|
|
|
|
2021-04-14 08:29:00 -07:00
|
|
|
#Set the AMDGPU_TARGETS with backward compatiblity
|
|
|
|
|
if(COMMAND rocm_check_target_ids)
|
|
|
|
|
rocm_check_target_ids(DEFAULT_AMDGPU_TARGETS
|
|
|
|
|
TARGETS "gfx803;gfx900:xnack-;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack-;gfx90a:xnack+;gfx1030"
|
|
|
|
|
)
|
2020-12-04 13:55:56 -08:00
|
|
|
else()
|
2021-04-14 08:29:00 -07:00
|
|
|
# Use target ID syntax if supported for AMDGPU_TARGETS
|
|
|
|
|
if(TARGET_ID_SUPPORT)
|
|
|
|
|
set(DEFAULT_AMDGPU_TARGETS "gfx803;gfx900:xnack-;gfx906:xnack-;gfx908:xnack-;gfx1030")
|
|
|
|
|
else()
|
|
|
|
|
set(DEFAULT_AMDGPU_TARGETS "gfx803;gfx900;gfx906;gfx908")
|
|
|
|
|
endif()
|
2020-12-04 13:55:56 -08:00
|
|
|
endif()
|
2021-04-14 08:29:00 -07:00
|
|
|
set(AMDGPU_TARGETS "${DEFAULT_AMDGPU_TARGETS}" CACHE STRING "List of specific machine types for library to target")
|
2019-10-22 17:10:07 -04:00
|
|
|
|
2019-07-05 15:43:00 -07:00
|
|
|
option(BUILD_TESTS "Build test programs" OFF)
|
2020-09-10 17:27:22 -06:00
|
|
|
option(INSTALL_DEPENDENCIES "Force install dependencies" OFF)
|
2019-07-05 15:43:00 -07:00
|
|
|
|
|
|
|
|
# parse version from Makefile NCCL_MAJOR, NCCL_MINOR, NCCL_PATCH must exist
|
|
|
|
|
# NCCL_SUFFIX is optional NCCL_VERSION formatting is ((X) * 1000 + (Y) * 100 +
|
|
|
|
|
# (Z)) so we must first detect one or two digits first
|
|
|
|
|
file(READ makefiles/version.mk version_mk_text)
|
|
|
|
|
if("${version_mk_text}" MATCHES "NCCL_MAJOR *:= *([0-9]*)")
|
|
|
|
|
set(NCCL_MAJOR ${CMAKE_MATCH_1})
|
|
|
|
|
else()
|
|
|
|
|
message(FATAL_ERROR "Failed to parse NCCL_MAJOR")
|
|
|
|
|
endif()
|
|
|
|
|
if("${version_mk_text}" MATCHES "NCCL_MINOR *:= *([0-9]*)")
|
|
|
|
|
set(NCCL_MINOR ${CMAKE_MATCH_1})
|
|
|
|
|
else()
|
|
|
|
|
message(FATAL_ERROR "Failed to parse NCCL_MINOR")
|
|
|
|
|
endif()
|
|
|
|
|
if("${version_mk_text}" MATCHES "NCCL_PATCH *:= *([0-9]*)")
|
|
|
|
|
set(NCCL_PATCH ${CMAKE_MATCH_1})
|
|
|
|
|
else()
|
|
|
|
|
message(FATAL_ERROR "Failed to parse NCCL_PATCH")
|
|
|
|
|
endif()
|
|
|
|
|
if("${version_mk_text}" MATCHES "NCCL_SUFFIX *:= *([0-9]*)")
|
|
|
|
|
set(NCCL_SUFFIX ${CMAKE_MATCH_1})
|
|
|
|
|
else()
|
|
|
|
|
set(NCCL_SUFFIX)
|
|
|
|
|
endif()
|
|
|
|
|
if("${version_mk_text}" MATCHES "PKG_REVISION *:= *([0-9]*)")
|
|
|
|
|
set(PKG_REVISION ${CMAKE_MATCH_1})
|
|
|
|
|
else()
|
|
|
|
|
message(FATAL_ERROR "Failed to parse PKG_REVISION")
|
|
|
|
|
endif()
|
|
|
|
|
if("${NCCL_PATCH}" MATCHES "[0-9][0-9]")
|
|
|
|
|
set(NCCL_VERSION "${NCCL_MAJOR}${NCCL_MINOR}${NCCL_PATCH}")
|
|
|
|
|
else()
|
|
|
|
|
set(NCCL_VERSION "${NCCL_MAJOR}${NCCL_MINOR}0${NCCL_PATCH}")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# Setup VERSION
|
2020-07-20 14:43:00 -07:00
|
|
|
set(VERSION_STRING "${NCCL_MAJOR}.${NCCL_MINOR}.${NCCL_PATCH}")
|
|
|
|
|
rocm_setup_version(VERSION ${VERSION_STRING})
|
2019-07-05 15:43:00 -07:00
|
|
|
|
|
|
|
|
list(APPEND CMAKE_PREFIX_PATH
|
|
|
|
|
/opt/rocm
|
|
|
|
|
/opt/rocm/hip
|
2020-08-06 11:19:43 -06:00
|
|
|
/opt/rocm/llvm
|
2019-07-05 15:43:00 -07:00
|
|
|
/opt/rocm/hcc)
|
|
|
|
|
|
|
|
|
|
find_package(hip REQUIRED)
|
|
|
|
|
message(STATUS "HIP compiler: ${HIP_COMPILER}")
|
|
|
|
|
message(STATUS "HIP runtime: ${HIP_RUNTIME}")
|
|
|
|
|
|
2020-08-06 11:19:43 -06:00
|
|
|
if(BUILD_STATIC)
|
|
|
|
|
option(BUILD_SHARED_LIBS "Build as a shared library" OFF)
|
|
|
|
|
else()
|
|
|
|
|
option(BUILD_SHARED_LIBS "Build as a shared library" ON)
|
|
|
|
|
endif()
|
2019-07-05 15:43:00 -07:00
|
|
|
|
|
|
|
|
configure_file(src/nccl.h.in ${PROJECT_BINARY_DIR}/rccl.h)
|
|
|
|
|
configure_file(src/nccl.h.in ${PROJECT_BINARY_DIR}/nccl.h)
|
|
|
|
|
|
|
|
|
|
include_directories(${PROJECT_BINARY_DIR}) # for generated rccl.h header
|
|
|
|
|
include_directories(src)
|
|
|
|
|
include_directories(src/include)
|
|
|
|
|
include_directories(src/collectives)
|
|
|
|
|
include_directories(src/collectives/device)
|
|
|
|
|
|
|
|
|
|
set(CU_SOURCES
|
|
|
|
|
src/collectives/device/all_reduce.cu
|
|
|
|
|
src/collectives/device/all_gather.cu
|
|
|
|
|
src/collectives/device/reduce.cu
|
|
|
|
|
src/collectives/device/broadcast.cu
|
|
|
|
|
src/collectives/device/reduce_scatter.cu
|
2020-06-08 20:45:19 -07:00
|
|
|
src/collectives/device/sendrecv.cu
|
2019-07-05 15:43:00 -07:00
|
|
|
src/collectives/device/functions.cu)
|
|
|
|
|
|
|
|
|
|
set(CPP_SOURCES)
|
|
|
|
|
foreach(filename ${CU_SOURCES})
|
|
|
|
|
string(REPLACE ".cu"
|
|
|
|
|
".cpp"
|
|
|
|
|
cpp_filename
|
|
|
|
|
${filename})
|
|
|
|
|
configure_file(${filename} ${cpp_filename} COPYONLY)
|
|
|
|
|
list(APPEND CPP_SOURCES ${cpp_filename})
|
|
|
|
|
endforeach(filename)
|
|
|
|
|
|
|
|
|
|
set(CC_SOURCES
|
|
|
|
|
src/init.cc
|
2019-11-21 13:41:10 -08:00
|
|
|
src/graph/trees.cc
|
|
|
|
|
src/graph/rings.cc
|
|
|
|
|
src/graph/paths.cc
|
|
|
|
|
src/graph/search.cc
|
|
|
|
|
src/graph/connect.cc
|
|
|
|
|
src/graph/tuning.cc
|
|
|
|
|
src/graph/topo.cc
|
2020-04-01 13:21:38 -07:00
|
|
|
src/graph/xml.cc
|
2021-03-31 10:25:59 -07:00
|
|
|
src/graph/rome_models.cc
|
2020-05-15 09:16:32 -07:00
|
|
|
src/collectives/all_reduce_api.cc
|
|
|
|
|
src/collectives/all_gather_api.cc
|
|
|
|
|
src/collectives/reduce_api.cc
|
|
|
|
|
src/collectives/broadcast_api.cc
|
|
|
|
|
src/collectives/reduce_scatter_api.cc
|
2020-06-08 20:45:19 -07:00
|
|
|
src/collectives/sendrecv_api.cc
|
2020-03-18 17:03:03 -07:00
|
|
|
src/collectives/gather_api.cc
|
|
|
|
|
src/collectives/scatter_api.cc
|
|
|
|
|
src/collectives/all_to_all_api.cc
|
2020-09-30 16:25:36 -07:00
|
|
|
src/collectives/all_to_allv_api.cc
|
2019-07-05 15:43:00 -07:00
|
|
|
src/channel.cc
|
2021-01-28 09:45:01 -07:00
|
|
|
src/clique/CliqueManager.cc # RCCL
|
|
|
|
|
src/clique/HandleCache.cc # RCCL
|
|
|
|
|
src/clique/HandleShm.cc # RCCL
|
|
|
|
|
src/clique/Hash.cc # RCCL
|
|
|
|
|
src/clique/MsgQueue.cc # RCCL
|
|
|
|
|
src/clique/ShmObject.cc # RCCL
|
2019-07-05 15:43:00 -07:00
|
|
|
src/misc/argcheck.cc
|
2019-11-21 13:41:10 -08:00
|
|
|
src/misc/nvmlwrap_stub.cc
|
2019-07-05 15:43:00 -07:00
|
|
|
src/misc/utils.cc
|
|
|
|
|
src/misc/ibvwrap.cc
|
|
|
|
|
src/misc/nvmlwrap_stub.cc
|
2020-04-01 13:21:38 -07:00
|
|
|
src/transport/coll_net.cc
|
2019-07-05 15:43:00 -07:00
|
|
|
src/transport/net.cc
|
|
|
|
|
src/transport/net_ib.cc
|
|
|
|
|
src/transport/net_socket.cc
|
|
|
|
|
src/transport/p2p.cc
|
|
|
|
|
src/transport/shm.cc
|
|
|
|
|
src/transport.cc
|
2019-11-21 13:41:10 -08:00
|
|
|
src/debug.cc
|
|
|
|
|
src/group.cc
|
2019-07-05 15:43:00 -07:00
|
|
|
src/bootstrap.cc
|
2020-06-08 20:45:19 -07:00
|
|
|
src/proxy.cc
|
2019-07-05 15:43:00 -07:00
|
|
|
src/enqueue.cc)
|
|
|
|
|
|
|
|
|
|
foreach(filename ${CC_SOURCES})
|
|
|
|
|
list(APPEND CPP_SOURCES ${filename})
|
|
|
|
|
endforeach(filename)
|
|
|
|
|
|
|
|
|
|
add_library(rccl ${CPP_SOURCES})
|
|
|
|
|
|
|
|
|
|
if(TRACE)
|
|
|
|
|
add_definitions(-DENABLE_TRACE)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(PROFILE)
|
|
|
|
|
add_definitions(-DENABLE_PROFILING)
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-11-26 16:33:13 -08:00
|
|
|
set(COLLTRACE 1 CACHE BOOL "Collective Trace Option")
|
|
|
|
|
if(COLLTRACE)
|
|
|
|
|
add_definitions(-DENABLE_COLLTRACE)
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-10-22 17:10:07 -04:00
|
|
|
foreach(target ${AMDGPU_TARGETS})
|
2020-09-25 17:44:56 -04:00
|
|
|
target_link_libraries(rccl PRIVATE --cuda-gpu-arch=${target})
|
2019-10-22 17:10:07 -04:00
|
|
|
endforeach()
|
2019-07-05 15:43:00 -07:00
|
|
|
|
|
|
|
|
if("${HIP_COMPILER}" MATCHES "clang")
|
2021-03-18 18:08:08 -07:00
|
|
|
target_compile_options(rccl PRIVATE -fvisibility=hidden)
|
2019-10-22 17:10:07 -04:00
|
|
|
foreach(target ${AMDGPU_TARGETS})
|
2020-10-16 00:25:18 -06:00
|
|
|
target_compile_options(rccl PRIVATE --cuda-gpu-arch=${target} PRIVATE -fgpu-rdc)
|
2019-10-22 17:10:07 -04:00
|
|
|
endforeach()
|
2019-07-05 15:43:00 -07:00
|
|
|
target_link_libraries(rccl PRIVATE -fgpu-rdc)
|
|
|
|
|
target_include_directories(rccl PRIVATE /opt/rocm/hsa/include)
|
2020-04-29 17:58:16 +00:00
|
|
|
find_program( hipcc_executable hipcc )
|
|
|
|
|
execute_process(COMMAND bash "-c" "${hipcc_executable} -help | grep 'parallel-jobs'" OUTPUT_VARIABLE hipcc_parallel_jobs)
|
|
|
|
|
if("${hipcc_parallel_jobs}" MATCHES "parallel-jobs")
|
2021-04-30 16:57:36 -07:00
|
|
|
target_compile_options(rccl PRIVATE -parallel-jobs=8 PRIVATE -Wno-format-nonliteral)
|
|
|
|
|
target_link_libraries(rccl PRIVATE -parallel-jobs=8)
|
2020-04-29 17:58:16 +00:00
|
|
|
endif()
|
2020-08-31 16:10:09 +00:00
|
|
|
|
|
|
|
|
# RCCL static lib uses -fgpu-rdc which requires hipcc as the linker and archiver
|
|
|
|
|
if(BUILD_STATIC)
|
|
|
|
|
target_link_libraries(rccl PRIVATE --emit-static-lib)
|
|
|
|
|
set(CMAKE_AR "${hipcc_executable}")
|
|
|
|
|
get_property(link_libraries TARGET rccl PROPERTY LINK_LIBRARIES)
|
|
|
|
|
string (REPLACE ";" " " LINK_PROPS "${link_libraries}")
|
|
|
|
|
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -o <TARGET> ${LINK_PROPS} <LINK_FLAGS> <OBJECTS>")
|
|
|
|
|
endif()
|
2019-07-05 15:43:00 -07:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if("${HIP_COMPILER}" MATCHES "hcc")
|
2019-10-03 13:25:25 -04:00
|
|
|
find_program( hcc_executable hcc )
|
|
|
|
|
execute_process(COMMAND bash "-c" "${hcc_executable} --version | sed -e '1!d' -e 's/.*based on HCC\\s*//'" OUTPUT_VARIABLE hcc_version_string)
|
|
|
|
|
execute_process(COMMAND bash "-c" "echo \"${hcc_version_string}\" | awk -F\".\" '{ printf $1}'" OUTPUT_VARIABLE hcc_major_version)
|
|
|
|
|
execute_process(COMMAND bash "-c" "echo \"${hcc_version_string}\" | awk -F\".\" '{ printf $2}'" OUTPUT_VARIABLE hcc_minor_version)
|
2020-02-11 19:37:13 +00:00
|
|
|
if ("${hcc_major_version}.${hcc_minor_version}" VERSION_LESS "4.0")
|
2019-10-03 13:25:25 -04:00
|
|
|
target_link_libraries(rccl PRIVATE -hc-function-calls)
|
|
|
|
|
endif()
|
2019-07-05 15:43:00 -07:00
|
|
|
endif()
|
|
|
|
|
|
2021-04-26 15:24:58 -07:00
|
|
|
target_link_libraries(rccl PRIVATE hip::device dl)
|
2020-03-05 13:36:55 -07:00
|
|
|
target_link_libraries(rccl INTERFACE hip::host)
|
2019-07-05 15:43:00 -07:00
|
|
|
|
2020-01-08 21:28:16 -08:00
|
|
|
#Setup librccl.so version
|
|
|
|
|
rocm_set_soversion(rccl "1.0")
|
|
|
|
|
|
2019-07-05 15:43:00 -07:00
|
|
|
rocm_install_targets(TARGETS
|
|
|
|
|
rccl
|
|
|
|
|
PREFIX
|
|
|
|
|
rccl)
|
|
|
|
|
install(FILES ${PROJECT_BINARY_DIR}/rccl.h
|
|
|
|
|
DESTINATION rccl/${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
|
|
|
|
|
|
rocm_export_targets(NAMESPACE
|
|
|
|
|
roc::
|
|
|
|
|
PREFIX
|
|
|
|
|
rccl
|
|
|
|
|
TARGETS
|
|
|
|
|
rccl
|
|
|
|
|
DEPENDS
|
|
|
|
|
hip)
|
|
|
|
|
|
2020-07-14 17:49:56 -06:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_DEPENDS "hip-rocclr (>= 3.5.0)")
|
2020-10-21 16:20:53 -07:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
|
2020-07-14 17:49:56 -06:00
|
|
|
set(CPACK_RPM_PACKAGE_REQUIRES "hip-rocclr >= 3.5.0")
|
2019-07-05 15:43:00 -07:00
|
|
|
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/opt" "/opt/rocm")
|
|
|
|
|
|
2020-10-21 16:20:53 -07:00
|
|
|
find_file (DEBIAN debian_version debconf.conf PATHS /etc)
|
|
|
|
|
if(DEBIAN)
|
|
|
|
|
# Write copyright file
|
|
|
|
|
file(WRITE "${CMAKE_BINARY_DIR}/copyright"
|
|
|
|
|
"Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
|
|
|
|
Upstream-Name: rccl
|
|
|
|
|
Source: https://github.com/ROCmSoftwarePlatform/rccl
|
|
|
|
|
|
|
|
|
|
Files: *
|
|
|
|
|
Copyright: (c) 2016-2020, NVIDIA CORPORATION. All rights reserved.
|
|
|
|
|
Modifications Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved.
|
|
|
|
|
License: See LICENSE.txt for license information\n")
|
2021-04-09 14:08:40 -07:00
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/copyright" DESTINATION ${CMAKE_INSTALL_DATADIR}/rccl)
|
2020-10-21 16:20:53 -07:00
|
|
|
# Write changelog file
|
|
|
|
|
find_program( date_executable date )
|
|
|
|
|
execute_process(COMMAND ${date_executable} -R OUTPUT_VARIABLE TIMESTAMP)
|
|
|
|
|
file(WRITE "${CMAKE_BINARY_DIR}/changelog"
|
|
|
|
|
"rccl (${VERSION_STRING}-1) unstable; urgency=medium
|
|
|
|
|
|
|
|
|
|
* Initial release.
|
|
|
|
|
|
|
|
|
|
-- RCCL Maintainer <rccl-maintainer@amd.com> ${TIMESTAMP}\n")
|
|
|
|
|
find_program( gzip_executable gzip )
|
|
|
|
|
execute_process(COMMAND bash "-c" "${gzip_executable} -9 -c ${CMAKE_BINARY_DIR}/changelog"
|
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_FILE "${CMAKE_BINARY_DIR}/changelog.Debian.gz")
|
2021-04-09 14:08:40 -07:00
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/changelog.Debian.gz" DESTINATION ${CMAKE_INSTALL_DATADIR}/rccl)
|
2020-10-21 16:20:53 -07:00
|
|
|
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "ROCm Communication Collectives Library
|
|
|
|
|
Optimized primitives for collective multi-GPU communication")
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-07-05 15:43:00 -07:00
|
|
|
rocm_create_package(
|
|
|
|
|
NAME
|
|
|
|
|
rccl
|
|
|
|
|
DESCRIPTION
|
2020-10-21 16:20:53 -07:00
|
|
|
"ROCm Communication Collectives Library"
|
2019-07-05 15:43:00 -07:00
|
|
|
MAINTAINER
|
2020-10-21 16:20:53 -07:00
|
|
|
"RCCL Maintainer <rccl-maintainer@amd.com>"
|
2019-07-05 15:43:00 -07:00
|
|
|
LDCONFIG)
|
|
|
|
|
|
|
|
|
|
rocm_install_symlink_subdir(rccl)
|
|
|
|
|
|
|
|
|
|
if(BUILD_TESTS)
|
|
|
|
|
add_subdirectory(test)
|
|
|
|
|
endif()
|