From f48ae5c98dc3919ba44215567ac7f5d7e65dfcd9 Mon Sep 17 00:00:00 2001 From: Akila Premachandra Date: Fri, 23 Aug 2019 22:02:42 +0000 Subject: [PATCH] Added hip-clang options to install script, and openmp/pthread options to CMakeLists.txt --- Jenkinsfile | 23 +++++++++++------------ install.sh | 27 ++++++++++++++++++++++----- test/CMakeLists.txt | 9 +++++---- 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d07a0b8140..76c8293a27 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,7 +1,7 @@ #!/usr/bin/env groovy // Copyright (c) 2019 Advanced Micro Devices, Inc. All rights reserved. // This shared library is available at https://github.com/ROCmSoftwarePlatform/rccl -@Library('rocJenkins@noDocker') _ +@Library('rocJenkins') _ // This is file for internal AMD use. // If you are interested in running your own Jenkins, please raise a github issue for assistance. @@ -32,7 +32,7 @@ rcclCI: def rccl = new rocProject('rccl') // customize for project - rccl.paths.build_command = './install.sh -t' + rccl.paths.build_command = './install.sh' // Define test architectures, optional rocm version argument is available def nodes = new dockerNodes(['RCCL'], rccl) @@ -47,10 +47,10 @@ rcclCI: def command = """#!/usr/bin/env bash set -x cd ${project.paths.project_build_prefix} - LD_LIBRARY_PATH=/opt/rocm/hcc/lib CXX=${project.compiler.compiler_path} ${project.paths.build_command} + LD_LIBRARY_PATH=/opt/rocm/hcc/lib CXX= ${project.paths.build_command} -t --hip-clang """ - sh command + platform.runCommand(this,command) } def testCommand = @@ -59,11 +59,11 @@ rcclCI: def command = """#!/usr/bin/env bash set -x - cd ${project.paths.project_build_prefix}/build/release/test - HSA_FORCE_FINE_GRAIN_PCIE=1 ./UnitTests --gtest_output=xml --gtest_color=yes + cd ${project.paths.project_build_prefix} + ${project.paths.project_build_prefix} -r --hip-clang """ - sh command + platform.runCommand(this,command) //junit "${project.paths.project_build_prefix}/build/release/*.xml" } @@ -79,11 +79,10 @@ rcclCI: mv *.deb package/ sudo dpkg -i package/*.deb """ - - - //platform.archiveArtifacts(this, """${project.paths.project_build_prefix}/build/package/*.deb""") + platform.runCommand(this,command) + platform.archiveArtifacts(this, """${project.paths.project_build_prefix}/build/package/*.deb""") } - buildProjectNoDocker(rccl, formatCheck, nodes.dockerArray, compileCommand, testCommand, packageCommand) + buildProject(rccl, formatCheck, nodes.dockerArray, compileCommand, testCommand, packageCommand) -} \ No newline at end of file +} diff --git a/install.sh b/install.sh index 8f65c6e5cb..05a2a02c1f 100755 --- a/install.sh +++ b/install.sh @@ -13,6 +13,7 @@ function display_help() 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 " [--hip-clang] Build library using hip-clang compiler." echo " [--prefix] Specify custom directory to install RCCL to (default: /opt/rocm)." } @@ -26,6 +27,7 @@ build_tests=false run_tests=false build_release=true install_library=false +build_hip_clang=false # ################################################# # Parameter parsing @@ -34,7 +36,7 @@ install_library=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,prefix: --options hiptr -- "$@") + GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,package_build,tests_build,run_tests,hip-clang,prefix: --options hiptr -- "$@") else echo "Need a new version of getopt" exit 1 @@ -65,6 +67,9 @@ while true; do -r|--run_tests) run_tests=true shift ;; + --hip-clang) + build_hip_clang=true + shift ;; --prefix) install_prefix=${2} shift 2 ;; @@ -97,7 +102,6 @@ else mkdir -p debug; cd debug fi - # build type if [[ "${build_release}" == true ]]; then cmake_common_options="${cmake_common_options} -DCMAKE_BUILD_TYPE=Release" @@ -105,10 +109,23 @@ else cmake_common_options="${cmake_common_options} -DCMAKE_BUILD_TYPE=Debug" fi -if ($build_tests); then - CXX=$rocm_path/hcc cmake -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=$install_prefix ../../. +compiler=hcc +if [[ "${build_hip_clang}" == true ]]; then + compiler=hipcc +fi + +cmake_executable=cmake +if [[ -e /etc/redhat-release ]]; then + yum install chrpath libgomp + cmake_executable=cmake3 else - CXX=$rocm_path/hcc cmake -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$install_prefix ../../. + apt install chrpath libomp-dev +fi + +if ($build_tests); then + CXX=$rocm_path/$compiler $cmake_executable -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=$install_prefix ../../. +else + CXX=$rocm_path/$compiler $cmake_executable -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$install_prefix ../../. fi if ($install_library); then diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d8fef68c17..66236c2f18 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -11,10 +11,11 @@ if(BUILD_TESTS) endif() # OpenMP is used to drive GPUs (one per thread) - find_package(OpenMP REQUIRED) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") + if(EXISTS /etc/redhat-release) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp=libgomp -pthread") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -pthread") + endif() # Download and unpack googletest at configure time configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)