diff --git a/config/m4/rocm.m4 b/config/m4/rocm.m4 index 356961939f..ab41d9da07 100644 --- a/config/m4/rocm.m4 +++ b/config/m4/rocm.m4 @@ -39,8 +39,8 @@ 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" ) @@ -102,11 +102,36 @@ AS_IF([test "x$with_rocm" != "xno"], LDFLAGS="$SAVE_LDFLAGS" LIBS="$SAVE_LIBS" + #Check whether we run on ROCm 6.0 or higher + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include <${with_rocm}/include/hip/hip_version.h> + ]], [[ +#if HIP_VERSION_MAJOR >= 6 +return 0; +#else +intr make+compilation_fail() +#endif + ]])], + [ROCM_VERSION_60_OR_GREATER=1], + [ROCM_VERSION_60_OR_GREATER=0]) + #Check whether we run on ROCm 5.0 or higher + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include <${with_rocm}/include/hip/hip_version.h> + ]], [[ +#if HIP_VERSION_MAJOR < 6 && HIP_VERSION_MAJOR >= 5 +return 0; +#else +intr make+compilation_fail() +#endif + ]])], + [ROCM_VERSION_50_OR_GREATER=1], + [ROCM_VERSION_50_OR_GREATER=0]) + AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <${with_rocm}/include/rocm_version.h> ]], [[ -#if ROCM_VERSION_MAJOR >= 5 +#if ROCM_VERSION_MAJOR < 6 && ROCM_VERSION_MAJOR >= 5 return 0; #else intr make+compilation_fail() @@ -117,13 +142,19 @@ intr make+compilation_fail() 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 + 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" + AC_MSG_CHECKING([if ROCm version is 5.0 or above]) + 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" @@ -142,10 +173,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 if 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 if 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]) diff --git a/cuda_lt.sh b/cuda_lt.sh index 68f9b5ff60..8ee28177c1 100755 --- a/cuda_lt.sh +++ b/cuda_lt.sh @@ -27,7 +27,9 @@ 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 ${@:5} -fPIC -o ${pic_filepath}" +elif [[ "$tmpcmd" == *"hipcc"* ]]; then cmd="${@:3} -fPIC -o ${pic_filepath}" else cmd="${@:3} -Xcompiler -fPIC -o ${pic_filepath}" @@ -35,7 +37,11 @@ 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 ${@:5} -o ${npic_filepath}" +else + cmd="${@:3} -o ${npic_filepath}" +fi echo $cmd $cmd