Skip to content

Commit 41b383a

Browse files
authored
[BUILD] Add options to install script for compiler and GPU targets (ROCm#121)
* [BUILD] Add options to install script for compiler and GPU targets * Fix GPU_TARGETS field and add option for custom ROCm path * Check for ROCM_PATH --------- Signed-off-by: nileshnegi <Nilesh.Negi@amd.com>
1 parent 5b27b96 commit 41b383a

File tree

2 files changed

+70
-28
lines changed

2 files changed

+70
-28
lines changed

‎install.sh‎

Lines changed: 69 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ function display_help()
1010
echo "./install [-h|--help] "
1111
echo " [-h|--help] Prints this help message."
1212
echo " [-m|--mpi] Build RCCL-tests with MPI support. (see --mpi_home below.)"
13-
echo " [--rccl_home] Specify custom path for RCCL installation (default: /opt/rocm/rccl)"
13+
echo " [-t|--test] Run unit-tests after building RCCL-Tests."
14+
echo " [--rocm_home] Specify custom path for ROCm installation (default: /opt/rocm)"
15+
echo " [--rccl_home] Specify custom path for RCCL installation (default: /opt/rocm)"
1416
echo " [--mpi_home] Specify path to your MPI installation."
17+
echo " [--hip_compiler] Specify path to HIP compiler (default: /opt/rocm/bin/amdclang++)"
18+
echo " [--gpu_targets] Specify GPU targets (default:gfx906,gfx908,gfx90a,gfx942,gfx950,gfx1030,gfx1100,gxf1101,gfx1102,gfx1200,gfx1201)"
1519
}
1620

1721
# #################################################
@@ -20,16 +24,20 @@ function display_help()
2024
run_tests=false
2125
build_release=true
2226
mpi_enabled=false
23-
rccl_dir=/opt/rocm/rccl
27+
rocm_dir=${ROCM_PATH}
28+
rccl_dir=${rocm_dir}
2429
mpi_dir=""
30+
hip_compiler=${rocm_dir}/bin/amdclang++
31+
gpu_targets=""
32+
2533
# #################################################
2634
# Parameter parsing
2735
# #################################################
2836

2937
# check if we have a modern version of getopt that can handle whitespace and long parameters
3038
getopt -T
3139
if [[ $? -eq 4 ]]; then
32-
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,mpi,test,rccl_home:,mpi_home: --options hmt -- "$@")
40+
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,mpi,test,rocm_home:,rccl_home:,mpi_home:,hip_compiler:,gpu_targets: --options hmt -- "$@")
3341
else
3442
echo "Need a new version of getopt"
3543
exit 1
@@ -44,28 +52,35 @@ eval set -- "${GETOPT_PARSE}"
4452

4553
while true; do
4654
case "${1}" in
47-
-h|--help)
48-
display_help
49-
exit 0
50-
;;
51-
-m|--mpi)
52-
mpi_enabled=true
53-
shift ;;
54-
-t|--test)
55-
run_tests=true
56-
shift ;;
57-
--rccl_home)
58-
rccl_dir=${2}
59-
shift 2 ;;
60-
--mpi_home)
61-
mpi_dir=${2}
62-
shift 2 ;;
63-
--) shift ; break ;;
64-
*) echo "Unexpected command line parameter received; aborting";
65-
exit 1
66-
;;
55+
-h|--help)
56+
display_help
57+
exit 0 ;;
58+
-m|--mpi)
59+
mpi_enabled=true
60+
shift ;;
61+
-t|--test)
62+
run_tests=true
63+
shift ;;
64+
--rocm_home)
65+
rocm_dir=${2}
66+
shift 2 ;;
67+
--rccl_home)
68+
rccl_dir=${2}
69+
shift 2 ;;
70+
--mpi_home)
71+
mpi_dir=${2}
72+
shift 2 ;;
73+
--hip_compiler)
74+
hip_compiler=${2}
75+
shift 2 ;;
76+
--gpu_targets)
77+
gpu_targets=${2}
78+
shift 2 ;;
79+
--) shift ; break ;;
80+
*) echo "Unexpected command line parameter received; aborting";
81+
exit 1 ;;
6782
esac
68-
done
83+
done
6984

7085
# throw error code after running a command in the install script
7186
check_exit_code( )
@@ -85,15 +100,42 @@ build_dir=./build
85100
# ensure a clean build environment
86101
rm -rf ${build_dir}
87102

103+
if [[ -n ${rocm_dir} ]]; then
104+
echo "ROCM_PATH does not exist at ${rocm_dir}. Defaulting to /opt/rocm"
105+
rocm_dir=/opt/rocm
106+
fi
107+
108+
if ! command -v ${hip_compiler} 2>&1 >/dev/null ; then
109+
echo "HIP Compiler does not exist at ${hip_compiler}. Please check the path."
110+
echo "Defaulting to /opt/rocm/bin/amdclang++"
111+
hip_compiler=${rocm_dir}/bin/amdclang++
112+
113+
if ! command -v ${hip_compiler} 2>&1 >/dev/null ; then
114+
echo "${hip_compiler} does not exist. Please be advised."
115+
echo "Defaulting to /opt/rocm/bin/hipcc"
116+
hip_compiler=${rocm_dir}/bin/hipcc
117+
118+
if ! command -v ${hip_compiler} 2>&1 >/dev/null ; then
119+
echo "${hip_compiler} does not exist!. Please check your ROCm installation."
120+
echo "Cannot proceed with building rccl-tests!"
121+
exit 1
122+
fi
123+
fi
124+
fi
125+
126+
if [[ -n ${gpu_targets} ]]; then
127+
GPU_TARGETS="GPU_TARGETS=${gpu_targets}"
128+
fi
129+
88130
if ($mpi_enabled); then
89131
if [[ ${mpi_dir} == "" ]]; then
90132
echo "MPI flag enabled but path to MPI installation not specified. See --mpi_home command line argument."
91133
exit 1
92134
else
93-
make NCCL_HOME=${rccl_dir} CUSTOM_RCCL_LIB=${rccl_dir}/lib/librccl.so MPI=1 MPI_HOME=${mpi_dir} -j$(nproc)
135+
make NCCL_HOME=${rccl_dir} CUSTOM_RCCL_LIB=${rccl_dir}/lib/librccl.so MPI=1 MPI_HOME=${mpi_dir} HIPCC=${hip_compiler} ${GPU_TARGETS} -j$(nproc)
94136
fi
95137
else
96-
make NCCL_HOME=${rccl_dir} CUSTOM_RCCL_LIB=${rccl_dir}/lib/librccl.so -j$(nproc)
138+
make NCCL_HOME=${rccl_dir} CUSTOM_RCCL_LIB=${rccl_dir}/lib/librccl.so HIP_COMPILER=${hip_compiler} ${GPU_TARGETS} -j$(nproc)
97139
fi
98140
check_exit_code "$?"
99141

@@ -102,6 +144,6 @@ if ($run_tests); then
102144
if ($mpi_enabled); then
103145
cd test; LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${rccl_dir}/lib:${mpi_dir}/lib PATH=$PATH:${mpi_dir}/bin python3 -m pytest
104146
else
105-
cd test; LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${rccl_dir}/lib python3 -m pytest
147+
cd test; LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${rccl_dir}/lib python3 -m pytest -k "not MPI"
106148
fi
107149
fi

‎src/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ DEBUG ?= 0
1313
NCCL_HOME ?= ""
1414
CUSTOM_RCCL_LIB ?= ""
1515

16-
HIPCC = $(ROCM_PATH)/bin/amdclang++
16+
HIPCC ?= $(ROCM_PATH)/bin/amdclang++
1717
HIPCONFIG = $(ROCM_PATH)/bin/hipconfig
1818
CXX = $(HIPCC)
1919

0 commit comments

Comments
 (0)