Skip to content

Commit 448c673

Browse files
pruthvistonysaadrahim
authored andcommitted
rocRAND changes to support multiple ROCM installation (#105)
- New mode of building is added "-r,--relocatable" which is used for ROCm stack installed in /opt/rocm-ver. - Below CMAKE parameters are set/overwritten in above mode CMAKE_INSTALL_PREFIX CMAKE_PREFIX_PATH CMAKE_SHARED_LINKER_FLAGS CMAKE_MODULE_PATH ROCM_DISABLE_LDCONFIG Signed-off-by: Pruthvi Madugundu <[email protected]>
1 parent b9f838b commit 448c673

File tree

2 files changed

+36
-13
lines changed

2 files changed

+36
-13
lines changed

cmake/Common.cmake

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#
2+
set(ROCM_DISABLE_LDCONFIG OFF CACHE BOOL "")
3+
24
function(package_set_postinst_prerm LIB_NAMES LIB_DIRS INCLUDE_DIRS)
35
list(LENGTH LIB_NAMES len1)
46
list(LENGTH LIB_DIRS len2)
@@ -18,7 +20,9 @@ function(package_set_postinst_prerm LIB_NAMES LIB_DIRS INCLUDE_DIRS)
1820

1921
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nmkdir -p ${inc_dir}/../../include/")
2022
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nmkdir -p ${lib_dir}/../../lib/cmake/${lib_name}")
21-
set(POSTINST_SOURCE "${POSTINST_SOURCE}\necho \"${lib_dir}\" > /etc/ld.so.conf.d/${lib_name}.conf")
23+
if(NOT ${ROCM_DISABLE_LDCONFIG})
24+
set(POSTINST_SOURCE "${POSTINST_SOURCE}\necho \"${lib_dir}\" > /etc/ld.so.conf.d/${lib_name}.conf")
25+
endif()
2226
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nln -sr ${inc_dir} ${inc_dir}/../../include/${lib_name}")
2327
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nln -sr ${lib_dir}/lib${lib_name}.so ${lib_dir}/../../lib/lib${lib_name}.so")
2428
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nln -sr ${lib_dir}/cmake/${lib_name} ${lib_dir}/../../lib/cmake/${lib_name}\n")

install

+31-12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ function display_help()
1111
echo " [-h|--help] prints this help message"
1212
echo " [-i|--install] install after build"
1313
echo " [-p|--package] build package"
14+
echo " [-r]--relocatable] create a package to support relocatable ROCm"
1415
#Not implemented yet
1516
# echo " [-d|--dependencies] install build dependencies"
1617
echo " [-c|--clients] build library clients too (combines with -i & -d)"
@@ -28,15 +29,17 @@ build_clients=false
2829
build_release=true
2930
run_tests=false
3031
build_hip_clang=false
31-
rocm_path=/opt/rocm/bin
32+
rocm_path=/opt/rocm
33+
build_relocatable=false
34+
3235
# #################################################
3336
# Parameter parsing
3437
# #################################################
3538

3639
# check if we have a modern version of getopt that can handle whitespace and long parameters
3740
getopt -T
3841
if [[ $? -eq 4 ]]; then
39-
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,clients,debug,hip-clang,test,package --options hicdtp -- "$@")
42+
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,install,clients,debug,hip-clang,test,package,relocatable --options hicdtpr -- "$@")
4043
else
4144
echo "Need a new version of getopt"
4245
exit 1
@@ -62,6 +65,9 @@ while true; do
6265
-p|--package)
6366
build_package=true
6467
shift ;;
68+
-r|--relocatable)
69+
build_relocatable=true
70+
shift ;;
6571
-c|--clients)
6672
build_clients=true
6773
shift ;;
@@ -81,6 +87,16 @@ while true; do
8187
esac
8288
done
8389

90+
if [[ "${build_relocatable}" == true ]]; then
91+
if ! [ -z ${ROCM_PATH+x} ]; then
92+
rocm_path=${ROCM_PATH}
93+
fi
94+
95+
rocm_rpath=" -Wl,--enable-new-dtags -Wl,--rpath,/opt/rocm/lib:/opt/rocm/lib64"
96+
if ! [ -z ${ROCM_RPATH+x} ]; then
97+
rocm_rpath=" -Wl,--enable-new-dtags -Wl,--rpath,${ROCM_RPATH}"
98+
fi
99+
fi
84100

85101
# Instal the pre-commit hook
86102
#bash .githooks/install
@@ -111,19 +127,22 @@ if ($build_hip_clang); then
111127
fi
112128

113129
if [ -e /etc/redhat-release ] ; then
114-
distro='centos'
130+
cmake_executable="cmake3"
115131
else
116-
distro='ubuntu'
132+
cmake_executable="cmake"
117133
fi
118134

119-
case "$distro" in
120-
centos)
121-
CXX=$rocm_path/$compiler cmake3 -DBUILD_BENCHMARK=ON ../../. # or cmake-gui ../.
122-
;;
123-
ubuntu)
124-
CXX=$rocm_path/$compiler cmake -DBUILD_BENCHMARK=ON ../../. # or cmake-gui ../.
125-
;;
126-
esac
135+
if [[ "${build_relocatable}" == true ]]; then
136+
CXX=${rocm_path}/bin/$compiler ${cmake_executable} -DCMAKE_INSTALL_PREFIX=${rocm_path} \
137+
-DBUILD_TEST=ON -DBUILD_BENCHMARK=ON -DBUILD_CRUSH_TEST=ON -DDEPENDENCIES_FORCE_DOWNLOAD=ON \
138+
-DCMAKE_PREFIX_PATH="${rocm_path} ${rocm_path}/hcc ${rocm_path}/hip" \
139+
-DCMAKE_SHARED_LINKER_FLAGS=${rocm_rpath} \
140+
-DROCM_DISABLE_LDCONFIG=ON \
141+
-DCMAKE_MODULE_PATH="${rocm_path}/hip/cmake" \
142+
../../. # or cmake-gui ../.
143+
else
144+
CXX=${rocm_path}/bin/$compiler ${cmake_executable} -DBUILD_BENCHMARK=ON ../../. # or cmake-gui ../.
145+
fi
127146

128147
# Build
129148
make -j$(nproc)

0 commit comments

Comments
 (0)