Skip to content

Commit

Permalink
Changed the name of UnitTests to rccl-UnitTests (wrapper executable i…
Browse files Browse the repository at this point in the history
…ncluded).
  • Loading branch information
PedramAlizadeh committed Dec 13, 2022
1 parent 8250092 commit 45872d1
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .jenkins/common.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def runTestCommand (platform, project, gfilter)
cd ${project.paths.project_build_prefix}/build/release/test
${sudo} ulimit -l unlimited
ulimit -a
${sudo} RCCL_ENABLE_SIGNALHANDLER=1 NCCL_DEBUG=INFO HSA_FORCE_FINE_GRAIN_PCIE=1 ./UnitTests --gtest_filter=${gfilter} --gtest_output=xml --gtest_color=yes
${sudo} RCCL_ENABLE_SIGNALHANDLER=1 NCCL_DEBUG=INFO HSA_FORCE_FINE_GRAIN_PCIE=1 ./rccl-UnitTests --gtest_filter=${gfilter} --gtest_output=xml --gtest_color=yes
"""

platform.runCommand(this, command)
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ For ROCm installation instructions, see https://github.com/RadeonOpenCompute/ROC

The root of this repository has a helper script 'install.sh' to build and install RCCL on Ubuntu with a single command. It does not take a lot of options and hard-codes configuration that can be specified through invoking cmake directly, but it's a great way to get started quickly and can serve as an example of how to build/install.

* `./install.sh` -- builds library including unit tests
* `./install.sh` -- builds library including rccl unit tests
* `./install.sh -i` -- builds and installs the library to /opt/rocm/rccl; installation path can be changed with --prefix argument (see below.)
* `./install.sh -d` -- installs all necessary dependencies for RCCL. Should be re-invoked if the build folder is removed.
* `./install.sh -h` -- shows help
* `./install.sh -t` -- builds library including unit tests
* `./install.sh -r` -- runs unit tests (must be already built)
* `./install.sh -t` -- builds library including rccl unit tests
* `./install.sh -r` -- runs rccl unit tests (must be already built)
* `./install.sh -p` -- builds RCCL package
* `./install.sh -s` -- builds RCCL as a static library (default: shared)
* `./install.sh -hcc` -- builds RCCL with hcc compiler; note that hcc is now deprecated. (default:hip-clang)
Expand Down Expand Up @@ -65,17 +65,17 @@ In order to enable peer-to-peer access on machines with PCIe-connected GPUs, the

## Tests

There are unit tests implemented with the Googletest framework in RCCL. The unit tests require Googletest 1.10 or higher to build and execute properly (installed with the -d option to install.sh).
To invoke the unit tests, go to the build folder, then the test subfolder, and execute the appropriate unit test executable(s).
There are rccl unit tests implemented with the Googletest framework in RCCL. The rccl unit tests require Googletest 1.10 or higher to build and execute properly (installed with the -d option to install.sh).
To invoke the rccl unit tests, go to the build folder, then the test subfolder, and execute the appropriate rccl unit test executable(s).

Unit test names are now of the format:
rccl unit test names are now of the format:

CollectiveCall.[Type of test]

Filtering of unit tests should be done with environment variable and by passing the --gtest_filter command line flag, for example:
Filtering of rccl unit tests should be done with environment variable and by passing the --gtest_filter command line flag, for example:

```shell
UT_DATATYPES=ncclBfloat16 UT_REDOPS=prod ./UnitTests --gtest_filter="AllReduce.C*"
UT_DATATYPES=ncclBfloat16 UT_REDOPS=prod ./rccl-UnitTests --gtest_filter="AllReduce.C*"
```
will run only AllReduce correctness tests with float16 datatype. A list of available filtering environment variables appears at the top of every run. See "Running a Subset of the Tests" at https://chromium.googlesource.com/external/github.com/google/googletest/+/HEAD/googletest/docs/advanced.md for more information on how to form more advanced filters.

Expand Down
20 changes: 10 additions & 10 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ function display_help()
echo " [-i|--install] install RCCL library (see --prefix argument below.)"
echo " [-d|--dependencies] install RCCL depdencencies."
echo " [-p|--package_build] Build RCCL package."
echo " [-t|--tests_build] Build unit tests, but do not run."
echo " [-r|--run_tests_quick] Run small subset of unit tests (must be built already.)"
echo " [-t|--tests_build] Build rccl unit tests, but do not run."
echo " [-r|--run_tests_quick] Run small subset of rccl unit tests (must be built already.)"
echo " [-s|--static] Build RCCL as a static library instead of shared library."
echo " [--run_tests_all] Run all unit tests (must be built already.)"
echo " [--run_tests_all] Run all rccl unit tests (must be built already.)"
echo " [--hcc] Build library using deprecated hcc compiler (default:hip-clang)."
echo " [--prefix] Specify custom directory to install RCCL to (default: /opt/rocm)."
echo " [--address-sanitizer] Build with address sanitizer enabled"
Expand Down Expand Up @@ -139,9 +139,9 @@ check_exit_code( )
}

if [[ "$build_release" == true ]]; then
unit_test_path="./build/release/test/UnitTests"
unit_test_path="./build/release/test/rccl-UnitTests"
else
unit_test_path="./build/debug/test/UnitTests"
unit_test_path="./build/debug/test/rccl-UnitTests"
fi

if ($run_tests) && [[ -f $unit_test_path ]]; then
Expand Down Expand Up @@ -216,7 +216,7 @@ if ($build_allreduce_only); then
fi
check_exit_code "$?"

if ($build_tests) || (($run_tests) && [[ ! -f ./test/UnitTests ]]); then
if ($build_tests) || (($run_tests) && [[ ! -f ./test/rccl-UnitTests ]]); then
CXX=$ROCM_BIN_PATH/$compiler $cmake_executable $cmake_common_options -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=$ROCM_PATH -DROCM_PATH=$ROCM_PATH ../../.
else
CXX=$ROCM_BIN_PATH/$compiler $cmake_executable $cmake_common_options -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$ROCM_PATH -DROCM_PATH=$ROCM_PATH ../../.
Expand All @@ -237,14 +237,14 @@ fi
# Optionally, run tests if they're enabled.
if ($run_tests); then
if (test -f "./test/UnitTests"); then
if (test -f "./test/rccl-UnitTests"); then
if ($run_tests_all); then
./test/UnitTests
./test/rccl-UnitTests
else
./test/UnitTests --gtest_filter="AllReduce.*"
./test/rccl-UnitTests --gtest_filter="AllReduce.*"
fi
else
echo "Unit tests have not been built yet; please re-run script with -t to build unit tests."
echo "rccl unit tests have not been built yet; please re-run script with -t to build rccl unit tests."
exit 1
fi
fi
2 changes: 1 addition & 1 deletion rtest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<testset>
<!-- Typically run with environment variables NCCL_DEBUG=INFO HSA_FORCE_FINE_GRAIN_PCIE=1 -->
<var name="GTEST_FILTER">UnitTests --gtest_color=yes --gtest_filter=</var>
<var name="GTEST_FILTER">rccl-UnitTests --gtest_color=yes --gtest_filter=</var>
<test sets="psdb">
<run name="all-psdb">{GTEST_FILTER}*sum_float32* --gtest_output=xml:output_psdb.xml </run>
</test>
Expand Down
35 changes: 18 additions & 17 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ cmake_minimum_required(VERSION 2.8.12)

if(BUILD_TESTS)

message("Building unit tests (Installed in /test/UnitTests)")
message("Building rccl unit tests (Installed in /test/rccl-UnitTests)")

find_program(CHRPATH chrpath)
if(NOT CHRPATH)
message(FATAL_ERROR "chrpath is required for UnitTests. Please install (e.g. sudo apt-get install chrpath)")
message(FATAL_ERROR "chrpath is required for rccl-UnitTests. Please install (e.g. sudo apt-get install chrpath)")
endif()

find_package(hsa-runtime64 PATHS /opt/rocm )
Expand Down Expand Up @@ -98,31 +98,32 @@ if(BUILD_TESTS)
)
endif()

add_executable(UnitTests ${COMMON_SOURCE_FILES} ${TEST_SOURCE_FILES})
target_include_directories(UnitTests PRIVATE ${ROCM_PATH} ${GTEST_INCLUDE_DIRS})
target_link_libraries(UnitTests PRIVATE ${GTEST_BOTH_LIBRARIES})
target_link_libraries(UnitTests PRIVATE hip::host hip::device hsa-runtime64::hsa-runtime64)
add_executable(rccl-UnitTests ${COMMON_SOURCE_FILES} ${TEST_SOURCE_FILES})
configure_file(common/UnitTests UnitTests)
target_include_directories(rccl-UnitTests PRIVATE ${ROCM_PATH} ${GTEST_INCLUDE_DIRS})
target_link_libraries(rccl-UnitTests PRIVATE ${GTEST_BOTH_LIBRARIES})
target_link_libraries(rccl-UnitTests PRIVATE hip::host hip::device hsa-runtime64::hsa-runtime64)

# UnitTests using static library of rccl requires passing rccl
# rccl-UnitTests using static library of rccl requires passing rccl
# through -l and -L instead of command line input.
if(BUILD_STATIC)
add_dependencies(UnitTests rccl)
target_link_libraries(UnitTests PRIVATE dl rt numa -lrccl -L${CMAKE_BINARY_DIR} -lrocm_smi64 -L${ROCM_PATH}/lib -L${ROCM_PATH}/rocm_smi/lib)
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)
else()
target_link_libraries(UnitTests PRIVATE rccl)
target_link_libraries(rccl-UnitTests PRIVATE rccl)
endif()
# HIPCC adds /opt/rocm/lib as RPATH, even though the install process is supposed to
# remove RPATH. It also occurs before any user-specified rpath, which effectively overrides the user rpath.
# As a work-around, set the correct RPATH for the unit test executable as a post-install step
# As a work-around, set the correct RPATH for the rccl unit test executable as a post-install step
# if (CMAKE_INSTALL_PREFIX MATCHES "${ROCM_PATH}")
# # install_prefix/CMAKE_INSTALL_PREFIX was not explicitly specified, so look in build/release
# add_custom_command( TARGET UnitTests POST_BUILD COMMAND chrpath ARGS -r ${CMAKE_BINARY_DIR}:${ROCM_PATH}/lib ${CMAKE_BINARY_DIR}/test/UnitTests)
# add_custom_command( TARGET rccl-UnitTests POST_BUILD COMMAND chrpath ARGS -r ${CMAKE_BINARY_DIR}:${ROCM_PATH}/lib ${CMAKE_BINARY_DIR}/test/rccl-UnitTests)
# else()
# add_custom_command( TARGET UnitTests POST_BUILD COMMAND chrpath ARGS -r ${CMAKE_INSTALL_PREFIX}/lib:${ROCM_PATH}/lib ${CMAKE_INSTALL_PREFIX}/test/UnitTests)
# add_custom_command( TARGET rccl-UnitTests POST_BUILD COMMAND chrpath ARGS -r ${CMAKE_INSTALL_PREFIX}/lib:${ROCM_PATH}/lib ${CMAKE_INSTALL_PREFIX}/test/rccl-UnitTests)
# endif()
set_property(TARGET UnitTests PROPERTY INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${ROCM_PATH}/lib;${CMAKE_BINARY_DIR}")
set_property(TARGET UnitTests PROPERTY BUILD_RPATH "${CMAKE_BINARY_DIR};${ROCM_PATH}/lib")
rocm_install(TARGETS UnitTests COMPONENT tests)
set_property(TARGET rccl-UnitTests PROPERTY INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${ROCM_PATH}/lib;${CMAKE_BINARY_DIR}")
set_property(TARGET rccl-UnitTests PROPERTY BUILD_RPATH "${CMAKE_BINARY_DIR};${ROCM_PATH}/lib")
rocm_install(TARGETS rccl-UnitTests COMPONENT tests)
else()
message("Not building unit tests")
message("Not building rccl unit tests")
endif()
10 changes: 10 additions & 0 deletions test/common/UnitTests
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#/*************************************************************************
# * Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved.
# *
# * See LICENSE.txt for license information
# ************************************************************************/

#!/bin/bash
echo "The RCCL test client name has changed from UnitTests to rccl-UnitTests. Please make sure to execute the rccl-UnitTests instead."

./rccl-UnitTests $@

0 comments on commit 45872d1

Please sign in to comment.