2021-01-15 16:34:36 -07:00
|
|
|
# Copyright (c) 2019-2021 Advanced Micro Devices, Inc. All rights reserved.
|
2022-12-13 07:51:04 +08:00
|
|
|
# Modifications Copyright (c) Microsoft Corporation. Licensed under the MIT License.
|
|
|
|
|
|
2019-07-05 15:43:00 -07:00
|
|
|
cmake_minimum_required(VERSION 2.8.12)
|
|
|
|
|
|
|
|
|
|
if(BUILD_TESTS)
|
|
|
|
|
|
2024-07-04 09:34:38 -06:00
|
|
|
option(OPENMP_TESTS_ENABLED "Enable OpenMP for unit tests" OFF)
|
|
|
|
|
|
2022-12-13 21:45:57 +00:00
|
|
|
message("Building rccl unit tests (Installed in /test/rccl-UnitTests)")
|
2019-07-05 15:43:00 -07:00
|
|
|
|
2022-02-25 08:59:07 -07:00
|
|
|
find_package(hsa-runtime64 PATHS /opt/rocm )
|
|
|
|
|
if(${hsa-runtime64_FOUND})
|
|
|
|
|
message("hsa-runtime64 found @ ${hsa-runtime64_DIR} ")
|
2021-10-26 16:36:46 -07:00
|
|
|
else()
|
2022-02-25 08:59:07 -07:00
|
|
|
message("find_package did NOT find hsa-runtime64, finding it the OLD Way")
|
|
|
|
|
message("Looking for header files in ${ROCR_INC_DIR}")
|
|
|
|
|
message("Looking for library files in ${ROCR_LIB_DIR}")
|
|
|
|
|
|
|
|
|
|
# Search for ROCr header file in user defined locations
|
2022-11-04 09:52:16 -07:00
|
|
|
find_path(ROCR_HDR hsa/hsa.h PATHS ${ROCR_INC_DIR} "/opt/rocm" PATH_SUFFIXES include REQUIRED)
|
2022-02-25 08:59:07 -07:00
|
|
|
INCLUDE_DIRECTORIES(${ROCR_HDR})
|
|
|
|
|
|
|
|
|
|
# Search for ROCr library file in user defined locations
|
|
|
|
|
find_library(ROCR_LIB ${CORE_RUNTIME_TARGET} PATHS ${ROCR_LIB_DIR} "/opt/rocm" PATH_SUFFIXES lib lib64 REQUIRED)
|
2021-10-26 16:36:46 -07:00
|
|
|
endif()
|
2022-02-25 08:59:07 -07:00
|
|
|
|
2024-07-04 09:34:38 -06:00
|
|
|
if(OPENMP_TESTS_ENABLED)
|
|
|
|
|
find_package(OpenMP REQUIRED)
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-02-25 08:59:07 -07:00
|
|
|
include_directories(${GTEST_INCLUDE_DIRS} ./common)
|
|
|
|
|
|
|
|
|
|
# Collect testing framework source files
|
2024-04-23 13:33:19 -07:00
|
|
|
set(TEST_SOURCE_FILES
|
|
|
|
|
AllGatherTests.cpp
|
|
|
|
|
AllReduceTests.cpp
|
|
|
|
|
AllToAllTests.cpp
|
|
|
|
|
AllToAllVTests.cpp
|
|
|
|
|
BroadcastTests.cpp
|
|
|
|
|
GatherTests.cpp
|
|
|
|
|
GroupCallTests.cpp
|
|
|
|
|
NonBlockingTests.cpp
|
|
|
|
|
ReduceScatterTests.cpp
|
|
|
|
|
ReduceTests.cpp
|
|
|
|
|
ScatterTests.cpp
|
|
|
|
|
SendRecvTests.cpp
|
|
|
|
|
StandaloneTests.cpp
|
2022-02-25 08:59:07 -07:00
|
|
|
common/main.cpp
|
|
|
|
|
common/CollectiveArgs.cpp
|
|
|
|
|
common/EnvVars.cpp
|
|
|
|
|
common/PrepDataFuncs.cpp
|
|
|
|
|
common/PtrUnion.cpp
|
|
|
|
|
common/TestBed.cpp
|
|
|
|
|
common/TestBedChild.cpp
|
|
|
|
|
)
|
|
|
|
|
|
2024-04-23 13:33:19 -07:00
|
|
|
add_executable(rccl-UnitTests ${TEST_SOURCE_FILES})
|
2024-02-12 17:56:15 -07:00
|
|
|
|
|
|
|
|
## Set rccl-UnitTests include directories
|
2022-12-13 21:45:57 +00:00
|
|
|
target_include_directories(rccl-UnitTests PRIVATE ${ROCM_PATH} ${GTEST_INCLUDE_DIRS})
|
2024-02-12 17:56:15 -07:00
|
|
|
target_include_directories(rccl-UnitTests PRIVATE ${PROJECT_BINARY_DIR}/include) # for generated rccl.h header
|
2023-05-25 16:08:54 -06:00
|
|
|
target_include_directories(rccl-UnitTests PRIVATE ${PROJECT_BINARY_DIR}/hipify/src/include) # for rccl_bfloat16.h
|
2024-02-12 17:56:15 -07:00
|
|
|
|
|
|
|
|
## Set rccl-UnitTests compile definitions
|
|
|
|
|
if(LL128_ENABLED)
|
|
|
|
|
target_compile_definitions(rccl-UnitTests PRIVATE ENABLE_LL128)
|
|
|
|
|
endif()
|
2024-07-04 09:34:38 -06:00
|
|
|
if(OPENMP_TESTS_ENABLED)
|
|
|
|
|
target_compile_definitions(rccl-UnitTests PRIVATE ENABLE_OPENMP)
|
|
|
|
|
endif()
|
2024-02-12 17:56:15 -07:00
|
|
|
target_compile_definitions(rccl-UnitTests PRIVATE ROCM_PATH="${ROCM_PATH}")
|
|
|
|
|
|
2024-07-04 09:34:38 -06:00
|
|
|
## Set rccl-UnitTests compile definitions
|
|
|
|
|
if(OPENMP_TESTS_ENABLED)
|
|
|
|
|
target_compile_options(rccl-UnitTests PRIVATE "${OpenMP_CXX_FLAGS}")
|
|
|
|
|
endif()
|
|
|
|
|
|
2024-02-12 17:56:15 -07:00
|
|
|
## Set rccl-UnitTests linked libraries
|
2022-12-13 21:45:57 +00:00
|
|
|
target_link_libraries(rccl-UnitTests PRIVATE ${GTEST_BOTH_LIBRARIES})
|
|
|
|
|
target_link_libraries(rccl-UnitTests PRIVATE hip::host hip::device hsa-runtime64::hsa-runtime64)
|
2023-06-06 14:21:40 -04:00
|
|
|
target_link_libraries(rccl-UnitTests PRIVATE Threads::Threads)
|
2024-07-04 09:34:38 -06:00
|
|
|
if(OPENMP_TESTS_ENABLED)
|
|
|
|
|
target_link_libraries(rccl-UnitTests PRIVATE "${OpenMP_CXX_FLAGS}")
|
|
|
|
|
endif()
|
2021-11-16 10:28:26 -08:00
|
|
|
|
2022-12-13 21:45:57 +00:00
|
|
|
# rccl-UnitTests using static library of rccl requires passing rccl
|
2020-08-31 16:10:09 +00:00
|
|
|
# through -l and -L instead of command line input.
|
|
|
|
|
if(BUILD_STATIC)
|
2022-12-13 21:45:57 +00:00
|
|
|
add_dependencies(rccl-UnitTests rccl)
|
|
|
|
|
target_link_libraries(rccl-UnitTests PRIVATE dl rt numa -lrccl -L${CMAKE_BINARY_DIR} -lrocm_smi64 -L${ROCM_PATH}/lib -L${ROCM_PATH}/rocm_smi/lib)
|
2020-08-31 16:10:09 +00:00
|
|
|
else()
|
2022-12-13 21:45:57 +00:00
|
|
|
target_link_libraries(rccl-UnitTests PRIVATE rccl)
|
2020-08-31 16:10:09 +00:00
|
|
|
endif()
|
2024-03-26 11:11:09 -04:00
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
|
set_property(TARGET rccl-UnitTests PROPERTY INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${ROCM_PATH}/lib;${CMAKE_BINARY_DIR}")
|
|
|
|
|
endif()
|
2022-12-13 21:45:57 +00:00
|
|
|
set_property(TARGET rccl-UnitTests PROPERTY BUILD_RPATH "${CMAKE_BINARY_DIR};${ROCM_PATH}/lib")
|
|
|
|
|
rocm_install(TARGETS rccl-UnitTests COMPONENT tests)
|
2019-07-05 15:43:00 -07:00
|
|
|
else()
|
2022-12-13 21:45:57 +00:00
|
|
|
message("Not building rccl unit tests")
|
2019-07-05 15:43:00 -07:00
|
|
|
endif()
|