1 Star 0 Fork 0

Ernest/rocRAND

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
install 4.29 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/bash
# #################################################
# helper functions
# #################################################
function display_help()
{
echo "rocRAND build & installation helper script"
echo "./install [-h|--help] "
echo " [-h|--help] prints this help message"
echo " [-i|--install] install after build"
echo " [-p|--package] build package"
echo " [-r]--relocatable] create a package to support relocatable ROCm"
#Not implemented yet
# echo " [-d|--dependencies] install build dependencies"
echo " [-c|--clients] build library clients too (combines with -i & -d)"
echo " [-g|--debug] -DCMAKE_BUILD_TYPE=Debug (default is =Release)"
echo " [--hip-clang] build library for amdgpu backend using hip-clang"
}
# #################################################
# global variables
# #################################################
install_package=false
build_package=false
build_clients=false
build_release=true
run_tests=false
build_hip_clang=false
rocm_path=/opt/rocm
build_relocatable=false
# #################################################
# Parameter parsing
# #################################################
# 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,clients,debug,hip-clang,test,package,relocatable --options hicdtpr -- "$@")
else
echo "Need a new version of getopt"
exit 1
fi
if [[ $? -ne 0 ]]; then
echo "getopt invocation failed; could not parse the command line";
exit 1
fi
eval set -- "${GETOPT_PARSE}"
check_exit_code( )
{
if (( $1 != 0 )); then
exit $1
fi
}
while true; do
case "${1}" in
-h|--help)
display_help
exit 0
;;
-i|--install)
install_package=true
shift ;;
-p|--package)
build_package=true
shift ;;
-r|--relocatable)
build_relocatable=true
shift ;;
-c|--clients)
build_clients=true
shift ;;
-g|--debug)
build_release=false
shift ;;
-t|--test)
run_tests=true
shift ;;
--hip-clang)
build_hip_clang=true
shift ;;
--) shift ; break ;;
*) echo "Unexpected command line parameter received; aborting";
exit 1
;;
esac
done
if [[ "${build_relocatable}" == true ]]; then
if ! [ -z ${ROCM_PATH+x} ]; then
rocm_path=${ROCM_PATH}
fi
rocm_rpath=" -Wl,--enable-new-dtags -Wl,--rpath,/opt/rocm/lib:/opt/rocm/lib64"
if ! [ -z ${ROCM_RPATH+x} ]; then
rocm_rpath=" -Wl,--enable-new-dtags -Wl,--rpath,${ROCM_RPATH}"
fi
fi
# Instal the pre-commit hook
#bash .githooks/install
# Create and go to the build directory.
mkdir -p build; cd build
if ($build_release); then
mkdir -p release; cd release
else
mkdir -p debug; cd debug
fi
# Configure hipCUB, setup options for your system.
# Build options:
# BUILD_TEST - on by default,
# BUILD_BENCHMARK - off by default.
#
# ! IMPORTANT !
# On ROCm platform set C++ compiler to HIPCC. You can do it by adding 'CXX=<path-to-hcc>'
# before 'cmake' or setting cmake option 'CMAKE_CXX_COMPILER' to path to the HIPCC compiler.
#
compiler="hipcc"
if [ -e /etc/redhat-release ] ; then
cmake_executable="cmake3"
else
cmake_executable="cmake"
fi
if($build_clients); then
clients=" -DBUILD_TEST=ON -DBUILD_BENCHMARK=ON "
fi
if [[ "${build_relocatable}" == true ]]; then
CXX=${rocm_path}/bin/$compiler ${cmake_executable} -DCMAKE_INSTALL_PREFIX="${rocm_path}" \
-DBUILD_TEST=ON -DBUILD_BENCHMARK=ON -DBUILD_CRUSH_TEST=ON -DDEPENDENCIES_FORCE_DOWNLOAD=ON \
-DCMAKE_PREFIX_PATH="${rocm_path} ${rocm_path}/hcc ${rocm_path}/hip" \
-DCMAKE_SHARED_LINKER_FLAGS="${rocm_rpath}" \
-DROCM_DISABLE_LDCONFIG=ON \
-DCMAKE_MODULE_PATH="${rocm_path}/hip/cmake" \
../../. # or cmake-gui ../.
else
CXX=${rocm_path}/bin/$compiler ${cmake_executable} ${clients} ../../. # or cmake-gui ../.
fi
check_exit_code "$?"
# Build
make -j$(nproc)
check_exit_code "$?"
if ($run_tests); then
# Optionally, run tests if they're enabled.
ctest --output-on-failure
fi
if ($install_package); then
# Install
make install
check_exit_code "$?"
fi
if ($build_package); then
# Package
make package -j$(nproc)
check_exit_code "$?"
fi
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Ernest778/rocRAND.git
[email protected]:Ernest778/rocRAND.git
Ernest778
rocRAND
rocRAND
develop

搜索帮助