From a37c1e3b689e0a68d26ad28b55ecb390636b3cc9 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 8 Jan 2019 19:32:54 +0100 Subject: [PATCH 1/8] Remove duplicates in selection buffer --- src/cipsi/pt2_stoch_routines.irp.f | 5 +- src/cipsi/selection_buffer.irp.f | 110 ++++++++++++++++++++++++++++- 2 files changed, 111 insertions(+), 4 deletions(-) diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index 1e1d895d..b9a81fb6 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -125,7 +125,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) error(:) = 0.d0 else - N = max(N_in,1) + N = max(N_in,1) * N_states state_average_weight_save(:) = state_average_weight(:) call create_selection_buffer(N, N*2, b) ASSERT (associated(b%det)) @@ -253,8 +253,11 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) FREE pt2_stoch_istate if (N_in > 0) then + b%cur = min(N_in,b%cur) if (s2_eig) then call make_selection_buffer_s2(b) + else + call remove_duplicates_in_selection_buffer(b) endif call fill_H_apply_buffer_no_selection(b%cur,b%det,N_int,0) endif diff --git a/src/cipsi/selection_buffer.irp.f b/src/cipsi/selection_buffer.irp.f index f30f6e44..ff5037f5 100644 --- a/src/cipsi/selection_buffer.irp.f +++ b/src/cipsi/selection_buffer.irp.f @@ -10,7 +10,7 @@ subroutine create_selection_buffer(N, siz_, res) siz = max(siz_,1) double precision :: rss - double precision, external :: memory_of_double, memory_of_int + double precision, external :: memory_of_double rss = memory_of_double(siz)*(N_int*2+1) call check_mem(rss,irp_here) @@ -171,7 +171,7 @@ subroutine make_selection_buffer_s2(b) n_d = b%cur double precision :: rss - double precision, external :: memory_of_double, memory_of_int + double precision, external :: memory_of_double rss = (4*N_int+4)*memory_of_double(n_d) call check_mem(rss,irp_here) allocate(o(N_int,2,n_d), iorder(n_d), duplicate(n_d), bit_tmp(n_d), & @@ -294,8 +294,112 @@ subroutine make_selection_buffer_s2(b) if (k > n_d) exit enddo deallocate(o) - b%N = n_d b%cur = n_d + b%N = n_d +end + + + + +subroutine remove_duplicates_in_selection_buffer(b) + use selection_types + type(selection_buffer), intent(inout) :: b + + integer(bit_kind), allocatable :: o(:,:,:) + double precision, allocatable :: val(:) + + integer :: n_d + integer :: i,k,sze,n_alpha,j,n + logical :: dup + + ! Sort + integer, allocatable :: iorder(:) + integer*8, allocatable :: bit_tmp(:) + integer*8, external :: det_search_key + integer(bit_kind), allocatable :: tmp_array(:,:,:) + logical, allocatable :: duplicate(:) + + n_d = b%cur + logical :: found_duplicates + double precision :: rss + double precision, external :: memory_of_double + rss = (4*N_int+4)*memory_of_double(n_d) + call check_mem(rss,irp_here) + + found_duplicates = .False. + allocate(iorder(n_d), duplicate(n_d), bit_tmp(n_d), & + tmp_array(N_int,2,n_d), val(n_d) ) + + do i=1,n_d + iorder(i) = i + bit_tmp(i) = det_search_key(b%det(1,1,i),N_int) + enddo + + call i8sort(bit_tmp,iorder,n_d) + + do i=1,n_d + do k=1,N_int + tmp_array(k,1,i) = b%det(k,1,iorder(i)) + tmp_array(k,2,i) = b%det(k,2,iorder(i)) + enddo + val(i) = b%val(iorder(i)) + duplicate(i) = .False. + enddo + + ! Find duplicates + do i=1,n_d-1 + if (duplicate(i)) then + cycle + endif + j = i+1 + do while (bit_tmp(j)==bit_tmp(i)) + if (duplicate(j)) then + j+=1 + if (j>n_d) then + exit + endif + cycle + endif + dup = .True. + do k=1,N_int + if ( (tmp_array(k,1,i) /= tmp_array(k,1,j)) & + .or. (tmp_array(k,2,i) /= tmp_array(k,2,j)) ) then + dup = .False. + exit + endif + enddo + if (dup) then + duplicate(j) = .True. + found_duplicates = .True. + endif + j+=1 + if (j>n_d) then + exit + endif + enddo + enddo + + if (found_duplicates) then + + ! Copy filtered result + integer :: n_p + n_p=0 + do i=1,n_d + if (duplicate(i)) then + cycle + endif + n_p = n_p + 1 + do k=1,N_int + b%det(k,1,n_p) = tmp_array(k,1,i) + b%det(k,2,n_p) = tmp_array(k,2,i) + enddo + val(n_p) = val(i) + enddo + b%cur=n_p + b%N=n_p + + endif + end From 8199ec2b5cad79b0b36dfb6b7b4e7b0d0bdc69ba Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Tue, 8 Jan 2019 23:48:59 +0100 Subject: [PATCH 2/8] Updated quantum_package.rc --- .gitignore | 1 - config/gfortran.cfg | 2 +- config/gfortran_avx.cfg | 2 +- config/ifort.cfg | 2 +- config/ifort_avx.cfg | 63 +++++++++++++++++++++++++++++++++++++ config/ifort_avx_mpi.cfg | 64 ++++++++++++++++++++++++++++++++++++++ config/ifort_debug.cfg | 2 +- config/ifort_mpi.cfg | 1 - configure | 24 +++++++------- etc/.gitignore | 1 + etc/README.rst | 1 + etc/ezfio.rc | 15 +++++++++ etc/irpf90.rc | 8 +++++ etc/libraries.rc | 9 ++++++ etc/network.rc | 11 +++++++ etc/ninja.rc | 8 +++++ etc/ocaml.rc | 10 ++++++ etc/paths.rc | 41 ++++++++++++++++++++++++ quantum_package.rc | 19 +++++++++++ quantum_package.rc.default | 57 --------------------------------- 20 files changed, 265 insertions(+), 76 deletions(-) create mode 100644 config/ifort_avx.cfg create mode 100644 config/ifort_avx_mpi.cfg create mode 100644 etc/.gitignore create mode 100644 etc/README.rst create mode 100644 etc/ezfio.rc create mode 100644 etc/irpf90.rc create mode 100644 etc/libraries.rc create mode 100644 etc/network.rc create mode 100644 etc/ninja.rc create mode 100644 etc/ocaml.rc create mode 100644 etc/paths.rc create mode 100644 quantum_package.rc delete mode 100644 quantum_package.rc.default diff --git a/.gitignore b/.gitignore index 642381d3..096e385b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -quantum_package.rc config/ifort.cfg quantum_package_static.tar.gz build.ninja diff --git a/config/gfortran.cfg b/config/gfortran.cfg index 867f3eee..2ba8c38c 100644 --- a/config/gfortran.cfg +++ b/config/gfortran.cfg @@ -35,7 +35,7 @@ OPENMP : 1 ; Append OpenMP flags # -ffast-math and the Fortran-specific # -fno-protect-parens and -fstack-arrays. [OPT] -FCFLAGS : -Ofast +FCFLAGS : -Ofast -msse4.2 # Profiling flags ################# diff --git a/config/gfortran_avx.cfg b/config/gfortran_avx.cfg index 47c39602..98ccd01f 100644 --- a/config/gfortran_avx.cfg +++ b/config/gfortran_avx.cfg @@ -35,7 +35,7 @@ OPENMP : 1 ; Append OpenMP flags # -ffast-math and the Fortran-specific # -fno-protect-parens and -fstack-arrays. [OPT] -FCFLAGS : -Ofast +FCFLAGS : -Ofast -mavx # Profiling flags ################# diff --git a/config/ifort.cfg b/config/ifort.cfg index d40ba26c..e2755e2f 100644 --- a/config/ifort.cfg +++ b/config/ifort.cfg @@ -32,7 +32,7 @@ OPENMP : 1 ; Append OpenMP flags # [OPT] FC : -traceback -FCFLAGS : -xAVX -O2 -ip -ftz -g +FCFLAGS : -xSSE4.2 -O2 -ip -ftz -g # Profiling flags ################# diff --git a/config/ifort_avx.cfg b/config/ifort_avx.cfg new file mode 100644 index 00000000..9810dd33 --- /dev/null +++ b/config/ifort_avx.cfg @@ -0,0 +1,63 @@ +# Common flags +############## +# +# -mkl=[parallel|sequential] : Use the MKL library +# --ninja : Allow the utilisation of ninja. It is mandatory ! +# --align=32 : Align all provided arrays on a 32-byte boundary +# +[COMMON] +FC : ifort +LAPACK_LIB : -mkl=parallel +IRPF90 : irpf90 +IRPF90_FLAGS : --ninja --align=32 + +# Global options +################ +# +# 1 : Activate +# 0 : Deactivate +# +[OPTION] +MODE : OPT ; [ OPT | PROFILE | DEBUG ] : Chooses the section below +CACHE : 0 ; Enable cache_compile.py +OPENMP : 1 ; Append OpenMP flags + +# Optimization flags +#################### +# +# -xHost : Compile a binary optimized for the current architecture +# -O2 : O3 not better than O2. +# -ip : Inter-procedural optimizations +# -ftz : Flushes denormal results to zero +# +[OPT] +FC : -traceback +FCFLAGS : -xAVX -O2 -ip -ftz -g + +# Profiling flags +################# +# +[PROFILE] +FC : -p -g +FCFLAGS : -xSSE4.2 -O2 -ip -ftz + +# Debugging flags +################# +# +# -traceback : Activate backtrace on runtime +# -fpe0 : All floating point exaceptions +# -C : Checks uninitialized variables, array subscripts, etc... +# -g : Extra debugging information +# -xSSE2 : Valgrind needs a very simple x86 executable +# +[DEBUG] +FC : -g -traceback +FCFLAGS : -xSSE2 -C -fpe0 -implicitnone + +# OpenMP flags +################# +# +[OPENMP] +FC : -qopenmp +IRPF90_FLAGS : --openmp + diff --git a/config/ifort_avx_mpi.cfg b/config/ifort_avx_mpi.cfg new file mode 100644 index 00000000..682b847c --- /dev/null +++ b/config/ifort_avx_mpi.cfg @@ -0,0 +1,64 @@ +# Common flags +############## +# +# -mkl=[parallel|sequential] : Use the MKL library +# --ninja : Allow the utilisation of ninja. It is mandatory ! +# --align=32 : Align all provided arrays on a 32-byte boundary +# +[COMMON] +FC : mpiifort +LAPACK_LIB : -mkl=parallel +IRPF90 : irpf90 +IRPF90_FLAGS : --ninja --align=32 -DMPI + +# Global options +################ +# +# 1 : Activate +# 0 : Deactivate +# +[OPTION] +MODE : OPT ; [ OPT | PROFILE | DEBUG ] : Chooses the section below +CACHE : 0 ; Enable cache_compile.py +OPENMP : 1 ; Append OpenMP flags + +# Optimization flags +#################### +# +# -xHost : Compile a binary optimized for the current architecture +# -O2 : O3 not better than O2. +# -ip : Inter-procedural optimizations +# -ftz : Flushes denormal results to zero +# +[OPT] +FCFLAGS : -xAVX -O2 -ip -ftz -g -traceback + +# Profiling flags +################# +# +[PROFILE] +FC : -p -g +FCFLAGS : -xSSE4.2 -O2 -ip -ftz + + +# Debugging flags +################# +# +# -traceback : Activate backtrace on runtime +# -fpe0 : All floating point exaceptions +# -C : Checks uninitialized variables, array subscripts, etc... +# -g : Extra debugging information +# -xSSE2 : Valgrind needs a very simple x86 executable +# +[DEBUG] +FC : -g -traceback +FCFLAGS : -xSSE2 -C -fpe0 -implicitnone + + +# OpenMP flags +################# +# +[OPENMP] +FC : -qopenmp +IRPF90_FLAGS : --openmp + diff --git a/config/ifort_debug.cfg b/config/ifort_debug.cfg index eb2c3cc8..1392885e 100644 --- a/config/ifort_debug.cfg +++ b/config/ifort_debug.cfg @@ -32,7 +32,7 @@ OPENMP : 1 ; Append OpenMP flags # [OPT] FC : -traceback -FCFLAGS : -xAVX -O2 -ip -ftz -g +FCFLAGS : -xSSE4.2 -O2 -ip -ftz -g # Profiling flags diff --git a/config/ifort_mpi.cfg b/config/ifort_mpi.cfg index 99dfc0f2..530cbb1e 100644 --- a/config/ifort_mpi.cfg +++ b/config/ifort_mpi.cfg @@ -33,7 +33,6 @@ OPENMP : 1 ; Append OpenMP flags [OPT] FCFLAGS : -xSSE4.2 -O2 -ip -ftz -g -traceback -# !xAVX # Profiling flags ################# # diff --git a/configure b/configure index cb05d609..c6d3e7fb 100755 --- a/configure +++ b/configure @@ -3,6 +3,10 @@ # Quantum Package configuration script # +export QP_ROOT="$( cd "$(dirname "$0")" ; pwd -P )" +echo "QP_ROOT="$QP_ROOT + + help() { cat <, --config define a configuration file, in "${QP_ROOT}/config/". -h, --help print the help message - -i , --install install . Use at your own risk. + -i , --install install . Use at your own + risk: no support will be provided + for the installation of dependencies. Example: ./configure -c config/gfortran.cfg Note: - - Using different configuration files for installing dependencies and - compiling QP can improve the user experience. + - Users are encouraged to create their own configuration files instead of + modifying the existing ones. EOF exit @@ -54,20 +60,12 @@ done # Trim leading and trailing spaces PACKAGES=$(echo $PACKAGES | xargs) - - -sed "s!^export QP_ROOT=.*\$!export QP_ROOT=\"$PWD\"!" \ - quantum_package.rc.default > quantum_package.rc - -echo "quantum_package.rc created." +echo "export QP_ROOT=\"$QP_ROOT\"" > ${QP_ROOT}/etc/00.qp_root source quantum_package.rc - - - function fail() { echo "Please refer to INSTALL.rst to install the missing dependencies." exit 1 @@ -151,7 +149,7 @@ for PACKAGE in ${PACKAGES} ; do elif [[ ${PACKAGE} = irpf90 ]] ; then download \ - "https://gitlab.com/scemama/irpf90/-/archive/v1.7.3/irpf90-v1.7.3.tar.gz" \ + "https://gitlab.com/scemama/irpf90/-/archive/v1.7.4/irpf90-v1.7.4.tar.gz" \ "${QP_ROOT}"/external/irpf90.tar.gz ( cd "${QP_ROOT}"/external diff --git a/etc/.gitignore b/etc/.gitignore new file mode 100644 index 00000000..6fbf4389 --- /dev/null +++ b/etc/.gitignore @@ -0,0 +1 @@ +00.qp_root diff --git a/etc/README.rst b/etc/README.rst new file mode 100644 index 00000000..68d34c99 --- /dev/null +++ b/etc/README.rst @@ -0,0 +1 @@ +This directory contains all the files to be sourced when the |QP| environment is loaded. diff --git a/etc/ezfio.rc b/etc/ezfio.rc new file mode 100644 index 00000000..f92fec42 --- /dev/null +++ b/etc/ezfio.rc @@ -0,0 +1,15 @@ +if [[ -z $QP_EZFIO ]] +then + + export QP_EZFIO=${QP_ROOT}/external/ezfio + + if [[ $SHELL == "/bin/bash" ]] ; then + if [[ -f ${QP_EZFIO}/Bash/ezfio.sh ]]; then + source ${QP_EZFIO}/Bash/ezfio.sh + else + echo "EZFIO is not installed." + fi + fi + +fi + diff --git a/etc/irpf90.rc b/etc/irpf90.rc new file mode 100644 index 00000000..82f0e751 --- /dev/null +++ b/etc/irpf90.rc @@ -0,0 +1,8 @@ +export IRPF90=${QP_ROOT}/bin/irpf90 + +# Load irpman shell completion +( + irpman=$(tail -1 "${QP_ROOT}/bin/irpman" | cut --delimiter " " --field=2) + source $(dirname ${irpman})/../irpman-completions.bash +) + diff --git a/etc/libraries.rc b/etc/libraries.rc new file mode 100644 index 00000000..af90c1b0 --- /dev/null +++ b/etc/libraries.rc @@ -0,0 +1,9 @@ +if [[ -z $QP_LIB ]] +then +: + + # Include here the optional external libraries to link with your binaries, + # for example +# export QP_LIB="$QP_LIB -lint" + +fi diff --git a/etc/network.rc b/etc/network.rc new file mode 100644 index 00000000..e02594b7 --- /dev/null +++ b/etc/network.rc @@ -0,0 +1,11 @@ +if [[ -z $QP_NIC ]] +then +: + + # Choose the correct network interface if the default one is incorrect +# export QP_NIC=ib0 +# export QP_NIC=eth0 + +fi + + diff --git a/etc/ninja.rc b/etc/ninja.rc new file mode 100644 index 00000000..59a3e092 --- /dev/null +++ b/etc/ninja.rc @@ -0,0 +1,8 @@ +if [[ -z $NINJA ]] +then + + export NINJA=${QP_ROOT}/bin/ninja + +fi + + diff --git a/etc/ocaml.rc b/etc/ocaml.rc new file mode 100644 index 00000000..fb58ed39 --- /dev/null +++ b/etc/ocaml.rc @@ -0,0 +1,10 @@ +if [[ -z $OPAMROOT ]] +then + + # Comment these lines if you have a system-wide OCaml installation + export OPAMROOT=${OPAMROOT:-${QP_ROOT}/external/opam} + source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true + +fi + + diff --git a/etc/paths.rc b/etc/paths.rc new file mode 100644 index 00000000..3ab5b547 --- /dev/null +++ b/etc/paths.rc @@ -0,0 +1,41 @@ +if [[ -z $QP_PYTHON ]] +then + + # Load dependencies + for i in ezfio.rc irpf90.rc network.rc ninja.rc ocaml.rc + do + source $i + done + + + export QP_PYTHON=${QP_PYTHON}:${QP_EZFIO}/Python + export QP_PYTHON=${QP_PYTHON}:${QP_ROOT}/scripts + export QP_PYTHON=${QP_PYTHON}:${QP_ROOT}/scripts/ezfio_interface + export QP_PYTHON=${QP_PYTHON}:${QP_ROOT}/scripts/utility + export QP_PYTHON=${QP_PYTHON}:${QP_ROOT}/scripts/module + export QP_PYTHON=${QP_PYTHON}:${QP_ROOT}/scripts/compilation + export QP_PYTHON=${QP_PYTHON}:${QP_ROOT}/external/Python + export QP_PYTHON=${QP_PYTHON}:${QP_ROOT}/external/Python/resultsFile + + + function qp_prepend_export () { + eval "value_1="\${$1}"" + if [[ -z $value_1 ]] ; then + echo "${2}:" + else + echo "${2}:${value_1}" + fi + } + + export PYTHONPATH=$(qp_prepend_export "PYTHONPATH" "${QP_EZFIO}/Python":"${QP_PYTHON}") + + export PATH=$(qp_prepend_export "PATH" "${QP_PYTHON}":"${QP_ROOT}"/bin:"${QP_ROOT}"/ocaml) + + export LD_LIBRARY_PATH=$(qp_prepend_export "LD_LIBRARY_PATH" "${QP_ROOT}"/lib:"${QP_ROOT}"/lib64) + + export LIBRARY_PATH=$(qp_prepend_export "LIBRARY_PATH" "${QP_ROOT}"/lib:"${QP_ROOT}"/lib64) + + export C_INCLUDE_PATH=$(qp_prepend_export "C_INCLUDE_PATH" "${QP_ROOT}"/include) + +fi + diff --git a/quantum_package.rc b/quantum_package.rc new file mode 100644 index 00000000..5dd46920 --- /dev/null +++ b/quantum_package.rc @@ -0,0 +1,19 @@ +#!/bin/bash +# This script loads the Quantum Package environment. It should be invoked as +# source quantum_package.rc + +WD=$PWD +cd $QP_ROOT/etc +for SCRIPT in *.rc +do + source $SCRIPT +done +cd $WD + +if [[ -z ${QP_ROOT} ]] +then + echo The QP_ROOT environment variable is not set. Run + + ./configure -help + +fi diff --git a/quantum_package.rc.default b/quantum_package.rc.default deleted file mode 100644 index c94ec552..00000000 --- a/quantum_package.rc.default +++ /dev/null @@ -1,57 +0,0 @@ -# This line should contain the location of your quantum_package directory -export QP_ROOT= - -# Include here the optional external libraries to link with your binaries -# export QP_LIB=" -lint" - -#### BEGIN Don't modify - -export IRPF90=${QP_ROOT}/bin/irpf90 -export NINJA=${QP_ROOT}/bin/ninja -export QP_EZFIO=${QP_ROOT}/external/ezfio -export QP_PYTHON=${QP_ROOT}/scripts:${QP_ROOT}/scripts/ezfio_interface:${QP_ROOT}/scripts/utility:${QP_ROOT}/scripts/module:${QP_ROOT}/scripts/pseudo:${QP_ROOT}/scripts/compilation:${QP_EZFIO}/Python:${QP_ROOT}/external/Python:${QP_ROOT}/external/Python/resultsFile - -function qp_prepend_export () { -eval "value_1="\${$1}"" -if [[ -z $value_1 ]] ; then - echo "${2}:" -else - echo "${2}:${value_1}" -fi -} -export PYTHONPATH=$(qp_prepend_export "PYTHONPATH" "${QP_EZFIO}/Python":"${QP_PYTHON}") -export PATH=$(qp_prepend_export "PATH" "${QP_PYTHON}":"${QP_ROOT}"/bin:"${QP_ROOT}"/ocaml) -export LD_LIBRARY_PATH=$(qp_prepend_export "LD_LIBRARY_PATH" "${QP_ROOT}"/lib:"${QP_ROOT}"/lib64) -export LIBRARY_PATH=$(qp_prepend_export "LIBRARY_PATH" "${QP_ROOT}"/lib:"${QP_ROOT}"/lib64) -export C_INCLUDE_PATH=$(qp_prepend_export "C_INCLUDE_PATH" "${QP_ROOT}"/include) - -function qp() { - ezfio $@ -} - -# EZFIO completion -if [[ $SHELL == "/bin/bash" ]] ; then - if [[ -f ${QP_EZFIO}/Bash/ezfio.sh ]]; then - source ${QP_EZFIO}/Bash/ezfio.sh - else - echo "EZFIO is not installed." - fi -fi - - -#### END Don't modify - - - -# Choose the correct network interface if the default one is incorrect -# export QP_NIC=ib0 -# export QP_NIC=eth0 - - - -# Comment these lines if you have a system-wide OCaml installation -export OPAMROOT=${OPAMROOT:-${QP_ROOT}/external/opam} -source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true - - - From 76144c90d46ad81d77be1d34f6b1be37484fb068 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Jan 2019 00:55:22 +0100 Subject: [PATCH 3/8] Fixed rc --- quantum_package.rc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/quantum_package.rc b/quantum_package.rc index 5dd46920..84e56201 100644 --- a/quantum_package.rc +++ b/quantum_package.rc @@ -2,6 +2,17 @@ # This script loads the Quantum Package environment. It should be invoked as # source quantum_package.rc +QP_ROOT="/NOT/FOUND" +case "$(ps -p $$ -ocomm=)" in + zsh) + QP_ROOT=$(dirname $0) + ;; + bash) + QP_ROOT=$(dirname ${BASH_SOURCE}[0]) + ;; +esac +export QP_ROOT="$( cd $QP_ROOT ; pwd -P )" + WD=$PWD cd $QP_ROOT/etc for SCRIPT in *.rc From c5f03c90975275aa8c3a797daab7aac22458c1dd Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Jan 2019 01:04:07 +0100 Subject: [PATCH 4/8] configure -help --- configure | 2 +- quantum_package.rc | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/configure b/configure index c6d3e7fb..55e4db19 100755 --- a/configure +++ b/configure @@ -48,7 +48,7 @@ while : ; do -i|--install) PACKAGES="${PACKAGE} $2" shift;; - -h|--help) + -h|-help|--help) help;; *) echo "unknown option $1, try --help" diff --git a/quantum_package.rc b/quantum_package.rc index 84e56201..808fb8e0 100644 --- a/quantum_package.rc +++ b/quantum_package.rc @@ -2,6 +2,7 @@ # This script loads the Quantum Package environment. It should be invoked as # source quantum_package.rc + QP_ROOT="/NOT/FOUND" case "$(ps -p $$ -ocomm=)" in zsh) @@ -11,9 +12,13 @@ case "$(ps -p $$ -ocomm=)" in QP_ROOT=$(dirname ${BASH_SOURCE}[0]) ;; esac + export QP_ROOT="$( cd $QP_ROOT ; pwd -P )" + + WD=$PWD + cd $QP_ROOT/etc for SCRIPT in *.rc do @@ -21,10 +26,12 @@ do done cd $WD + + if [[ -z ${QP_ROOT} ]] then echo The QP_ROOT environment variable is not set. Run - ./configure -help + ./configure --help fi From 0c02733cde034ea9641c490e293c8975e0405571 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Jan 2019 01:09:59 +0100 Subject: [PATCH 5/8] Fixed ocaml.rc --- etc/ocaml.rc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/etc/ocaml.rc b/etc/ocaml.rc index fb58ed39..dd1bc127 100644 --- a/etc/ocaml.rc +++ b/etc/ocaml.rc @@ -2,9 +2,9 @@ if [[ -z $OPAMROOT ]] then # Comment these lines if you have a system-wide OCaml installation - export OPAMROOT=${OPAMROOT:-${QP_ROOT}/external/opam} - source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true + export OPAMROOT=${QP_ROOT}/external/opam fi +source ${OPAMROOT}/opam-init/init.sh > /dev/null 2> /dev/null || true From 4258a7a6f20bf13313472725d75e05166db89ebc Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Jan 2019 02:44:30 +0100 Subject: [PATCH 6/8] Added qpsh, the QP shell --- configure | 6 +- etc/ezfio.rc | 19 ++-- etc/libraries.rc | 9 +- etc/network.rc | 6 -- etc/ninja.rc | 9 +- etc/qp.rc | 157 ++++++++++++++++++++++++++++++ ocaml/qp_create_ezfio_from_xyz.ml | 2 +- qpsh | 11 +++ quantum_package.rc | 4 +- 9 files changed, 187 insertions(+), 36 deletions(-) create mode 100644 etc/qp.rc create mode 100755 qpsh diff --git a/configure b/configure index 55e4db19..62f58c48 100755 --- a/configure +++ b/configure @@ -378,10 +378,14 @@ echo " ||----w | " echo " || || " echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo "" -echo "Now:" +echo "Now, if you want to use the current shell," echo "" echo " source $QP_ROOT/quantum_package.rc" echo "" +echo "Or if you want to use a Bash shell adapted for QP:" +echo "" +echo " $QP_ROOT/qpsh" +echo "" diff --git a/etc/ezfio.rc b/etc/ezfio.rc index f92fec42..a75a8c9e 100644 --- a/etc/ezfio.rc +++ b/etc/ezfio.rc @@ -1,15 +1,10 @@ -if [[ -z $QP_EZFIO ]] -then - - export QP_EZFIO=${QP_ROOT}/external/ezfio - - if [[ $SHELL == "/bin/bash" ]] ; then - if [[ -f ${QP_EZFIO}/Bash/ezfio.sh ]]; then - source ${QP_EZFIO}/Bash/ezfio.sh - else - echo "EZFIO is not installed." - fi - fi +export QP_EZFIO=${QP_ROOT}/external/ezfio +if [[ -f ${QP_EZFIO}/Bash/ezfio.sh ]]; then + if [[ "$(ps -p $$ -ocomm=)" == "zsh" ]] ; then + autoload bashcompinit + bashcompinit + fi + source ${QP_EZFIO}/Bash/ezfio.sh fi diff --git a/etc/libraries.rc b/etc/libraries.rc index af90c1b0..c41daac1 100644 --- a/etc/libraries.rc +++ b/etc/libraries.rc @@ -1,9 +1,6 @@ -if [[ -z $QP_LIB ]] -then -: +QP_LIB="" - # Include here the optional external libraries to link with your binaries, - # for example +# Include here the optional external libraries to link with your binaries, +# for example : # export QP_LIB="$QP_LIB -lint" -fi diff --git a/etc/network.rc b/etc/network.rc index e02594b7..1fdb91ef 100644 --- a/etc/network.rc +++ b/etc/network.rc @@ -1,11 +1,5 @@ -if [[ -z $QP_NIC ]] -then -: - # Choose the correct network interface if the default one is incorrect # export QP_NIC=ib0 # export QP_NIC=eth0 -fi - diff --git a/etc/ninja.rc b/etc/ninja.rc index 59a3e092..6f717599 100644 --- a/etc/ninja.rc +++ b/etc/ninja.rc @@ -1,8 +1 @@ -if [[ -z $NINJA ]] -then - - export NINJA=${QP_ROOT}/bin/ninja - -fi - - +export NINJA=${QP_ROOT}/bin/ninja diff --git a/etc/qp.rc b/etc/qp.rc new file mode 100644 index 00000000..63104dc2 --- /dev/null +++ b/etc/qp.rc @@ -0,0 +1,157 @@ +if [[ "$(ps -p $$ -ocomm=)" == "zsh" ]] ; then + autoload bashcompinit + bashcompinit +fi + +source ${QP_ROOT}/etc/ezfio.rc + +function _qp_usage() +{ + echo " +Usage: + qp set_file EZFIO_DIRECTORY + qp unset_file + + qp has DIRECTORY ITEM + qp get DIRECTORY ITEM + qp set DIRECTORY ITEM VALUE : Scalar values + qp set DIRECTORY ITEM : Array values read from stdin + + qp run PROGRAM + qp srun PROGRAM + qp mpirun PROGRAM + + qp set_frozen_core + qp create_ezfio_from_xyz -help + qp set_mo_class -help +" +} + +function qp() +{ + case $1 in + "has"|"set"|"get"|"set_file"|"unset_file") + ezfio $@ + ;; + + "set_frozen_core") + shift + qp_set_frozen_core ${EZFIO_FILE} + ;; + + "create_ezfio_from_xyz") + shift + [[ -n $EZFIO_FILE ]] && ezfio unset_file + NAME=$(qp_create_ezfio_from_xyz $@) + ezfio set_file $NAME + ;; + + "set_mo_class") + shift + qp_set_mo_class ${EZFIO_FILE} $@ + ;; + + "edit") + shift + qp_edit ${EZFIO_FILE} + ;; + + "run") + shift + qp_run $@ ${EZFIO_FILE} + ;; + + "srun") + shift + qp_srun $@ ${EZFIO_FILE} + ;; + + "mpirun") + shift + qp_mpirun $@ ${EZFIO_FILE} + ;; + + *) + _qp_usage + ;; + esac + +} + + +_Complete() +{ + local cur + + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + prev2="${COMP_WORDS[COMP_CWORD-2]}" + + if [[ -n ${EZFIO_FILE} && -d ${EZFIO_FILE} ]] + then + + case "${prev2}" in + "set"|has|get) + if [[ ${prev} == "qp" ]] ; then + COMPREPLY=( $(compgen -W "set set_frozen_core set_mo_class" -- $cur ) ) + elif [[ ! -d ${EZFIO_FILE}/${prev} ]] ; then + COMPREPLY=( $(compgen -W "" -- $cur ) ) + else + COMPREPLY=( $(compgen -W "$(cd ${EZFIO_FILE}/${prev} ; ls | sed 's/\.gz//' )" -- $cur ) ) + fi + return 0 + ;; + *) + COMPREPLY=( $(compgen -W "$(\ls)" -- $cur ) ) + esac + + case "${prev}" in + run|srun|mpirun) + COMPREPLY=( $(compgen -W "$(cat ${QP_ROOT}/data/executables | cut -d ' ' -f 1)" -- $cur ) ) + return 0 + ;; + unset_file|edit|set_frozen_core) + COMPREPLY=() + return 0 + ;; + set_mo_class) + COMPREPLY=( $(compgen -W "-h -core -inact -act -virt -del" -- $cur ) ) + return 0 + ;; + set|has|get) + COMPREPLY=( $(compgen -W "$(cd ${EZFIO_FILE} ; \ls -d */ | sed 's|/||g')" -- $cur ) ) + return 0 + ;; + *) + COMPREPLY=( $(compgen -W 'has get set unset_file edit \ + run srun mpirun set_frozen_core \ + set_mo_class create_ezfio_from_xyz \ + -h' -- $cur ) ) + return 0 + ;; + esac + + else + + case "${prev}" in + set_file) + COMPREPLY=( $(compgen -W "$(\ls -d */ | sed 's|/||g')" -- ${cur} ) ) + return 0 + ;; + create_ezfio_from_xyz) + COMPREPLY=( $(compgen -W "$(\ls)" -- ${cur} ) ) + return 0 + ;; + *) + COMPREPLY=( $(compgen -W 'set_file \ + create_ezfio_from_xyz \ + -h' -- $cur ) ) + return 0 + ;; + esac + + fi +} + +complete -F _Complete qp diff --git a/ocaml/qp_create_ezfio_from_xyz.ml b/ocaml/qp_create_ezfio_from_xyz.ml index 13bcf7bf..4873c95b 100644 --- a/ocaml/qp_create_ezfio_from_xyz.ml +++ b/ocaml/qp_create_ezfio_from_xyz.ml @@ -660,7 +660,7 @@ let run ?o b au c d m p cart xyz_file = end; raise ex; end - in () + in print_endline ezfio_file diff --git a/qpsh b/qpsh new file mode 100755 index 00000000..bea64a09 --- /dev/null +++ b/qpsh @@ -0,0 +1,11 @@ +#!/bin/bash + +export QP_ROOT=$(dirname $0) + +exec bash --init-file <(cat << EOF +PS1="[\u@\h \W] |\\\${EZFIO_FILE}> " +source $QP_ROOT/quantum_package.rc +EOF +) + + diff --git a/quantum_package.rc b/quantum_package.rc index 808fb8e0..1c7ce73d 100644 --- a/quantum_package.rc +++ b/quantum_package.rc @@ -5,10 +5,10 @@ QP_ROOT="/NOT/FOUND" case "$(ps -p $$ -ocomm=)" in - zsh) + "zsh") QP_ROOT=$(dirname $0) ;; - bash) + *) QP_ROOT=$(dirname ${BASH_SOURCE}[0]) ;; esac From bd72bace4e891ad9f41b11c0ab591ef506585276 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Jan 2019 02:45:13 +0100 Subject: [PATCH 7/8] Doc --- TODO | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/TODO b/TODO index 33d47341..cfb152b5 100644 --- a/TODO +++ b/TODO @@ -43,13 +43,6 @@ Refaire les benchmarks -# Commande qp avec completion dans le shell -* qp set => ezfio set -* qp get => ezfio get -* qp run => qp_run -* qp srun => qp_run -* qp mpirun => qp_run -* qp edit => qp_edit -* qp set_mo_class => qp_set_mo_class -* qp set_frozen_core => qp_set_frozen_core +# Documentation de qpsh +# Documentation de /etc From a38b57ac34c3f5957358ea05ba22230f03df613d Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 9 Jan 2019 11:31:59 +0100 Subject: [PATCH 8/8] Better estimate of the PT2 memory --- etc/ezfio.rc | 2 + etc/irpf90.rc | 2 + etc/libraries.rc | 2 + etc/local.rc | 15 ++++++ etc/network.rc | 5 -- etc/ninja.rc | 2 + etc/ocaml.rc | 2 + etc/paths.rc | 2 + etc/qp.rc | 2 + src/cipsi/cipsi.irp.f | 3 ++ src/cipsi/pt2_stoch_routines.irp.f | 54 +++++++++++++++---- src/cipsi/stochastic_cipsi.irp.f | 3 ++ src/davidson/davidson_parallel.irp.f | 4 +- .../diagonalization_hs2_dressed.irp.f | 51 ++++++++++++++---- src/fci/environment.irp.f | 14 +++++ 15 files changed, 137 insertions(+), 26 deletions(-) create mode 100644 etc/local.rc delete mode 100644 etc/network.rc create mode 100644 src/fci/environment.irp.f diff --git a/etc/ezfio.rc b/etc/ezfio.rc index a75a8c9e..67a8a008 100644 --- a/etc/ezfio.rc +++ b/etc/ezfio.rc @@ -1,3 +1,5 @@ +# Configuration of EZFIO package + export QP_EZFIO=${QP_ROOT}/external/ezfio if [[ -f ${QP_EZFIO}/Bash/ezfio.sh ]]; then diff --git a/etc/irpf90.rc b/etc/irpf90.rc index 82f0e751..f5dbffae 100644 --- a/etc/irpf90.rc +++ b/etc/irpf90.rc @@ -1,3 +1,5 @@ +# Configuration of IRPF90 package + export IRPF90=${QP_ROOT}/bin/irpf90 # Load irpman shell completion diff --git a/etc/libraries.rc b/etc/libraries.rc index c41daac1..223322df 100644 --- a/etc/libraries.rc +++ b/etc/libraries.rc @@ -1,3 +1,5 @@ +# Configuration of additional libraries required for modules + QP_LIB="" # Include here the optional external libraries to link with your binaries, diff --git a/etc/local.rc b/etc/local.rc new file mode 100644 index 00000000..552e1a9b --- /dev/null +++ b/etc/local.rc @@ -0,0 +1,15 @@ +# Configuration specific to the local machine + +# Maximum allowed memory per node +# export QP_MAXMEM=64 + +# Target number of threads for Davidson's algorithm +# export QP_NTHREADS_DAVIDSON=32 + +# Target number of threads for the computation of the PT2 +# export QP_NTHREADS_PT2=32 + +# Name of the network interface to be chosen +# export QP_NIC=ib0 + + diff --git a/etc/network.rc b/etc/network.rc deleted file mode 100644 index 1fdb91ef..00000000 --- a/etc/network.rc +++ /dev/null @@ -1,5 +0,0 @@ - # Choose the correct network interface if the default one is incorrect -# export QP_NIC=ib0 -# export QP_NIC=eth0 - - diff --git a/etc/ninja.rc b/etc/ninja.rc index 6f717599..a5d5f4a9 100644 --- a/etc/ninja.rc +++ b/etc/ninja.rc @@ -1 +1,3 @@ +# Configuration for the Ninja package + export NINJA=${QP_ROOT}/bin/ninja diff --git a/etc/ocaml.rc b/etc/ocaml.rc index dd1bc127..1a1e5612 100644 --- a/etc/ocaml.rc +++ b/etc/ocaml.rc @@ -1,3 +1,5 @@ +# Configuration for the OCaml compiler + if [[ -z $OPAMROOT ]] then diff --git a/etc/paths.rc b/etc/paths.rc index 3ab5b547..33104af6 100644 --- a/etc/paths.rc +++ b/etc/paths.rc @@ -1,3 +1,5 @@ +# Configuration of all the paths to executables and libraries + if [[ -z $QP_PYTHON ]] then diff --git a/etc/qp.rc b/etc/qp.rc index 63104dc2..dcf9dc35 100644 --- a/etc/qp.rc +++ b/etc/qp.rc @@ -1,3 +1,5 @@ +# Configuration of the qp shell command + if [[ "$(ps -p $$ -ocomm=)" == "zsh" ]] ; then autoload bashcompinit bashcompinit diff --git a/src/cipsi/cipsi.irp.f b/src/cipsi/cipsi.irp.f index ecbab7c6..8e93297d 100644 --- a/src/cipsi/cipsi.irp.f +++ b/src/cipsi/cipsi.irp.f @@ -46,6 +46,9 @@ subroutine run_cipsi psi_coef = psi_coef_sorted N_det = N_det_max soft_touch N_det psi_det psi_coef + if (s2_eig) then + call make_s2_eigenfunction + endif call diagonalize_CI call save_wavefunction endif diff --git a/src/cipsi/pt2_stoch_routines.irp.f b/src/cipsi/pt2_stoch_routines.irp.f index b9a81fb6..e5774e1f 100644 --- a/src/cipsi/pt2_stoch_routines.irp.f +++ b/src/cipsi/pt2_stoch_routines.irp.f @@ -185,7 +185,7 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) ipos=1 do i= 1, N_det_generators do j=1,pt2_F(pt2_J(i)) - write(task(ipos:ipos+30),'(I9,1X,I9,1X,I9,''|'')') j, pt2_J(i), N + write(task(ipos:ipos+30),'(I9,1X,I9,1X,I9,''|'')') j, pt2_J(i), N_in ipos += 30 if (ipos > 300000-30) then if (add_task_to_taskserver(zmq_to_qp_run_socket,trim(task(1:ipos))) == -1) then @@ -213,15 +213,49 @@ subroutine ZMQ_pt2(E, pt2,relative_error, error, variance, norm, N_in) endif + double precision :: mem_collector, mem, rss + + call resident_memory(rss) + + mem_collector = 8.d0 * & ! bytes + ( 1.d0*pt2_n_tasks_max & ! task_id, index + + 0.635d0*N_det_generators & ! f,d + + 3.d0*N_det_generators*N_states & ! eI, vI, nI + + 3.d0*pt2_n_tasks_max*N_states & ! eI_task, vI_task, nI_task + + 4.d0*(pt2_N_teeth+1) & ! S, S2, T2, T3 + + 1.d0*(N_int*2.d0*N + N) & ! selection buffer + + 1.d0*(N_int*2.d0*N + N) & ! sort selection buffer + ) / 1024.d0**3 + integer :: nproc_target - nproc_target = nproc - double precision :: mem - mem = 8.d0 * N_det * (N_int * 2.d0 * 3.d0 + 3.d0 + 5.d0) / (1024.d0**3) - call write_double(6,mem,'Estimated memory/thread (Gb)') - if (qp_max_mem > 0) then - nproc_target = max(1,int(dble(qp_max_mem)/mem)) - nproc_target = min(nproc_target,nproc) - endif + nproc_target = nthreads_pt2 + + do + mem = mem_collector + & ! + nproc_target * 8.d0 * & ! bytes + ( 0.5d0*pt2_n_tasks_max & ! task_id + + 64.d0*pt2_n_tasks_max & ! task + + 3.d0*pt2_n_tasks_max*N_states & ! pt2, variance, norm + + 1.d0*pt2_n_tasks_max & ! i_generator, subset + + 2.d0*(N_int*2.d0*N_in + N_in) & ! selection buffers + + 1.d0*(N_int*2.d0*N_in + N_in) & ! sort/merge selection buffers + ) / 1024.d0**3 + + if (nproc_target == 0) then + call check_mem(mem,irp_here) + nproc_target = 1 + exit + endif + + if (mem+rss < qp_max_mem) then + exit + endif + + nproc_target = nproc_target - 1 + + enddo + call write_int(6,nproc_target,'Number of threads for PT2') + call write_double(6,mem,'Memory (Gb)') call omp_set_nested(.false.) @@ -329,6 +363,8 @@ subroutine pt2_collector(zmq_socket_pull, E, relative_error, pt2, error, & rss += memory_of_double(pt2_N_teeth+1)*4.d0 call check_mem(rss,irp_here) + ! If an allocation is added here, the estimate of the memory should also be + ! updated in ZMQ_pt2 allocate(task_id(pt2_n_tasks_max), index(pt2_n_tasks_max), f(N_det_generators)) allocate(d(N_det_generators+1)) allocate(eI(N_states, N_det_generators), eI_task(N_states, pt2_n_tasks_max)) diff --git a/src/cipsi/stochastic_cipsi.irp.f b/src/cipsi/stochastic_cipsi.irp.f index 64822dcd..59fb227c 100644 --- a/src/cipsi/stochastic_cipsi.irp.f +++ b/src/cipsi/stochastic_cipsi.irp.f @@ -48,6 +48,9 @@ subroutine run_stochastic_cipsi psi_coef = psi_coef_sorted N_det = N_det_max soft_touch N_det psi_det psi_coef + if (s2_eig) then + call make_s2_eigenfunction + endif call diagonalize_CI call save_wavefunction endif diff --git a/src/davidson/davidson_parallel.irp.f b/src/davidson/davidson_parallel.irp.f index 35ff6240..505393a8 100644 --- a/src/davidson/davidson_parallel.irp.f +++ b/src/davidson/davidson_parallel.irp.f @@ -452,10 +452,10 @@ BEGIN_PROVIDER [ integer, nthreads_davidson ] END_DOC nthreads_davidson = nproc character*(32) :: env - call getenv('NTHREADS_DAVIDSON',env) + call getenv('QP_NTHREADS_DAVIDSON',env) if (trim(env) /= '') then read(env,*) nthreads_davidson - call write_int(6,nthreads_davidson,'Number of threads for ') + call write_int(6,nthreads_davidson,'Target number of threads for ') endif END_PROVIDER diff --git a/src/davidson/diagonalization_hs2_dressed.irp.f b/src/davidson/diagonalization_hs2_dressed.irp.f index 52c31c2f..8faf0c0f 100644 --- a/src/davidson/diagonalization_hs2_dressed.irp.f +++ b/src/davidson/diagonalization_hs2_dressed.irp.f @@ -115,7 +115,7 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ integer :: iter2, itertot double precision, allocatable :: W(:,:), U(:,:), S(:,:), overlap(:,:) double precision, allocatable :: y(:,:), h(:,:), lambda(:), s2(:) - double precision, allocatable :: c(:), s_(:,:), s_tmp(:,:) + double precision, allocatable :: s_(:,:), s_tmp(:,:) double precision :: diag_h_mat_elem double precision, allocatable :: residual_norm(:) character*(16384) :: write_buffer @@ -137,6 +137,13 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ itermax = max(3,min(davidson_sze_max, sze/N_st_diag)) itertot = 0 + if (state_following) then + allocate(overlap(N_st_diag*itermax, N_st_diag*itermax)) + else + allocate(overlap(1,1)) ! avoid 'if' for deallocate + endif + overlap = 0.d0 + PROVIDE nuclear_repulsion expected_s2 psi_bilinear_matrix_order psi_bilinear_matrix_order_reverse call write_time(6) @@ -149,25 +156,51 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ call write_int(6,N_st,'Number of states') call write_int(6,N_st_diag,'Number of states in diagonalization') call write_int(6,sze,'Number of determinants') + + ! Find max number of cores to fit in memory + ! ----------------------------------------- + nproc_target = nproc double precision :: rss + integer :: maxab + maxab = max(N_det_alpha_unique, N_det_beta_unique)+1 + call resident_memory(rss) - r1 = 8.d0*(3.d0*dble(sze*N_st_diag*itermax+5.d0*(N_st_diag*itermax)**2 & - + 3.d0*(N_st_diag*itermax)+nproc*(4.d0*N_det_alpha_unique+2.d0*N_st_diag*sze)))/(1024.d0**3) - do while (r1+rss > qp_max_mem) - nproc_target = nproc_target - 1 - r1 = 8.d0*(3.d0*dble(sze*N_st_diag*itermax+5.d0*(N_st_diag*itermax)**2 & - + 3.d0*(N_st_diag*itermax)+nproc_target*(4.d0*N_det_alpha_unique+2.d0*N_st_diag*sze)))/(1024.d0**3) + do + r1 = 8.d0 * &! bytes + ( 3.d0*(dble(sze)*(N_st_diag*itermax)) &! W,U,S + + 4.d0*(N_st_diag*itermax)**2 &! h,y,s_,s_tmp + + 2.d0*(N_st_diag*itermax) &! s2,lambda + + 1.d0*(N_st_diag) &! residual_norm + ! In H_S2_u_0_nstates_zmq + + 3.d0*(N_st_diag*N_det) &! u_t, v_t, s_t on collector + + 3.d0*(N_st_diag*N_det) &! u_t, v_t, s_t on slave + + 0.5d0*maxab &! idx0 in H_S2_u_0_nstates_openmp_work_* + + nproc_target * &! In OMP section + ( 1.d0*(N_int*maxab) &! buffer + + 3.5d0*(maxab) ) &! singles_a, singles_b, doubles, idx + ) / 1024.d0**3 + if (nproc_target == 0) then call check_mem(r1,irp_here) nproc_target = 1 exit endif + + if (r1+rss < qp_max_mem) then + exit + endif + + nproc_target = nproc_target - 1 + enddo nthreads_davidson = nproc_target TOUCH nthreads_davidson call write_int(6,nproc_target,'Number of threads for diagonalization') call write_double(6, r1, 'Memory(Gb)') + + !--------------- + write(6,'(A)') '' write_buffer = '=====' do i=1,N_st @@ -198,9 +231,7 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ s_(N_st_diag*itermax,N_st_diag*itermax), & s_tmp(N_st_diag*itermax,N_st_diag*itermax), & residual_norm(N_st_diag), & - c(N_st_diag*itermax), & s2(N_st_diag*itermax), & - overlap(N_st_diag*itermax, N_st_diag*itermax), & lambda(N_st_diag*itermax)) h = 0.d0 @@ -503,7 +534,7 @@ subroutine davidson_diag_hjj_sjj(dets_in,u_in,H_jj,s2_out,energies,dim_in,sze,N_ deallocate ( & W, residual_norm, & U, overlap, & - c, S, & + S, & h, & y, s_, s_tmp, & lambda & diff --git a/src/fci/environment.irp.f b/src/fci/environment.irp.f new file mode 100644 index 00000000..5c0e0820 --- /dev/null +++ b/src/fci/environment.irp.f @@ -0,0 +1,14 @@ +BEGIN_PROVIDER [ integer, nthreads_pt2 ] + implicit none + BEGIN_DOC + ! Number of threads for Davidson + END_DOC + nthreads_pt2 = nproc + character*(32) :: env + call getenv('QP_NTHREADS_PT2',env) + if (trim(env) /= '') then + read(env,*) nthreads_pt2 + call write_int(6,nthreads_pt2,'Target number of threads for PT2') + endif +END_PROVIDER +