Skip to content

Commit

Permalink
rocFFT Changes to support multiple ROCM installation (#285)
Browse files Browse the repository at this point in the history
- 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
  CPACK_PACKAGING_INSTALL_PREFIX
  CMAKE_PREFIX_PATH
  CMAKE_SHARED_LINKER_FLAGS
  ROCM_DISABLE_LDCONFIG

Signed-off-by: Pruthvi Madugundu <mpruthvi@gmail.com>
Signed-off-by: Pruthvi Madugundu <pruthvi.madugundu@amd.com>

Conflicts:
	CMakeLists.txt

Co-authored-by: mpruthvikumar <mpruthvi@gmail.com>
  • Loading branch information
2 people authored and malcolmroberts committed Jan 7, 2020
1 parent 4b418ae commit bdb82c6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ elseif( CMAKE_CXX_COMPILER MATCHES ".*/hcc$" )
message( STATUS "HCC compiler set; ROCm backend selected" )
endif( )

# NOTE: workaround until hcc & hip cmake modules fixes symlink logic in their config files; remove when fixed
list( APPEND CMAKE_PREFIX_PATH /opt/rocm /opt/rocm/hcc /opt/rocm/hip )

# This finds the rocm-cmake project, and installs it if not found
# rocm-cmake contains common cmake code for rocm projects to help setup and install
set( PROJECT_EXTERN_DIR ${CMAKE_CURRENT_BINARY_DIR}/extern )
Expand Down
38 changes: 33 additions & 5 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function display_help()
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 " [-r]--relocatable] create a package to support relocatable ROCm"
echo " [--cuda] build library for cuda backend"
echo " [--hip-clang] build library for amdgpu backend using hip-clang"
}
Expand Down Expand Up @@ -268,6 +269,7 @@ install_prefix=rocfft-install
build_clients=false
build_cuda=false
build_release=true
build_relocatable=false

# #################################################
# Parameter parsing
Expand All @@ -276,7 +278,7 @@ build_release=true
# 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}" -o 'hidcg' --long 'help,install,clients,dependencies,debug,cuda,hip-clang,prefix:' --options hicgd -- "$@")
GETOPT_PARSE=$(getopt --name "${0}" -o 'hidcgr' --long 'help,install,clients,dependencies,debug,cuda,hip-clang,prefix:,relocatable' --options hicgdr -- "$@")
else
echo "Need a new version of getopt"
exit 1
Expand Down Expand Up @@ -304,6 +306,9 @@ while true; do
-c|--clients)
build_clients=true
shift ;;
-r|--relocatable)
build_relocatable=true
shift ;;
-g|--debug)
build_release=false
shift ;;
Expand Down Expand Up @@ -337,6 +342,18 @@ else
rm -rf ${build_dir}/debug
fi

if [[ "${build_relocatable}" == true ]]; then
rocm_path=/opt/rocm
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

# Default cmake executable is called cmake
cmake_executable=cmake

Expand Down Expand Up @@ -367,7 +384,11 @@ fi

# We append customary rocm path; if user provides custom rocm path in ${path}, our
# hard-coded path has lesser priority
export PATH=${PATH}:/opt/rocm/bin
if [[ "${build_relocatable}" == true ]]; then
export PATH=${rocm_path}/bin:${PATH}
else
export PATH=${PATH}:/opt/rocm/bin
fi

pushd .
# #################################################
Expand Down Expand Up @@ -403,10 +424,17 @@ fi
if [[ "${build_cuda}" == false ]]; then

# Build library with AMD toolchain because of existense of device kernels
if [[ "${build_clients}" == true ]]; then
CXX=${compiler} ${cmake_executable} ${cmake_common_options} ${cmake_client_options} -DCPACK_SET_DESTDIR=OFF -DCMAKE_INSTALL_PREFIX=${install_prefix} -DCPACK_PACKAGING_INSTALL_PREFIX=/opt/rocm ../..
if [[ "${build_clients}" == false ]]; then
cmake_client_options=" "
fi
if [[ "${build_relocatable}" == true ]]; then
CXX=${compiler} ${cmake_executable} ${cmake_common_options} ${cmake_client_options} -DCPACK_SET_DESTDIR=OFF -DCMAKE_INSTALL_PREFIX=${rocm_path} -DCPACK_PACKAGING_INSTALL_PREFIX=${rocm_path} \
-DCMAKE_PREFIX_PATH="${rocm_path} ${rocm_path}/hcc ${rocm_path}/hip" \
-DCMAKE_SHARED_LINKER_FLAGS=${rocm_rpath} \
-DROCM_DISABLE_LDCONFIG=ON \
../..
else
CXX=${compiler} ${cmake_executable} ${cmake_common_options} -DCPACK_SET_DESTDIR=OFF -DCMAKE_INSTALL_PREFIX=${install_prefix} -DCPACK_PACKAGING_INSTALL_PREFIX=/opt/rocm ../..
CXX=${compiler} ${cmake_executable} ${cmake_common_options} ${cmake_client_options} -DCPACK_SET_DESTDIR=OFF -DCMAKE_INSTALL_PREFIX=${install_prefix} -DCPACK_PACKAGING_INSTALL_PREFIX=/opt/rocm ../..
fi
check_exit_code
make -j$(nproc)
Expand Down

0 comments on commit bdb82c6

Please sign in to comment.