From 75eb6c851b82a77a52edd9c63bc0800a4f834b11 Mon Sep 17 00:00:00 2001 From: sfilippone Date: Thu, 20 Feb 2025 13:45:55 +0100 Subject: [PATCH] Fix handling of LLVM in configry --- configure | 58 +++++++++++++++++++++++++++++++++++++++------------- configure.ac | 56 +++++++++++++++++++++++++++++++++++++------------- 2 files changed, 86 insertions(+), 28 deletions(-) diff --git a/configure b/configure index 8b972b1a..b8eb2b97 100755 --- a/configure +++ b/configure @@ -3491,7 +3491,7 @@ ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5' ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_fc_compiler_gnu if test -n "$ac_tool_prefix"; then - for ac_prog in ftn xlf2003_r xlf2003 xlf95_r xlf95 xlf90 xlf pgf95 pgf90 flang-new ifort ifc nagfor gfortran + for ac_prog in ftn xlf2003_r xlf2003 xlf95_r xlf95 xlf90 xlf pgf95 pgf90 flang ifort ifc nagfor gfortran do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 @@ -3540,7 +3540,7 @@ fi fi if test -z "$FC"; then ac_ct_FC=$FC - for ac_prog in ftn xlf2003_r xlf2003 xlf95_r xlf95 xlf90 xlf pgf95 pgf90 flang-new ifort ifc nagfor gfortran + for ac_prog in ftn xlf2003_r xlf2003 xlf95_r xlf95 xlf90 xlf pgf95 pgf90 flang ifort ifc nagfor gfortran do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -6936,12 +6936,12 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test x"$psblas_cv_fc" == "x" ; then if eval "$MPIFC -qversion 2>&1 | grep XL 2>/dev/null" ; then - psblas_cv_fc="xlf" + psblas_cv_fc="xlf"; # Some configurations of the XLF want "-WF," prepended to -D.. flags. # TODO : discover the exact conditions when the usage of -WF is needed. psblas_cv_define_prepend="-WF," if eval "$MPIFC -qversion 2>&1 | grep -e\"Version: 10\.\" 2>/dev/null"; then - FDEFINES="$psblas_cv_define_prepend-DXLF_10 $FDEFINES" + FDEFINES="$psblas_cv_define_prepend-DXLF_10 $FDEFINES"; sed -e's/(0-9*).*/$1/p' fi # Note : there could be problems with old xlf compiler versions ( <10.1 ) @@ -6950,22 +6950,52 @@ if test x"$psblas_cv_fc" == "x" ; then elif eval "$MPIFC -V 2>&1 | grep Sun 2>/dev/null" ; then # Sun compiler detection - psblas_cv_fc="sun" - elif eval "$MPIFC --version 2>&1 | grep flang-new 2>/dev/null" ; then - # Portland group compiler detection - - psblas_cv_fc="flang" - psblas_cv_define_prepend="" + psblas_cv_fc="sun"; + elif eval "$MPIFC --version 2>&1 | grep flang-new 2>&1 1>/dev/null" ; then + # LLVM compiler + psblas_cv_fc="flang-new"; + psblas_flang_version=`flang-new --version |grep flang| sed -e 's/^ *flang.* version *//gi'`; + psblas_flang_shv=`flang-new --version |grep flang| sed -e 's/^ *flang.* version *//gi' | sed -e's/\./ /g' | awk '{print $1}'`; + psblas_cv_define_prepend=""; + FDEFINES="$psblas_cv_define_prepend-DFLANG $FDEFINES" + psblas_shvs=`echo $psblas_flang_shv|sed -e's/^0-9*//g'`; + if test x"$psblas_shvs" != x""; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Running with LLVM $psblas_flang_version ($psblas_flang_shv). " >&5 +printf "%s\n" "$as_me: Running with LLVM $psblas_flang_version ($psblas_flang_shv). " >&6;} + if (( $psblas_flang_shv < 20 )) ; then + as_fn_error $? "The minimum supported LLVM version is version 20, bailing out. " "$LINENO" 5 + else + psblas_cv_fc="flang"; + fi + else + as_fn_error $? "Unrecognized LLVM version. The minimum supported LLVM version is version 20, bailing out. " "$LINENO" 5 + fi + elif eval "$MPIFC --version 2>&1 | grep flang 2>&1 1>/dev/null" ; then + # LLVM compiler + psblas_flang_version=`flang --version |grep flang| sed -e 's/^ *flang.* version *//gi'`; + psblas_flang_shv=`flang --version |grep flang| sed -e 's/^ *flang.* version *//gi' | sed -e's/\./ /g' | awk '{print $1}'`; + psblas_cv_fc="flang"; + psblas_cv_define_prepend=""; FDEFINES="$psblas_cv_define_prepend-DFLANG $FDEFINES" + psblas_shvs=`echo $psblas_flang_shv|sed -e's/^0-9*//g'`; + if test x"$psblas_shvs" != x""; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Running with LLVM $psblas_flang_version ($psblas_flang_shv). " >&5 +printf "%s\n" "$as_me: Running with LLVM $psblas_flang_version ($psblas_flang_shv). " >&6;} + if (( $psblas_flang_shv < 20 )) ; then + as_fn_error $? "The minimum supported LLVM version is version 20, bailing out. " "$LINENO" 5 + fi + else + as_fn_error $? "Unrecognized LLVM version. The minimum supported LLVM version is version 20, bailing out. " "$LINENO" 5 + fi elif eval "$MPIFC -V 2>&1 | grep Intel.*Fortran.*Compiler 2>/dev/null" ; then # Intel compiler identification - psblas_cv_fc="ifc" + psblas_cv_fc="ifc"; elif eval "$MPIFC -v 2>&1 | grep NAG 2>/dev/null" ; then - psblas_cv_fc="nag" - FC="$MPIFC" + psblas_cv_fc="nag"; + FC="$MPIFC"; else - psblas_cv_fc="" + psblas_cv_fc=""; # unsupported MPI Fortran compiler { printf "%s\n" "$as_me:${as_lineno-$LINENO}: Unknown Fortran compiler, proceeding with fingers crossed !" >&5 printf "%s\n" "$as_me: Unknown Fortran compiler, proceeding with fingers crossed !" >&6;} diff --git a/configure.ac b/configure.ac index 54b2a012..04370c40 100755 --- a/configure.ac +++ b/configure.ac @@ -100,7 +100,7 @@ dnl We set our own FC flags, ignore those from AC_PROG_FC but not those from the dnl environment variable. Same for C dnl save_FCFLAGS="$FCFLAGS"; -AC_PROG_FC([ftn xlf2003_r xlf2003 xlf95_r xlf95 xlf90 xlf pgf95 pgf90 flang-new ifort ifc nagfor gfortran]) +AC_PROG_FC([ftn xlf2003_r xlf2003 xlf95_r xlf95 xlf90 xlf pgf95 pgf90 flang ifort ifc nagfor gfortran]) FCFLAGS="$save_FCFLAGS"; save_CFLAGS="$CFLAGS"; AC_PROG_CC([xlc pgcc clang icc gcc cc ]) @@ -235,12 +235,12 @@ PAC_CHECK_HAVE_CRAYFTN( if test x"$psblas_cv_fc" == "x" ; then if eval "$MPIFC -qversion 2>&1 | grep XL 2>/dev/null" ; then - psblas_cv_fc="xlf" + psblas_cv_fc="xlf"; # Some configurations of the XLF want "-WF," prepended to -D.. flags. # TODO : discover the exact conditions when the usage of -WF is needed. psblas_cv_define_prepend="-WF," if eval "$MPIFC -qversion 2>&1 | grep -e\"Version: 10\.\" 2>/dev/null"; then - FDEFINES="$psblas_cv_define_prepend-DXLF_10 $FDEFINES" + FDEFINES="$psblas_cv_define_prepend-DXLF_10 $FDEFINES"; sed -e's/([0-9]*).*/$1/p' fi # Note : there could be problems with old xlf compiler versions ( <10.1 ) @@ -249,22 +249,50 @@ if test x"$psblas_cv_fc" == "x" ; then elif eval "$MPIFC -V 2>&1 | grep Sun 2>/dev/null" ; then # Sun compiler detection - psblas_cv_fc="sun" - elif eval "$MPIFC --version 2>&1 | grep flang-new 2>/dev/null" ; then - # Portland group compiler detection - - psblas_cv_fc="flang" - psblas_cv_define_prepend="" - FDEFINES="$psblas_cv_define_prepend-DFLANG $FDEFINES" + psblas_cv_fc="sun"; + elif eval "$MPIFC --version 2>&1 | grep flang-new 2>&1 1>/dev/null" ; then + # LLVM compiler + psblas_cv_fc="flang-new"; + psblas_flang_version=`flang-new --version |grep flang| sed -e 's/^ *flang.* version *//gi'`; + psblas_flang_shv=`flang-new --version |grep flang| sed -e 's/^ *flang.* version *//gi' | sed -e's/\./ /g' | awk '{print $1}'`; + psblas_cv_define_prepend=""; + FDEFINES="$psblas_cv_define_prepend-DFLANG $FDEFINES" + psblas_shvs=`echo $psblas_flang_shv|sed -e's/[^0-9]*//g'`; + if test x"$psblas_shvs" != x""; then + AC_MSG_NOTICE([[Running with LLVM $psblas_flang_version ($psblas_flang_shv). ]]) + if (( $psblas_flang_shv < 20 )) ; then + AC_MSG_ERROR([[The minimum supported LLVM version is version 20, bailing out. ]]) + else + psblas_cv_fc="flang"; + fi + else + AC_MSG_ERROR([[Unrecognized LLVM version. The minimum supported LLVM version is version 20, bailing out. ]]) + fi + elif eval "$MPIFC --version 2>&1 | grep flang 2>&1 1>/dev/null" ; then + # LLVM compiler + psblas_flang_version=`flang --version |grep flang| sed -e 's/^ *flang.* version *//gi'`; + psblas_flang_shv=`flang --version |grep flang| sed -e 's/^ *flang.* version *//gi' | sed -e's/\./ /g' | awk '{print $1}'`; + psblas_cv_fc="flang"; + psblas_cv_define_prepend=""; + FDEFINES="$psblas_cv_define_prepend-DFLANG $FDEFINES" + psblas_shvs=`echo $psblas_flang_shv|sed -e's/[^0-9]*//g'`; + if test x"$psblas_shvs" != x""; then + AC_MSG_NOTICE([[Running with LLVM $psblas_flang_version ($psblas_flang_shv). ]]) + if (( $psblas_flang_shv < 20 )) ; then + AC_MSG_ERROR([[The minimum supported LLVM version is version 20, bailing out. ]]) + fi + else + AC_MSG_ERROR([[Unrecognized LLVM version. The minimum supported LLVM version is version 20, bailing out. ]]) + fi elif eval "$MPIFC -V 2>&1 | grep Intel.*Fortran.*Compiler 2>/dev/null" ; then # Intel compiler identification - psblas_cv_fc="ifc" + psblas_cv_fc="ifc"; elif eval "$MPIFC -v 2>&1 | grep NAG 2>/dev/null" ; then - psblas_cv_fc="nag" - FC="$MPIFC" + psblas_cv_fc="nag"; + FC="$MPIFC"; else - psblas_cv_fc="" + psblas_cv_fc=""; # unsupported MPI Fortran compiler AC_MSG_NOTICE([[Unknown Fortran compiler, proceeding with fingers crossed !]]) fi