Skip to content

Commit 329a62a

Browse files
Fixing install script to actually install library when requested (ROCm#88)
* Fixing install script to actually install library when requested. Cleaning up unused code. Removing unused arguments from install script. Fixing weird whitespacing * Fixing install script to install to correct location /opt/rocm, now creates symlink in /opt/rocm/lib * Updates and corrections to README and install script
1 parent 840f871 commit 329a62a

File tree

2 files changed

+38
-39
lines changed

2 files changed

+38
-39
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ In addition, HC Direct Function call support needs to be present on your machine
2222
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.
2323

2424
* `./install.sh` -- builds library including unit tests
25-
* `./install.sh -i` -- builds and installs the library to /opt/rocm/rccl
25+
* `./install.sh -i` -- builds and installs the library to /opt/rocm/rccl; installation path can be changed with --prefix argument (see below.)
2626
* `./install.sh -h` -- shows help
2727
* `./install.sh -t` -- builds library including unit tests
28+
* `./install.sh -r` -- runs unit tests (must be already built)
29+
* `./install.sh -p` -- builds RCCL package
30+
* `./install.sh --prefix` -- specify custom path to install RCCL to (default:/opt/rocm)
2831

2932
## Manual build
3033
#### To build the library :

install.sh

+34-38
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,32 @@ function display_help()
99
echo "RCCL build & installation helper script"
1010
echo "./install [-h|--help] "
1111
echo " [-h|--help] prints this help message."
12+
echo " [-i|--install] install RCCL library (see --prefix argument below.)"
1213
echo " [-p|--package_build] Build RCCL package."
1314
echo " [-t|--tests_build] Build unit tests, but do not run."
1415
echo " [-r|--run_tests] Run unit tests (must be built already.)"
15-
echo " [--prefix] Specify custom directory to install RCCL to (default: /opt/rocm/rccl)."
16+
echo " [--prefix] Specify custom directory to install RCCL to (default: /opt/rocm)."
1617
}
1718

1819
# #################################################
1920
# global variables
2021
# #################################################
22+
default_path=/opt/rocm
2123
build_package=false
22-
install_prefix=/opt/rocm/rccl
24+
install_prefix=$default_path
2325
build_tests=false
2426
run_tests=false
25-
run_tests_only=false
2627
build_release=true
2728
install_library=false
29+
2830
# #################################################
2931
# Parameter parsing
3032
# #################################################
3133

3234
# check if we have a modern version of getopt that can handle whitespace and long parameters
3335
getopt -T
3436
if [[ $? -eq 4 ]]; then
35-
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,package_build_only,tests_build,run_tests,prefix: --options hptr -- "$@")
37+
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,package_build,tests_build,run_tests,prefix: --options hiptr -- "$@")
3638
else
3739
echo "Need a new version of getopt"
3840
exit 1
@@ -47,45 +49,42 @@ eval set -- "${GETOPT_PARSE}"
4749

4850
while true; do
4951
case "${1}" in
50-
-h|--help)
52+
-h|--help)
5153
display_help
5254
exit 0
5355
;;
54-
-i|--install)
55-
install_library=true
56-
shift ;;
57-
-p|--package_build)
58-
build_package=true
59-
shift ;;
60-
-t|--tests_build)
61-
build_tests=true
62-
shift ;;
63-
-r|--run_tests)
64-
run_tests=true
65-
shift ;;
56+
-i|--install)
57+
install_library=true
58+
shift ;;
59+
-p|--package_build)
60+
build_package=true
61+
shift ;;
62+
-t|--tests_build)
63+
build_tests=true
64+
shift ;;
65+
-r|--run_tests)
66+
run_tests=true
67+
shift ;;
6668
--prefix)
6769
install_prefix=${2}
6870
shift 2 ;;
69-
--) shift ; break ;;
70-
*) echo "Unexpected command line parameter received; aborting";
71-
exit 1
72-
;;
71+
--) shift ; break ;;
72+
*) echo "Unexpected command line parameter received; aborting";
73+
exit 1
74+
;;
7375
esac
7476
done
7577

76-
# Install the pre-commit hook
77-
#bash ./githooks/install
78-
7978
rocm_path=/opt/rocm/bin
80-
#build_dir=./build
79+
8180
# #################################################
8281
# prep
8382
# #################################################
8483
# ensure a clean build environment
8584
if [[ "${build_release}" == true ]]; then
86-
rm -rf ${build_dir}/release
85+
rm -rf build/release
8786
else
88-
rm -rf ${build_dir}/debug
87+
rm -rf build/debug
8988
fi
9089

9190

@@ -101,29 +100,26 @@ fi
101100

102101
# build type
103102
if [[ "${build_release}" == true ]]; then
104-
#mkdir -p ${build_dir}/release/clients && cd ${build_dir}/release
105103
cmake_common_options="${cmake_common_options} -DCMAKE_BUILD_TYPE=Release"
106104
else
107-
#mkdir -p ${build_dir}/debug/clients && cd ${build_dir}/debug
108105
cmake_common_options="${cmake_common_options} -DCMAKE_BUILD_TYPE=Debug"
109106
fi
110107

111-
112-
#if !($run_tests_only); then
113-
# cd build
114-
115108
if ($build_tests); then
116109
CXX=$rocm_path/hcc cmake -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=$install_prefix ../../.
117110
else
118111
CXX=$rocm_path/hcc cmake -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=$install_prefix ../../.
119112
fi
120113

121-
make -j$(nproc)
114+
if ($install_library); then
115+
make -j$(nproc) install
116+
else
117+
make -j$(nproc)
118+
fi
122119

123-
if ($build_package); then
124-
make package
125-
fi
126-
#fi
120+
if ($build_package); then
121+
make package
122+
fi
127123

128124
# Optionally, run tests if they're enabled.
129125
if ($run_tests); then

0 commit comments

Comments
 (0)