Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUILD: added support for amdclang-based build (#899) (v1.3.x) #906

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 45 additions & 24 deletions config/m4/rocm.m4
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,28 @@ AC_DEFUN([ROCM_BUILD_FLAGS],
# Parse value of ARG into appropriate LIBS, LDFLAGS, and
# CPPFLAGS variables.
AC_DEFUN([HIP_BUILD_FLAGS],
$4="-D__HIP_PLATFORM_AMD__ -I$1/include/hip -I$1/include"
$3="-L$1/lib"
$4="-D__HIP_PLATFORM_AMD__ -I$1/include/hip -I$1/include -I$1/llvm/include"
$3="-L$1/lib -L$1/llvm/lib"
$2="-lamdhip64"
)

# CHECK_ROCM_VERSION(HIP_VERSION_MAJOR, ROCM_VERSION_CONDITION)
# ----------------------------------------------------------
# Checks ROCm version and marks condition as 1 (TRUE) or 0 (FALSE)
AC_DEFUN([CHECK_ROCM_VERSION], [
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <${with_rocm}/include/hip/hip_version.h>
]], [[
#if HIP_VERSION_MAJOR >= $1
return 0;
#else
intr make+compilation_fail()
#endif
]])],
[$2=1],
[$2=0])
])

#
# Check for ROCm support
#
Expand Down Expand Up @@ -102,28 +119,25 @@ AS_IF([test "x$with_rocm" != "xno"],
LDFLAGS="$SAVE_LDFLAGS"
LIBS="$SAVE_LIBS"
#Check whether we run on ROCm 5.0 or higher
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <${with_rocm}/include/rocm_version.h>
]], [[
#if ROCM_VERSION_MAJOR >= 5
return 0;
#else
intr make+compilation_fail()
#endif
]])],
[ROCM_VERSION_50_OR_GREATER=1],
[ROCM_VERSION_50_OR_GREATER=0])
HIP_BUILD_FLAGS([$with_rocm], [HIP_LIBS], [HIP_LDFLAGS], [HIP_CPPFLAGS])
AC_MSG_CHECKING([if ROCm version is 5.0 or above])
if test "$ROCM_VERSION_50_OR_GREATER" = "1" ; then
# Check whether we run on ROCm 6.0 or higher
CHECK_ROCM_VERSION(6, ROCM_VERSION_60_OR_GREATER)
AC_MSG_CHECKING([if ROCm version is 6.0 or above])
if test "$ROCM_VERSION_60_OR_GREATER" = "1" ; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
HIP_CPPFLAGS="${HIP_CPPFLAGS} -I${with_rocm}/hip/include"
HIP_LDFLAGS="${HIP_LDFLAGS} -L${with_rocm}/hip/lib"
# Check whether we run on ROCm 5.0-5.7
CHECK_ROCM_VERSION(5, ROCM_VERSION_50_OR_GREATER)
AC_MSG_CHECKING([if ROCm version is 5.0 - 5.7])
if test "$ROCM_VERSION_50_OR_GREATER" = "1" ; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
HIP_CPPFLAGS="${HIP_CPPFLAGS} -I${with_rocm}/hip/include"
HIP_LDFLAGS="${HIP_LDFLAGS} -L${with_rocm}/hip/lib"
fi
fi
CPPFLAGS="$HIP_CPPFLAGS $CPPFLAGS"
Expand All @@ -142,10 +156,17 @@ intr make+compilation_fail()
LDFLAGS="$SAVE_LDFLAGS"
LIBS="$SAVE_LIBS"
AS_IF([test "x$hip_happy" = "xyes"],
[AC_PATH_PROG([HIPCC], [hipcc], [notfound], [$PATH:$with_rocm/bin])])
AS_IF([test "$HIPCC" = "notfound"], [hip_happy="no"])
if test "$ROCM_VERSION_60_OR_GREATER" = "1" ; then
AC_MSG_NOTICE([using amdclang as ROCm version is 6.0 or above])
AS_IF([test "x$hip_happy" = "xyes"],
[AC_PATH_PROG([HIPCC], [amdclang], [notfound], [$PATH:$with_rocm/bin])])
AS_IF([test "$HIPCC" = "notfound"], [hip_happy="no"])
else
AC_MSG_NOTICE([using hipcc as ROCm version is 3.7.0 to ROCm 5.7.1])
AS_IF([test "x$hip_happy" = "xyes"],
[AC_PATH_PROG([HIPCC], [hipcc], [notfound], [$PATH:$with_rocm/bin])])
AS_IF([test "$HIPCC" = "notfound"], [hip_happy="no"])
fi
AS_IF([test "x$hip_happy" = "xyes"],
[AC_DEFINE([HAVE_HIP], 1, [Enable HIP support])
Expand Down
10 changes: 8 additions & 2 deletions cuda_lt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,21 @@ local_npic_filepath="${local_npic_dir}${o_filename}"
mkdir -p $pic_dir

tmpcmd="${@:3}"
if [[ "$tmpcmd" == *"hipcc"* ]]; then
if [[ "$tmpcmd" == *"amdclang"* ]]; then
cmd="${@:3:2} -x hip -target x86_64-unknown-linux-gnu --offload-arch=gfx908:xnack- --offload-arch=gfx90a:xnack- --offload-arch=gfx90a:xnack+ --offload-arch=gfx940 --offload-arch=gfx941 --offload-arch=gfx942 --offload-arch=gfx1030 --offload-arch=gfx1100 --offload-arch=gfx1101 --offload-arch=gfx1102 --offload-arch=native ${@:5} -fPIC -o ${pic_filepath}"
elif [[ "$tmpcmd" == *"hipcc"* ]]; then
cmd="${@:3} -fPIC -o ${pic_filepath}"
else
cmd="${@:3} -Xcompiler -fPIC -o ${pic_filepath}"
fi
echo $cmd
$cmd

cmd="${@:3} -o ${npic_filepath}"
if [[ "$tmpcmd" == *"amdclang"* ]]; then
cmd="${@:3:2} -x hip -target x86_64-unknown-linux-gnu --offload-arch=gfx908:xnack- --offload-arch=gfx90a:xnack- --offload-arch=gfx90a:xnack+ --offload-arch=gfx940 --offload-arch=gfx941 --offload-arch=gfx942 --offload-arch=gfx1030 --offload-arch=gfx1100 --offload-arch=gfx1101 --offload-arch=gfx1102 --offload-arch=native ${@:5} -o ${npic_filepath}"
else
cmd="${@:3} -o ${npic_filepath}"
fi
echo $cmd
$cmd

Expand Down
Loading