10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-03 20:54:00 +01:00

Fix cache_compile.py and ninja make all the binary

This commit is contained in:
Thomas Applencourt 2015-05-28 12:03:14 +02:00
parent a48f089990
commit 5f0883c05c
14 changed files with 103 additions and 97 deletions

View File

@ -5,9 +5,9 @@
# --align=32 : Align all provided arrays on a 32-byte boundary
#
[COMMON]
FC : ifort
LAPACK_LIB : -mkl=parallel
IRPF90_FLAGS : --align=32
FC : ifort
LAPACK_LIB : -mkl=parallel
IRPF90_FLAGS : --align=32 --ninja
# Global options
################
@ -29,14 +29,14 @@ OPENMP : 1 ; Append OpenMP flags
# -ftz : Flushes denormal results to zero
#
[OPT]
FCFLAGS : -xHost -O2 -ip -qopt-prefetch -ftz
FCFLAGS : -xHost -O2 -ip -opt-prefetch -ftz
# Profiling flags
#################
#
[PROFILE]
FC : -p -g
FCFLAGS : -xHost -O2 -ip -qopt-prefetch -ftz
FCFLAGS : -xHost -O2 -ip -opt-prefetch -ftz
# Debugging flags
#################

View File

@ -11,6 +11,7 @@ import sys
import hashlib
import re
import shutil
import subprocess
r = re.compile(ur'-c\s+(\S+\.[fF]90)\s+-o\s+(\S+\.o)')
p = re.compile(ur'-I IRPF90_temp/\S*\s+')
@ -51,15 +52,14 @@ def get_hash_key(command, input_data):
def run_and_save_the_data(command, path_output, path_key, is_mod):
# Compile the file -> .o
pid = os.fork()
if pid == 0:
os.execvpe(command.split()[0],command.split(),os.environ)
process = subprocess.Popen(command, shell=True)
os.waitpid(pid)
# Copy the .o in database if is not a module
if not is_mod:
if process.wait() != 0:
sys.exit(1)
elif not is_mod:
try:
shutil.copyfile(path_output, path_key)
print "save"
except:
pass
@ -70,13 +70,15 @@ def cache_utility(command):
try:
os.mkdir("/tmp/qp_compiler/")
except OSError:
raise
pass
# Get the filename of the input.f.90
# and the otput .o
try:
(path_input, path_output) = return_filename_to_cache(command)
except:
# Canot parse the arg of command
raise OSError
try:
@ -87,6 +89,9 @@ def cache_utility(command):
key = get_hash_key(command, input_data)
path_key = os.path.join(TMPDIR, key)
print key
print path_key
# Try to return the content of the .o file
try:
shutil.copyfile(path_key, path_output)
@ -104,4 +109,5 @@ if __name__ == '__main__':
try:
cache_utility(command)
except:
os.execvpe(command.split()[0],command.split(),os.environ)
process = subprocess.Popen(command, shell=True)
# os.execvpe(command.split()[0],command.split(),os.environ)

View File

@ -32,10 +32,30 @@ except ImportError:
sys.exit(1)
# _
# |_ ._ _. ._ o _. |_ | _ _
# |_ | | \/ \/ (_| | | (_| |_) | (/_ _>
def ninja_create_env_variable(pwd_config_file):
l_string = []
for flag in ["FC", "FCFLAGS", "IRPF90", "IRPF90_FLAGS"]:
str_ = "{0} = {1}".format(flag, get_compilation_option(pwd_config_file, flag))
l_string.append(str_)
lib_lapack = get_compilation_option(pwd_config_file, "LAPACK_LIB")
lib_ezfio = join(qpackage_root_ezfio, "lib", "libezfio_irp.a")
l_string.append("{0} = {1} {2}".format("LIB", lib_lapack, lib_ezfio))
l_string.append("")
return l_string
# _ __ _ ___ _ _
# |_ / |_ | / \ _ _|_ _
# |_ /_ | _|_ \_/ o (_ | (_|
# _|
def get_l_module_with_ezfio_cfg():
from os import listdir
from os.path import isfile, join
@ -44,10 +64,10 @@ def get_l_module_with_ezfio_cfg():
return [join(qp_src, m) for m in listdir(qp_src) if isfile(join(qp_src, m, "EZFIO.cfg")) ]
def get_ezfio_config():
# Path in module
# Path in EZFIO/config/
# namedtuple('EZ_config', ['path_in_module', 'path_in_ezfio'])
def get_l_ezfio_config():
"""In $QPACKAGE_ROOT/src/module
In EZFIO/config/
namedtuple('EZ_config', ['path_in_module', 'path_in_ezfio'])"""
l = []
@ -183,18 +203,20 @@ def ninja_ezfio_config_build(l_ezfio_config):
return l_string
def ninja_ezfio_rule(pwd_config_file):
def ninja_ezfio_rule():
# Rule
l_string = ["rule build_ezfio"]
l_flag = []
for flag in ["FC", "FCFLAGS", "IRPF90"]:
str_ = "export {0}='{1}'".format(flag, get_compilation_option(pwd_config_file, flag))
str_ = "export {0}='${0}'".format(flag)
l_flag.append(str_)
l_cmd = ["cd {0}".format(qpackage_root_ezfio)] + l_flag + ["make", "make Python"]
l_string += [" command = {0}".format(" ; ".join(l_cmd))]
l_string += [""]
return l_string
@ -287,7 +309,7 @@ def get_irp_dependancy(d_info_module):
return d_irp
def ninja_irpf90_make_rule(pwd_config_file):
def ninja_irpf90_make_rule():
# Rule
l_string = ["pool irp_pool"]
l_string += [" depth = 1"]
@ -295,12 +317,12 @@ def ninja_irpf90_make_rule(pwd_config_file):
l_string += ["rule build_irpf90.make"]
flag = get_compilation_option(pwd_config_file, "IRPF90_FLAGS")
l_flag = []
for flag in ["FC", "FCFLAGS", "LIB", "SRC", "OBJ"]:
str_ = "export {0}='${0}'".format(flag)
l_flag.append(str_)
l_cmd = ["cd $module",
"export SRC=$src",
"export OBJ=$obj",
"irpf90 $include_dir irpf90_flag = {0}".format(flag)]
l_cmd = ["cd $module"] + l_flag + ["irpf90 $include_dir $IRPF90_FLAGS"]
l_string += [" command = {0}".format(" ; ".join(l_cmd))]
l_string += [" pool = irp_pool"]
@ -313,11 +335,9 @@ def ninja_irpf90_make_build(l_all_needed_molule,
path_module,
d_irp):
l_creation = [join(path_module.abs,i) for i in ["irpf90.make",
"irpf90_entities",
"tags",
"IRPF90_temp",
"IRPF90_man"]]
l_creation = [join(path_module.abs,i) for i in ["irpf90.make",
"irpf90_entities",
"tags"]]
str_creation = " ".join(l_creation)
l_irp_need = []
@ -335,7 +355,7 @@ def ninja_irpf90_make_build(l_all_needed_molule,
str_depend = "{0}".format(str_l_irp_need)
# Build
l_string = ["build {0}: build_irpf90.make {1}".format(str_creation,
str_depend)]
@ -346,8 +366,8 @@ def ninja_irpf90_make_build(l_all_needed_molule,
str_src = " ".join(l_src)
str_obj = " ".join(l_obj)
l_string += [" src = '{0}'".format(str_src)]
l_string += [" obj = '{0}'".format(str_obj)]
l_string += [" SRC = {0}".format(str_src)]
l_string += [" OBJ = {0}".format(str_obj)]
# Option
str_include_dir = " ".join(["-I {0}".format(m.rel) for m in l_all_needed_molule])
@ -498,22 +518,9 @@ def get_program(path_module):
return []
def ninja_binary_rule(pwd_config_file):
def ninja_binary_rule():
l_flag = []
for flag in ["FC", "FCFLAGS"]:
str_ = "export {0}='{1}'".format(flag, get_compilation_option(pwd_config_file, flag))
l_flag.append(str_)
mkl = get_compilation_option(pwd_config_file, "LAPACK_LIB")
ezfio = join(qpackage_root_ezfio, "lib", "libezfio_irp.a")
str_ = "export LIB='{0} {1}'".format(mkl, ezfio)
l_flag.append(str_)
l_cmd = ["cd $module"] + l_flag + ["export SRC=$src",
"export OBJ=$obj",
"make -f irpf90.make -j 1 $binary && touch $binary"]
l_cmd = ["cd $module", "make -f irpf90.make"]
l_string = ["rule build_binary"]
l_string += [" command = {0}".format(" ; ".join(l_cmd))]
@ -524,34 +531,21 @@ def ninja_binary_rule(pwd_config_file):
def ninja_binary_build(l_bin, path_module, l_children):
l_src, l_obj = file_dependancy(path_module.rel)
str_src = " ".join(l_src)
str_obj = " ".join(l_obj)
if not l_bin:
return []
# Build
irpf90mk_path = join(path_module.abs, "irpf90.make")
l_string = []
l_abs_bin = [join(path_module.abs, binary) for binary in l_bin]
for path, abs_path in zip(l_bin, l_abs_bin):
l_string += ["build {0}: build_binary {1} {2}".format(abs_path,
ezfio_lib,
irpf90mk_path)]
l_string += [" module = {0}".format(path_module.abs)]
l_string += [" binary = {0}".format(path)]
l_string += [" src = '{0}'".format(str_src)]
l_string += [" obj = '{0}'".format(str_obj)]
l_string += [""]
str_l_abs_bin = " ".join(l_abs_bin)
l_string = ["build {0}: build_binary {1} {2}".format(str_l_abs_bin,
ezfio_lib,
irpf90mk_path)]
l_string += [" module = {0}".format(path_module.abs)]
l_string += ["build build_all_binary_{0}: phony {1}".format(path_module.rel,
str_l_abs_bin)]
l_string += [""]
@ -576,23 +570,29 @@ def ninja_build_executable_list(l_module):
if __name__ == "__main__":
# _
# |_ ._ _. ._ o _. |_ | _ _
# |_ | | \/ \/ (_| | | (_| |_) | (/_ _>
#
pwd_config_file = sys.argv[1]
l_string = ninja_create_env_variable(pwd_config_file)
# _
# |_) | _
# | \ |_| | (/_
#
l_string = ninja_ezfio_cfg_rule()
l_string += ninja_ezfio_cfg_rule()
l_string += ninja_symlink_rule()
l_string += ninja_irpf90_make_rule(pwd_config_file)
l_string += ninja_irpf90_make_rule()
l_string += ninja_readme_rule()
l_string += ninja_binary_rule(pwd_config_file)
l_string += ninja_binary_rule()
l_string += ninja_ezfio_config_rule()
l_string += ninja_ezfio_rule(pwd_config_file)
l_string += ninja_ezfio_rule()
# l_string += ninja_ocaml_rule()
@ -602,7 +602,7 @@ if __name__ == "__main__":
# _|
l_module_with_ezfio_cfg = get_l_module_with_ezfio_cfg()
l_util = get_children_of_ezfio_cfg(l_module_with_ezfio_cfg)
l_ezfio_config = get_ezfio_config()
l_ezfio_config = get_l_ezfio_config()
l_string += ninja_ezfio_cfg_build(l_util)
l_string += ninja_ezfio_config_build(l_ezfio_config)

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python
import os
file = open(os.environ["QPACKAGE_ROOT"]+'/src/Determinants/H_apply_template.f','r')
file = open(os.environ["QPACKAGE_ROOT"]+'/src/Determinants/H_apply.template.f','r')
template = file.read()
file.close()

View File

@ -170,7 +170,7 @@ if __name__ == '__main__':
if not arguments['<NEEDED_CHILDREN_MODULES>']:
dir_ = os.getcwd()
path_file = os.path.join(dir_, "NEEDED_CHILDREN_MODULES")
path_file = os.path.split(dir_)[1]
else:
path_file = os.path.abspath(arguments['<NEEDED_CHILDREN_MODULES>'])
path_file = os.path.expanduser(path_file)

View File

@ -3,13 +3,13 @@
implicit none
integer :: n_pt_sup
integer :: prim_power_l_max
include 'constants.F'
include 'Utils/constants.F'
prim_power_l_max = maxval(ao_power)
n_pt_max_integrals = 24 * prim_power_l_max + 4
n_pt_max_i_x = 8 * prim_power_l_max
ASSERT (n_pt_max_i_x-1 <= max_dim)
if (n_pt_max_i_x-1 > max_dim) then
print *, 'Increase max_dim in constants.F to ', n_pt_max_i_x-1
print *, 'Increase max_dim in Utils/constants.F to ', n_pt_max_i_x-1
stop 1
endif
END_PROVIDER

View File

@ -1,6 +1,6 @@
# Define here all new external source files and objects.Don't forget to prefix the
# object files with IRPF90_temp/
SRC=H_apply_template.f
SRC=
OBJ=
include $(QPACKAGE_ROOT)/src/Makefile.common

View File

@ -9,7 +9,7 @@ double precision function ao_bielec_integral(i,j,k,l)
double precision :: I_center(3),J_center(3),K_center(3),L_center(3)
integer :: num_i,num_j,num_k,num_l,dim1,I_power(3),J_power(3),K_power(3),L_power(3)
double precision :: integral
include 'constants.F'
include 'Utils/constants.F'
double precision :: P_new(0:max_dim,3),P_center(3),fact_p,pp
double precision :: Q_new(0:max_dim,3),Q_center(3),fact_q,qq
integer :: iorder_p(3), iorder_q(3)
@ -115,7 +115,7 @@ double precision function ao_bielec_integral_schwartz_accel(i,j,k,l)
double precision :: I_center(3),J_center(3),K_center(3),L_center(3)
integer :: num_i,num_j,num_k,num_l,dim1,I_power(3),J_power(3),K_power(3),L_power(3)
double precision :: integral
include 'constants.F'
include 'Utils/constants.F'
double precision :: P_new(0:max_dim,3),P_center(3),fact_p,pp
double precision :: Q_new(0:max_dim,3),Q_center(3),fact_q,qq
integer :: iorder_p(3), iorder_q(3)
@ -519,7 +519,7 @@ double precision function general_primitive_integral(dim, &
! Computes the integral <pq|rs> where p,q,r,s are Gaussian primitives
END_DOC
integer,intent(in) :: dim
include 'constants.F'
include 'Utils/constants.F'
double precision, intent(in) :: P_new(0:max_dim,3),P_center(3),fact_p,p,p_inv
double precision, intent(in) :: Q_new(0:max_dim,3),Q_center(3),fact_q,q,q_inv
integer, intent(in) :: iorder_p(3)
@ -665,7 +665,7 @@ double precision function ERI(alpha,beta,delta,gama,a_x,b_x,c_x,d_x,a_y,b_y,c_y,
integer :: n_pt_sup
double precision :: p,q,denom,coeff
double precision :: I_f
include 'constants.F'
include 'Utils/constants.F'
if(iand(a_x+b_x+c_x+d_x,1).eq.1.or.iand(a_y+b_y+c_y+d_y,1).eq.1.or.iand(a_z+b_z+c_z+d_z,1).eq.1)then
ERI = 0.d0
return
@ -859,7 +859,7 @@ subroutine give_polynom_mult_center_x(P_center,Q_center,a_x,d_x,p,q,n_pt_in,pq_i
integer, intent(in) :: a_x,d_x
double precision, intent(in) :: P_center, Q_center
double precision, intent(in) :: p,q,pq_inv,p10_1,p01_1,p10_2,p01_2,pq_inv_2
include 'constants.F'
include 'Utils/constants.F'
double precision,intent(out) :: d(0:max_dim)
double precision :: accu
accu = 0.d0
@ -916,7 +916,7 @@ subroutine I_x1_pol_mult(a,c,B_10,B_01,B_00,C_00,D_00,d,nd,n_pt_in)
! recursive function involved in the bielectronic integral
END_DOC
integer , intent(in) :: n_pt_in
include 'constants.F'
include 'Utils/constants.F'
double precision,intent(inout) :: d(0:max_dim)
integer,intent(inout) :: nd
integer, intent(in) :: a,c
@ -950,7 +950,7 @@ recursive subroutine I_x1_pol_mult_recurs(a,c,B_10,B_01,B_00,C_00,D_00,d,nd,n_pt
! recursive function involved in the bielectronic integral
END_DOC
integer , intent(in) :: n_pt_in
include 'constants.F'
include 'Utils/constants.F'
double precision,intent(inout) :: d(0:max_dim)
integer,intent(inout) :: nd
integer, intent(in) :: a,c
@ -1036,7 +1036,7 @@ recursive subroutine I_x1_pol_mult_a1(c,B_10,B_01,B_00,C_00,D_00,d,nd,n_pt_in)
! recursive function involved in the bielectronic integral
END_DOC
integer , intent(in) :: n_pt_in
include 'constants.F'
include 'Utils/constants.F'
double precision,intent(inout) :: d(0:max_dim)
integer,intent(inout) :: nd
integer, intent(in) :: c
@ -1090,7 +1090,7 @@ recursive subroutine I_x1_pol_mult_a2(c,B_10,B_01,B_00,C_00,D_00,d,nd,n_pt_in)
! recursive function involved in the bielectronic integral
END_DOC
integer , intent(in) :: n_pt_in
include 'constants.F'
include 'Utils/constants.F'
double precision,intent(inout) :: d(0:max_dim)
integer,intent(inout) :: nd
integer, intent(in) :: c
@ -1152,7 +1152,7 @@ recursive subroutine I_x2_pol_mult(c,B_10,B_01,B_00,C_00,D_00,d,nd,dim)
! recursive function involved in the bielectronic integral
END_DOC
integer , intent(in) :: dim
include 'constants.F'
include 'Utils/constants.F'
double precision :: d(0:max_dim)
integer,intent(inout) :: nd
integer, intent(in) :: c

View File

@ -148,7 +148,7 @@ double precision :: P_center(3)
double precision :: d(0:n_pt_in),pouet,coeff,rho,dist,const,pouet_2,p,p_inv,factor
double precision :: I_n_special_exact,integrate_bourrin,I_n_bibi
double precision :: V_e_n,const_factor,dist_integral,tmp
include 'constants.F'
include 'Utils/constants.F'
if ( (A_center(1)/=B_center(1)).or. &
(A_center(2)/=B_center(2)).or. &
(A_center(3)/=B_center(3)).or. &
@ -351,7 +351,7 @@ recursive subroutine I_x1_pol_mult_mono_elec(a,c,R1x,R1xp,R2x,d,nd,n_pt_in)
integer,intent(inout) :: nd
integer, intent(in):: a,c
double precision, intent(in) :: R1x(0:2),R1xp(0:2),R2x(0:2)
include 'constants.F'
include 'Utils/constants.F'
double precision :: X(0:max_dim)
double precision :: Y(0:max_dim)
!DIR$ ATTRIBUTES ALIGN : $IRP_ALIGN :: X, Y
@ -417,7 +417,7 @@ end
recursive subroutine I_x2_pol_mult_mono_elec(c,R1x,R1xp,R2x,d,nd,dim)
implicit none
integer , intent(in) :: dim
include 'constants.F'
include 'Utils/constants.F'
double precision :: d(0:max_dim)
integer,intent(inout) :: nd
integer, intent(in):: c
@ -492,7 +492,7 @@ implicit none
double precision :: alpha
integer :: n
double precision :: dble_fact
include 'constants.F'
include 'Utils/constants.F'
!if(iand(n,1).eq.1)then
! int_gaus_pol= 0.d0
@ -521,7 +521,7 @@ double precision function V_r(n,alpha)
implicit none
double precision :: alpha, fact
integer :: n
include 'constants.F'
include 'Utils/constants.F'
if(iand(n,1).eq.1)then
V_r = 0.5d0 * fact(ishft(n,-1)) / (alpha ** (ishft(n,-1) + 1))
else
@ -549,7 +549,7 @@ implicit none
!! integral on "theta" with boundaries ( 0 ; pi) of [ cos(theta) **n sin(theta) **m ]
integer :: n,m,i
double precision :: Wallis, prod
include 'constants.F'
include 'Utils/constants.F'
V_theta = 0.d0
prod = 1.d0
do i = 0,ishft(n,-1)-1
@ -565,7 +565,7 @@ double precision function Wallis(n)
implicit none
double precision :: fact
integer :: n,p
include 'constants.F'
include 'Utils/constants.F'
if(iand(n,1).eq.0)then
Wallis = fact(ishft(n,-1))
Wallis = pi * fact(n) / (dble(ibset(0_8,n)) * (Wallis+Wallis)*Wallis)

View File

@ -1 +1 @@
AOs Integrals_Bielec Bitmask CAS_SD CID CID_SC2_selected CID_selected CIS CISD CISD_SC2_selected CISD_selected DDCI_selected Determinants Electrons Ezfio_files FCIdump Full_CI Generators_CAS Generators_full Hartree_Fock MOGuess Molden Integrals_Monoelec MOs MP2 MRCC Nuclei Pseudo Selectors_full Utils
AOs Integrals_Bielec Bitmask CAS_SD CID CID_SC2_selected CID_selected CIS CISD CISD_SC2_selected CISD_selected DDCI_selected Electrons Ezfio_files FCIdump Full_CI Generators_CAS Generators_full Hartree_Fock MOGuess Molden Integrals_Monoelec MOs MP2 MRCC Nuclei Pseudo Selectors_full Utils

View File

@ -1,6 +1,6 @@
# Define here all new external source files and objects.Don't forget to prefix the
# object files with IRPF90_temp/
SRC=perturbation_template.f
SRC=
OBJ=
include $(QPACKAGE_ROOT)/src/Makefile.common

View File

@ -2,7 +2,7 @@ BEGIN_SHELL [ /usr/bin/env python ]
from perturbation import perturbations
import os
filename = os.environ["QPACKAGE_ROOT"]+"/src/Perturbation/perturbation_template.f"
filename = os.environ["QPACKAGE_ROOT"]+"/src/Perturbation/perturbation.template.f"
file = open(filename,'r')
template = file.read()
file.close()