From 1e01bec0e90de564a4ca632cacb286aef6389f7e Mon Sep 17 00:00:00 2001 From: edoapra Date: Thu, 19 Oct 2023 22:38:18 -0700 Subject: [PATCH 1/9] updates for vendors flangs --- travis/build_env.sh | 8 ++++---- travis/nwchem.bashrc | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/travis/build_env.sh b/travis/build_env.sh index 40e67e7adf..95a521a6d8 100755 --- a/travis/build_env.sh +++ b/travis/build_env.sh @@ -222,15 +222,15 @@ if [[ "$os" == "Linux" ]]; then fi if [[ "$FC" == "flang" ]]; then if [[ "USE_AOMP" == "Y" ]]; then - aomp_major=16 - aomp_minor=0-3 + aomp_major=18 + aomp_minor=0-0 wget -nv https://github.com/ROCm-Developer-Tools/aomp/releases/download/rel_"$aomp_major"."$aomp_minor"/aomp_Ubuntu2004_"$aomp_major"."$aomp_minor"_amd64.deb $MYSUDO dpkg -i aomp_Ubuntu2004_"$aomp_major"."$aomp_minor"_amd64.deb export PATH=/usr/lib/aomp_"$aomp_major"."$aomp_minor"/bin/:$PATH export LD_LIBRARY_PATH=/usr/lib/aomp_"$aomp_major"."$aomp_minor"/lib:$LD_LIBRARY_PATH ls -lrt /usr/lib | grep aomp ||true else - aocc_version=4.0.0 + aocc_version=4.1.0 aocc_dir=aocc-compiler-${aocc_version} # curl -sS -LJO https://developer.amd.com/wordpress/media/files/${aocc_dir}.tar tries=0 ; until [ "$tries" -ge 10 ] ; do \ @@ -247,7 +247,7 @@ if [[ "$os" == "Linux" ]]; then fi if [[ "$FC" == "amdflang" ]]; then $MYSUDO apt-get install -y wget gnupg2 coreutils dialog tzdata - rocm_version=5.4.3 + rocm_version=5.7.1 tries=0 ; until [ "$tries" -ge 10 ] ; do \ wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | $MYSUDO apt-key add - \ && break ; \ diff --git a/travis/nwchem.bashrc b/travis/nwchem.bashrc index aa82708f49..d9da64b7b0 100644 --- a/travis/nwchem.bashrc +++ b/travis/nwchem.bashrc @@ -25,8 +25,8 @@ echo NWCHEM_TOP is $NWCHEM_TOP export USE_MPI=y if [[ "$FC" == "flang" ]]; then if [[ "USE_AOMP" == "Y" ]]; then - aomp_major=16 - aomp_minor=0-3 + aomp_major=18 + aomp_minor=0-0 export PATH=/usr/lib/aomp_"$aomp_major"."$aomp_minor"/bin/:$PATH export LD_LIBRARY_PATH=/usr/lib/aomp_"$aomp_major"."$aomp_minor"/lib:$LD_LIBRARY_PATH else From 836dbea74230f1f481ec8eff0026fd62fbf72172 Mon Sep 17 00:00:00 2001 From: edoapra Date: Thu, 19 Oct 2023 22:39:17 -0700 Subject: [PATCH 2/9] changed detection of FLANG_NEW --- src/config/makefile.h | 19 +++++++------------ src/geom/GNUmakefile | 2 +- src/inp/inp.F | 2 +- src/libext/openblas/build_openblas.sh | 11 +++-------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/config/makefile.h b/src/config/makefile.h index c4fcb63482..d5c255fd88 100644 --- a/src/config/makefile.h +++ b/src/config/makefile.h @@ -1,4 +1,5 @@ + # $Id$ # @@ -1321,8 +1322,7 @@ ifeq ($(TARGET),MACX64) USE_FLANG=1 endif ifeq ($(USE_FLANG),1) - FLANG_VERSION=$(shell $(FC) --version |head -1 | sed 's/^.*\(version\)//'|cut -d . -f 1) - FLANG_LT_16 = $(shell [ $(FLANG_VERSION) -lt 16 ] && echo true || echo false) + FLANG_NEW = $(shell [ $(shell $(FC) --help |head -1| cut -d " " -f 2 ) == flang ] && echo true || echo false) endif ifeq ($(_FC),gfortran) @@ -1344,8 +1344,7 @@ ifeq ($(TARGET),MACX64) ifeq ($(USE_FLANG),1) GNU_GE_4_6=true FOPTIONS+=-fno-backslash - DEFINES += -D__FLANG - ifeq ($(FLANG_LT_16),false) + ifeq ($(FLANG_NEW),true) # FOPTIONS+=-fstack-arrays endif else @@ -2098,13 +2097,11 @@ ifneq ($(TARGET),LINUX) endif ifeq ($(USE_FLANG),1) - FLANG_VERSION=$(shell $(FC) --version |head -1 | sed 's/^.*\(version\)//'|cut -d . -f 1) - FLANG_LT_16 = $(shell [ $(FLANG_VERSION) -lt 16 ] && echo true || echo false) + FLANG_NEW = $(shell [ $(shell $(FC) --help |head -1| cut -d " " -f 2 ) == flang ] && echo true || echo false) endif #@info -#@info flv $(FLANG_VERSION) -#@info FLANG_LT_16 $(FLANG_LT_16) +#@info FLANG_NEW $(FLANG_NEW) #@info ifeq ($(CC),clang) @@ -2220,7 +2217,7 @@ ifneq ($(TARGET),LINUX) FOPTIONS += -ffast-math #-Wunused endif ifeq ($(V),-1) - ifeq ($(FLANG_LT_16),true) + ifeq ($(FLANG_NEW),false) FOPTIONS += -w endif COPTIONS += -w @@ -2246,13 +2243,11 @@ ifneq ($(TARGET),LINUX) GNU_GE_4_6=true FOPTIONS+=-fno-backslash - ifeq ($(FLANG_LT_16),true) + ifeq ($(FLANG_NEW),false) FOPTIONS+=-mcmodel=medium COPTIONS+=-mcmodel=medium CFLAGS_FORGA = -mcmodel=medium FFLAGS_FORGA = -mcmodel=medium - else - DEFINES += -D__FLANG endif else GNUMAJOR=$(shell $(FC) -dM -E - < /dev/null 2> /dev/null | grep __GNUC__ |cut -c18-) diff --git a/src/geom/GNUmakefile b/src/geom/GNUmakefile index c08cee966d..87138624c1 100644 --- a/src/geom/GNUmakefile +++ b/src/geom/GNUmakefile @@ -15,7 +15,7 @@ include ../config/makefile.h include ../config/makelib.h - ifeq ($(FLANG_LT_16),false) + ifeq ($(FLANG_NEW),true) FOPTIONS += -fno-automatic endif ifeq ($(_FC),pgf90) diff --git a/src/inp/inp.F b/src/inp/inp.F index a5bc9a5325..56c54aa48a 100644 --- a/src/inp/inp.F +++ b/src/inp/inp.F @@ -15,7 +15,7 @@ block data inp_data data errmsg /' '/ data input_line /0/ data xblnk /' '/ -#if defined(CRAY) || defined(HPUX) || defined(WIN32) || defined(PSCALE) || defined(__FLANG) || ( __GNUC__ >= 4) || defined(FUJITSU) +#if defined(CRAY) || defined(HPUX) || defined(WIN32) || defined(PSCALE) || defined(__FLANG) || defined(__flang__) || ( __GNUC__ >= 4) || defined(FUJITSU) data xtab /' '/ ! Tab ... no backslash necessary #elif (defined(LINUX) || defined(MACX)) && !defined(PGLINUX) && !defined(XLFLINUX) &&!( __GNUC__ >= 4) data xtab /9/ ! Tab ... g77 has trouble with escape sequence diff --git a/src/libext/openblas/build_openblas.sh b/src/libext/openblas/build_openblas.sh index cf483bbb25..4b586f1f79 100755 --- a/src/libext/openblas/build_openblas.sh +++ b/src/libext/openblas/build_openblas.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +!/usr/bin/env bash #set -v arch=`uname -m` VERSION=0.3.24 @@ -152,12 +152,7 @@ elif [[ -n ${FC} ]] && [[ $(../../../config/strip_compiler.sh "${FC}") == "flan if [[ ${BLAS_SIZE} == 8 ]]; then LAPACK_FPFLAGS_VAL+=" -fdefault-integer-8" fi - FLANG_VERSION=$(${FC} --version |head -1 | sed 's/^.*\(version\)//'|cut -d . -f 1) - if [[ ${FLANG_VERSION} -lt 17 ]]; then - FLANG_GE_17="false" - else - FLANG_GE_17="true" - fi + FLANG_NEW = $( [ $( $({FC)} --help |head -1| cut -d " " -f 2 ) == flang ] && echo true || echo false) elif [[ "${_FC}" == "crayftn" ]] ; then # FORCETARGET+=' F_COMPILER=FLANG ' LAPACK_FPFLAGS_VAL=" -s integer64 -ef " @@ -260,7 +255,7 @@ echo output redirected to libext/openblas/OpenBLAS/openblas.log echo if [[ ${_FC} == xlf ]]; then $MYMAKE FC="xlf -qextname" $FORCETARGET LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL" INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=$MYNTS NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib $MAKEJ >& openblas.log -elif [[ ${FLANG_GE_17} == "true" ]]; then +elif [[ ${FLANG_NEW} == "true" ]]; then $MYMAKE FC=$FC CC=$CC HOSTCC=gcc $FORCETARGET FCOMMON_OPT="$LAPACK_FPFLAGS_VAL" LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL" INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=128 NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib $MAKEJ >& openblas.log else $MYMAKE FC=$FC CC=$CC HOSTCC=gcc $FORCETARGET LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL" INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=128 NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib $MAKEJ >& openblas.log From 9b6d9e460cd622158a2a7a134da8f5f475a720ee Mon Sep 17 00:00:00 2001 From: edoapra Date: Fri, 20 Oct 2023 08:58:25 -0700 Subject: [PATCH 3/9] write movecs warning only with print high --- src/nwdft/scf_dft/dft_scf.F | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nwdft/scf_dft/dft_scf.F b/src/nwdft/scf_dft/dft_scf.F index 0ff9eea384..c4ed784a52 100644 --- a/src/nwdft/scf_dft/dft_scf.F +++ b/src/nwdft/scf_dft/dft_scf.F @@ -893,7 +893,8 @@ logical function dft_scf(rtdb, Etold, Enuc, iVcoul_opt, iVxc_opt, & .true.) c check if movecs read has failed if(movecs_in_org.ne.movecs_in) then - if(ga_nodeid().eq.0) then + if(ga_nodeid().eq.0.and. + A util_print('movecs_info', print_high)) then write(luout,*) ' WARNING: movecs_in_org=', c movecs_in_org(1:inp_strlen(movecs_in_org)), c ' not equal to movecs_in=', From a7f7b5e36b53c68c1d55fcc33753366130263b95 Mon Sep 17 00:00:00 2001 From: edoapra Date: Fri, 20 Oct 2023 10:23:39 -0700 Subject: [PATCH 4/9] fix aocc install --- travis/build_env.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/travis/build_env.sh b/travis/build_env.sh index 95a521a6d8..12ad452c7a 100755 --- a/travis/build_env.sh +++ b/travis/build_env.sh @@ -230,15 +230,19 @@ if [[ "$os" == "Linux" ]]; then export LD_LIBRARY_PATH=/usr/lib/aomp_"$aomp_major"."$aomp_minor"/lib:$LD_LIBRARY_PATH ls -lrt /usr/lib | grep aomp ||true else - aocc_version=4.1.0 - aocc_dir=aocc-compiler-${aocc_version} + aocc_major=4 + aocc_minor=1 + aocc_patch=0 + aocc_version=${aocc_major}.${aocc_minor}.${aocc_patch} + aocc_dir=aocc-${aocc_major}-${aocc_minor} + aocc_file=aocc-compiler-${aocc_version} # curl -sS -LJO https://developer.amd.com/wordpress/media/files/${aocc_dir}.tar tries=0 ; until [ "$tries" -ge 10 ] ; do \ - curl -sS -LJO https://download.amd.com/developer/eula/aocc-compiler/${aocc_dir}.tar \ + curl -sS -LJO https://download.amd.com/developer/eula/aocc/${aocc_dir}/${aocc_file}.tar \ && break ; \ tries=$((tries+1)) ; echo attempt no. $tries ; sleep 30 ; done - tar xf ${aocc_dir}.tar - ./${aocc_dir}/install.sh + tar xf ${aocc_file}.tar + ./${aocc_file}/install.sh source setenv_AOCC.sh pwd fi From 2f8801b4d21839cdb2a673f13ef2858680e53d34 Mon Sep 17 00:00:00 2001 From: edoapra Date: Fri, 20 Oct 2023 10:24:49 -0700 Subject: [PATCH 5/9] fix FLANG_NEW detection --- src/libext/openblas/build_openblas.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libext/openblas/build_openblas.sh b/src/libext/openblas/build_openblas.sh index 4b586f1f79..4a5df859ab 100755 --- a/src/libext/openblas/build_openblas.sh +++ b/src/libext/openblas/build_openblas.sh @@ -1,4 +1,4 @@ -!/usr/bin/env bash +#!/usr/bin/env bash #set -v arch=`uname -m` VERSION=0.3.24 @@ -152,7 +152,7 @@ elif [[ -n ${FC} ]] && [[ $(../../../config/strip_compiler.sh "${FC}") == "flan if [[ ${BLAS_SIZE} == 8 ]]; then LAPACK_FPFLAGS_VAL+=" -fdefault-integer-8" fi - FLANG_NEW = $( [ $( $({FC)} --help |head -1| cut -d " " -f 2 ) == flang ] && echo true || echo false) + FLANG_NEW=$( [ $( ${FC} --help |head -1| cut -d " " -f 2 ) == flang ] && echo true || echo false) elif [[ "${_FC}" == "crayftn" ]] ; then # FORCETARGET+=' F_COMPILER=FLANG ' LAPACK_FPFLAGS_VAL=" -s integer64 -ef " @@ -256,6 +256,8 @@ echo if [[ ${_FC} == xlf ]]; then $MYMAKE FC="xlf -qextname" $FORCETARGET LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL" INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=$MYNTS NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib $MAKEJ >& openblas.log elif [[ ${FLANG_NEW} == "true" ]]; then + echo FLANG_NEW + echo $MYMAKE FC=$FC CC=$CC HOSTCC=gcc $FORCETARGET FCOMMON_OPT="$LAPACK_FPFLAGS_VAL" LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL" INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=128 NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD ="$THREADOPT" libs netlib $MAKEJ $MYMAKE FC=$FC CC=$CC HOSTCC=gcc $FORCETARGET FCOMMON_OPT="$LAPACK_FPFLAGS_VAL" LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL" INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=128 NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib $MAKEJ >& openblas.log else $MYMAKE FC=$FC CC=$CC HOSTCC=gcc $FORCETARGET LAPACK_FPFLAGS="$LAPACK_FPFLAGS_VAL" INTERFACE64="$sixty4_int" BINARY="$binary" NUM_THREADS=128 NO_CBLAS=1 NO_LAPACKE=1 DEBUG=0 USE_THREAD="$THREADOPT" libs netlib $MAKEJ >& openblas.log From 7f5ce1a0c2ae1bdddaa68ce4c17ca8f98d2daf50 Mon Sep 17 00:00:00 2001 From: edoapra Date: Fri, 20 Oct 2023 16:14:35 -0700 Subject: [PATCH 6/9] remove https://github.com/GlobalArrays/ga/commit/c9c174fbb52f68f0c72c9bbebd3ef88b976b7037 on Linux to avoid amdflang GA failures https://github.com/nwchemgit/nwchem/issues/171#issuecomment-1773473504 --- src/tools/autoconf_patch.sh | 16 ++++++++++++++++ src/tools/get-tools-github | 3 +++ 2 files changed, 19 insertions(+) create mode 100755 src/tools/autoconf_patch.sh diff --git a/src/tools/autoconf_patch.sh b/src/tools/autoconf_patch.sh new file mode 100755 index 0000000000..f2e431a113 --- /dev/null +++ b/src/tools/autoconf_patch.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +rm -f autoconf.patch +cat > autoconf.patch < Date: Fri, 20 Oct 2023 22:43:30 -0700 Subject: [PATCH 7/9] fix integer overflow on 32-bit archs resulting in n2_ccsd SIGFPE https://github.com/nwchemgit/nwchem/issues/864#issuecomment-1770549014 --- src/ccsd/ccsd_trpdrv.F | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ccsd/ccsd_trpdrv.F b/src/ccsd/ccsd_trpdrv.F index 4bbd9c9ec5..7128476a73 100644 --- a/src/ccsd/ccsd_trpdrv.F +++ b/src/ccsd/ccsd_trpdrv.F @@ -361,12 +361,15 @@ subroutine ccsd_getdjka(djka, integer av,klo,khi,j c integer k,l_kk,k_kk,lenk,start,end,iptr,i,startc + double precision mem_avail logical failed c start = 1 + (j-1)*nvir + (klo-1)*lnov end = (j-1)*nvir + (khi)*lnov lenk=end-start+1 - lenk=min(lenk,(ma_inquire_avail(MT_DBL)*66)/100) +c protect from integer overflowing on 32bit archs + mem_avail=0.66d0*dble(ma_inquire_avail(MT_DBL)) + lenk=min(lenk,int(mem_avail)) crestrict to 5M to avoid OOMs lenk=min(lenk,5000000) 1 continue From bce4c5cd857f62f5e03e69d7df6f3c5fe6378742 Mon Sep 17 00:00:00 2001 From: edoapra Date: Sat, 21 Oct 2023 16:15:44 -0700 Subject: [PATCH 8/9] trying to fix the DONTHAVEM64OPT jungle https://github.com/nwchemgit/nwchem/issues/864#issuecomment-1773779486 --- src/config/makefile.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/config/makefile.h b/src/config/makefile.h index d5c255fd88..33022f8083 100644 --- a/src/config/makefile.h +++ b/src/config/makefile.h @@ -2152,23 +2152,18 @@ ifneq ($(TARGET),LINUX) FOPTIMIZE = -O2 - ifeq ($(_CPU),aarch64) + ifeq ($(_CPU),$(findstring $(_CPU),aarch64 mips64 loongarch64 riscv64 alpha ia64 hppa)) DONTHAVEM64OPT=Y endif ifeq ($(_CPU),mips64) - DONTHAVEM64OPT=Y COPTIONS = -mabi=64 FOPTIONS = -mabi=64 FFLAGS_FORGA = -mabi=64 CFLAGS_FORGA = -mabi=64 endif - ifeq ($(_CPU),loongarch64) - DONTHAVEM64OPT=Y - endif ifeq ($(_CPU),riscv64) - DONTHAVEM64OPT=Y COPTIONS = -march=rv64gc -mabi=lp64d FOPTIONS = -march=rv64gc -mabi=lp64d FFLAGS_FORGA = -march=rv64gc -mabi=lp64d From 39afa0f731d902c52fa65875a020dbcb5f68981e Mon Sep 17 00:00:00 2001 From: edoapra Date: Sat, 21 Oct 2023 16:34:52 -0700 Subject: [PATCH 9/9] downgrading rocm from 5.7.1 to 5.6.1 because of nwpw compiler failures --- travis/build_env.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/build_env.sh b/travis/build_env.sh index 12ad452c7a..b4d7a783fa 100755 --- a/travis/build_env.sh +++ b/travis/build_env.sh @@ -251,7 +251,7 @@ if [[ "$os" == "Linux" ]]; then fi if [[ "$FC" == "amdflang" ]]; then $MYSUDO apt-get install -y wget gnupg2 coreutils dialog tzdata - rocm_version=5.7.1 + rocm_version=5.6.1 tries=0 ; until [ "$tries" -ge 10 ] ; do \ wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | $MYSUDO apt-key add - \ && break ; \