diff --git a/install.sh b/install.sh index df71584541..6fbdfb5bfb 100755 --- a/install.sh +++ b/install.sh @@ -12,7 +12,8 @@ function display_help() echo " [-i|--install] install RCCL library (see --prefix argument below.)" echo " [-p|--package_build] Build RCCL package." echo " [-t|--tests_build] Build unit tests, but do not run." - echo " [-r|--run_tests] Run unit tests (must be built already.)" + echo " [-r|--run_tests_quick] Run small subset of unit tests (must be built already.)" + echo " [--run_tests_all] Run all 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)." } @@ -25,9 +26,11 @@ build_package=false install_prefix=$default_path build_tests=false run_tests=false +run_tests_all=false build_release=true install_library=false build_hip_clang=true +clean_build=true install_dependencies=false # ################################################# @@ -37,7 +40,7 @@ install_dependencies=false # check if we have a modern version of getopt that can handle whitespace and long parameters getopt -T if [[ $? -eq 4 ]]; then - GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,package_build,tests_build,run_tests,hcc,hip-clang,prefix: --options hiptr -- "$@") + GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,dependencies,package_build,tests_build,run_tests_quick,run_tests_all,hcc,hip-clang,no_clean,prefix: --options hiptr -- "$@") else echo "Need a new version of getopt" exit 1 @@ -68,15 +71,22 @@ while true; do -t|--tests_build) build_tests=true shift ;; - -r|--run_tests) + -r|--run_tests_quick) run_tests=true shift ;; + --run_tests_all) + run_tests=true + run_tests_all=true + shift ;; --hcc) build_hip_clang=false shift ;; --hip-clang) build_hip_clang=true shift ;; + --no_clean) + clean_build=false + shift ;; --prefix) install_prefix=${2} shift 2 ;; @@ -112,10 +122,12 @@ check_exit_code( ) # prep # ################################################# # ensure a clean build environment -if [[ "${build_release}" == true ]]; then - rm -rf build/release -else - rm -rf build/debug +if ($clean_build); then + if [[ "${build_release}" == true ]]; then + rm -rf build/release + else + rm -rf build/debug + fi fi @@ -156,7 +168,7 @@ if ($install_dependencies); then fi check_exit_code "$?" -if ($build_tests); then +if ($build_tests) || (($run_tests) && [[ ! -f ./test/UnitTests ]]); then CXX=$rocm_path/$compiler $cmake_executable $cmake_common_options -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=$install_prefix ../../. else CXX=$rocm_path/$compiler $cmake_executable $cmake_common_options -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$install_prefix ../../. @@ -178,7 +190,11 @@ fi # Optionally, run tests if they're enabled. if ($run_tests); then if (test -f "./test/UnitTests"); then - ./test/UnitTests + if ($run_tests_all); then + ./test/UnitTests + else + ./test/UnitTests --gtest_filter="BroadcastCorrectnessSweep*:*float32*" + fi else echo "Unit tests have not been built yet; please re-run script with -t to build unit tests." exit 1 diff --git a/test/CorrectnessTest.hpp b/test/CorrectnessTest.hpp index 1c52224a7b..95010ee701 100644 --- a/test/CorrectnessTest.hpp +++ b/test/CorrectnessTest.hpp @@ -170,6 +170,51 @@ namespace CorrectnessTests // - Each test is instantiated with a different TestTuple class CorrectnessTest : public testing::TestWithParam { + public: + struct PrintToStringParamName + { + std::string operator()(const testing::TestParamInfo& info) + { + std::string name; + + name += opStrings[std::get<0>(info.param)] + "_"; + name += dataTypeStrings[std::get<1>(info.param)] + "_"; + name += std::to_string(std::get<2>(info.param)) + "elements_"; + name += std::to_string(std::get<3>(info.param)) + "devices_"; + name += std::get<4>(info.param) == true ? "inplace_" : "outofplace_"; + std::string envVars = std::string(std::get<5>(info.param)); + std::replace(envVars.begin(), envVars.end(), '=', '_'); + name += envVars; + + return name; + } + + std::map opStrings + { + {ncclSum, "sum"}, + {ncclProd, "prod"}, + {ncclMax, "max"}, + {ncclMin, "min"} + }; + + std::map dataTypeStrings + { + {ncclInt8, "int8"}, + {ncclChar, "char"}, + {ncclUint8, "uint8"}, + {ncclInt32, "int32"}, + {ncclInt, "int"}, + {ncclUint32, "uint32"}, + {ncclInt64, "int64"}, + {ncclUint64, "uint64"}, + {ncclFloat16, "float16"}, + {ncclHalf, "half"}, + {ncclFloat32, "float32"}, + {ncclFloat64, "float64"}, + {ncclDouble, "double"}, + {ncclBfloat16, "bfloat16"} + }; + }; protected: // This code is called per test-tuple diff --git a/test/test_AllGather.cpp b/test/test_AllGather.cpp index 1e7b9441c0..d53ab4354d 100644 --- a/test/test_AllGather.cpp +++ b/test/test_AllGather.cpp @@ -88,7 +88,7 @@ namespace CorrectnessTests } - INSTANTIATE_TEST_CASE_P(AllGatherCorrectnessSweep, + INSTANTIATE_TEST_SUITE_P(AllGatherCorrectnessSweep, AllGatherCorrectnessTest, testing::Combine( // Reduction operator (not used) @@ -110,5 +110,6 @@ namespace CorrectnessTests testing::Values(2,3,4,5,6,7,8), // In-place or not testing::Values(false, true), - testing::Values(""))); + testing::Values("")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_AllReduce.cpp b/test/test_AllReduce.cpp index 1452ccdfef..992b7c32d4 100644 --- a/test/test_AllReduce.cpp +++ b/test/test_AllReduce.cpp @@ -36,7 +36,7 @@ namespace CorrectnessTests dataset.Release(); } - INSTANTIATE_TEST_CASE_P(AllReduceCorrectnessSweep, + INSTANTIATE_TEST_SUITE_P(AllReduceCorrectnessSweep, AllReduceCorrectnessTest, testing::Combine( // Reduction operator @@ -58,5 +58,6 @@ namespace CorrectnessTests testing::Values(2,3,4,5,6,7,8), // In-place or not testing::Values(false, true), - testing::Values(""))); + testing::Values("")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_AllReduceAbort.cpp b/test/test_AllReduceAbort.cpp index d84f36f8ad..0880043931 100644 --- a/test/test_AllReduceAbort.cpp +++ b/test/test_AllReduceAbort.cpp @@ -126,7 +126,7 @@ namespace CorrectnessTests dataset.Release(); } - INSTANTIATE_TEST_CASE_P(AllReduceAbortSweep, + INSTANTIATE_TEST_SUITE_P(AllReduceAbortSweep, AllReduceAbortTest, testing::Combine( // Reduction operator @@ -139,5 +139,6 @@ namespace CorrectnessTests testing::Values(2, 4), // In-place or not testing::Values(false), - testing::Values(""))); + testing::Values("")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_AllToAll.cpp b/test/test_AllToAll.cpp index 05d5e40475..a1b0c00510 100644 --- a/test/test_AllToAll.cpp +++ b/test/test_AllToAll.cpp @@ -40,7 +40,7 @@ namespace CorrectnessTests dataset.Release(); } - INSTANTIATE_TEST_CASE_P(AllToAllCorrectnessSweep, + INSTANTIATE_TEST_SUITE_P(AllToAllCorrectnessSweep, AllToAllCorrectnessTest, testing::Combine( // Reduction operator is not used @@ -62,5 +62,6 @@ namespace CorrectnessTests testing::Values(2,3,4,5,6,7,8), // In-place or not testing::Values(false), - testing::Values("RCCL_ALLTOALL_KERNEL_DISABLE=0", "RCCL_ALLTOALL_KERNEL_DISABLE=1"))); + testing::Values("RCCL_ALLTOALL_KERNEL_DISABLE=0", "RCCL_ALLTOALL_KERNEL_DISABLE=1")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_Broadcast.cpp b/test/test_Broadcast.cpp index 52e4403c75..955c2c1255 100644 --- a/test/test_Broadcast.cpp +++ b/test/test_Broadcast.cpp @@ -44,7 +44,7 @@ namespace CorrectnessTests dataset.Release(); } - INSTANTIATE_TEST_CASE_P(BroadcastCorrectnessSweep, + INSTANTIATE_TEST_SUITE_P(BroadcastCorrectnessSweep, BroadcastCorrectnessTest, testing::Combine( // Reduction operator is not used @@ -66,5 +66,6 @@ namespace CorrectnessTests testing::Values(2,3,4,5,6,7,8), // In-place or not testing::Values(false, true), - testing::Values(""))); + testing::Values("")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_BroadcastAbort.cpp b/test/test_BroadcastAbort.cpp index e14c8f159c..9ea6fd6beb 100644 --- a/test/test_BroadcastAbort.cpp +++ b/test/test_BroadcastAbort.cpp @@ -129,7 +129,7 @@ namespace CorrectnessTests dataset.Release(); } - INSTANTIATE_TEST_CASE_P(BroadcastAbortSweep, + INSTANTIATE_TEST_SUITE_P(BroadcastAbortSweep, BroadcastAbortTest, testing::Combine( // Reduction operator @@ -142,5 +142,6 @@ namespace CorrectnessTests testing::Values(2, 4), // In-place or not testing::Values(false), - testing::Values(""))); + testing::Values("")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_CombinedCalls.cpp b/test/test_CombinedCalls.cpp index 1fe86a4125..db4f938fc0 100644 --- a/test/test_CombinedCalls.cpp +++ b/test/test_CombinedCalls.cpp @@ -74,7 +74,7 @@ namespace CorrectnessTests } } - INSTANTIATE_TEST_CASE_P(CombinedCallsCorrectnessSweep, + INSTANTIATE_TEST_SUITE_P(CombinedCallsCorrectnessSweep, CombinedCallsCorrectnessTest, testing::Combine( // Reduction operator (not used) @@ -96,5 +96,6 @@ namespace CorrectnessTests testing::Values(2,3,4,5,6,7,8), // In-place or not testing::Values(false, true), - testing::Values(""))); + testing::Values("")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_Gather.cpp b/test/test_Gather.cpp index 95dc35c461..8169127966 100644 --- a/test/test_Gather.cpp +++ b/test/test_Gather.cpp @@ -44,7 +44,7 @@ namespace CorrectnessTests dataset.Release(); } - INSTANTIATE_TEST_CASE_P(GatherCorrectnessSweep, + INSTANTIATE_TEST_SUITE_P(GatherCorrectnessSweep, GatherCorrectnessTest, testing::Combine( // Reduction operator is not used @@ -66,5 +66,6 @@ namespace CorrectnessTests testing::Values(2,3,4,5,6,7,8), // In-place or not testing::Values(false), - testing::Values("RCCL_ALLTOALL_KERNEL_DISABLE=0", "RCCL_ALLTOALL_KERNEL_DISABLE=1"))); + testing::Values("RCCL_ALLTOALL_KERNEL_DISABLE=0", "RCCL_ALLTOALL_KERNEL_DISABLE=1")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_GroupCalls.cpp b/test/test_GroupCalls.cpp index 2f652e96e4..b3ab2ca09b 100644 --- a/test/test_GroupCalls.cpp +++ b/test/test_GroupCalls.cpp @@ -94,9 +94,9 @@ namespace CorrectnessTests } } - INSTANTIATE_TEST_CASE_P(GroupCallsCorrectnessSweep, - GroupCallsCorrectnessTest, - testing::Combine( + INSTANTIATE_TEST_SUITE_P(GroupCallsCorrectnessSweep, + GroupCallsCorrectnessTest, + testing::Combine( // Reduction operator (not used) testing::Values(ncclSum), // Data types @@ -116,5 +116,6 @@ namespace CorrectnessTests testing::Values(2,3,4,5,6,7,8), // In-place or not testing::Values(false, true), - testing::Values(""))); + testing::Values("")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_Reduce.cpp b/test/test_Reduce.cpp index 59dac111f9..5405f3e0fc 100644 --- a/test/test_Reduce.cpp +++ b/test/test_Reduce.cpp @@ -44,9 +44,9 @@ namespace CorrectnessTests dataset.Release(); } - INSTANTIATE_TEST_CASE_P(ReduceCorrectnessSweep, - ReduceCorrectnessTest, - testing::Combine( + INSTANTIATE_TEST_SUITE_P(ReduceCorrectnessSweep, + ReduceCorrectnessTest, + testing::Combine( // Reduction operator testing::Values(ncclSum, ncclProd, ncclMax, ncclMin), // Data types @@ -66,5 +66,6 @@ namespace CorrectnessTests testing::Values(2,3,4,5,6,7,8), // In-place or not testing::Values(false, true), - testing::Values(""))); + testing::Values("")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_ReduceScatter.cpp b/test/test_ReduceScatter.cpp index ab4dc08860..26e62170ff 100644 --- a/test/test_ReduceScatter.cpp +++ b/test/test_ReduceScatter.cpp @@ -42,9 +42,9 @@ namespace CorrectnessTests dataset.Release(); } - INSTANTIATE_TEST_CASE_P(ReduceScatterCorrectnessSweep, - ReduceScatterCorrectnessTest, - testing::Combine( + INSTANTIATE_TEST_SUITE_P(ReduceScatterCorrectnessSweep, + ReduceScatterCorrectnessTest, + testing::Combine( // Reduction operator testing::Values(ncclSum, ncclProd, ncclMax, ncclMin), // Data types @@ -64,5 +64,6 @@ namespace CorrectnessTests testing::Values(2,3,4,5,6,7,8), // In-place or not testing::Values(false, true), - testing::Values(""))); + testing::Values("")), + CorrectnessTest::PrintToStringParamName()); } // namespace diff --git a/test/test_Scatter.cpp b/test/test_Scatter.cpp index 80ac6e534c..78cfa01ec3 100644 --- a/test/test_Scatter.cpp +++ b/test/test_Scatter.cpp @@ -44,7 +44,7 @@ namespace CorrectnessTests dataset.Release(); } - INSTANTIATE_TEST_CASE_P(ScatterCorrectnessSweep, + INSTANTIATE_TEST_SUITE_P(ScatterCorrectnessSweep, ScatterCorrectnessTest, testing::Combine( // Reduction operator is not used @@ -66,5 +66,6 @@ namespace CorrectnessTests testing::Values(2,3,4,5,6,7,8), // In-place or not testing::Values(false), - testing::Values("RCCL_ALLTOALL_KERNEL_DISABLE=0", "RCCL_ALLTOALL_KERNEL_DISABLE=1"))); + testing::Values("RCCL_ALLTOALL_KERNEL_DISABLE=0", "RCCL_ALLTOALL_KERNEL_DISABLE=1")), + CorrectnessTest::PrintToStringParamName()); } // namespace