mirror of
https://github.com/LCPQ/quantum_package
synced 2024-12-22 20:35:19 +01:00
Better config_gfortran
This commit is contained in:
parent
ba49beff36
commit
a48f089990
@ -13,7 +13,7 @@ script:
|
||||
- ./setup_environment.sh --robot
|
||||
- source ./quantum_package.rc
|
||||
- cp ./src/Makefile.config.gfortran ./src/Makefile.config
|
||||
- ./scripts/compilation/create_ninja_build.py > build.ninja
|
||||
- ./scripts/compilation/create_ninja_build.py ./config/gfortran_example.cfg > build.ninja
|
||||
- ./ninja/ninja -v
|
||||
- ei_handler.py ocaml_global
|
||||
- cd ocaml ; make ; cd -
|
||||
|
59
config/gfortran_example.cfg
Normal file
59
config/gfortran_example.cfg
Normal file
@ -0,0 +1,59 @@
|
||||
# Common flags
|
||||
##############
|
||||
#
|
||||
# -ffree-line-length-none : Needed for IRPF90 which produces long lines
|
||||
# -lblas -llapack : Link with libblas and liblapack libraries provided by the system
|
||||
#
|
||||
# --align=32 : Align all provided arrays on a 32-byte boundary
|
||||
#
|
||||
[COMMON]
|
||||
FC : gfortran -ffree-line-length-none
|
||||
LAPACK_LIB : -lblas -llapack
|
||||
IRPF90_FLAGS : --align=32
|
||||
|
||||
# Global options
|
||||
################
|
||||
#
|
||||
# 1 : Activate
|
||||
# 0 : Deactivate
|
||||
#
|
||||
[OPTION]
|
||||
MODE : OPT ; [ OPT | PROFILE | DEBUG ] : Chooses the section below
|
||||
CACHE : 1 ; Enable cache_compile.py
|
||||
OPENMP : 1 ; Append OpenMP flags
|
||||
|
||||
# Optimization flags
|
||||
####################
|
||||
#
|
||||
# -march=native : Compile a binary optimized for the current architecture
|
||||
# -Ofast : Disregard strict standards compliance. Enables all -O3 optimizations.
|
||||
# It also enables optimizations that are not valid
|
||||
# for all standard-compliant programs. It turns on
|
||||
# -ffast-math and the Fortran-specific
|
||||
# -fno-protect-parens and -fstack-arrays.
|
||||
[OPT]
|
||||
FCFLAGS : -Ofast -march=native
|
||||
|
||||
# Profiling flags
|
||||
#################
|
||||
#
|
||||
[PROFILE]
|
||||
FC : -p -g
|
||||
FCFLAGS : -Ofast -march=native
|
||||
|
||||
# Debugging flags
|
||||
#################
|
||||
#
|
||||
# -fcheck=all : Checks uninitialized variables, array subscripts, etc...
|
||||
# -g : Extra debugging information
|
||||
#
|
||||
[DEBUG]
|
||||
FCFLAGS : -fcheck=all -g
|
||||
|
||||
# OpenMP flags
|
||||
#################
|
||||
#
|
||||
[OPENMP]
|
||||
FC : -fopenmp
|
||||
IRPF90_FLAGS : --openmp
|
||||
|
60
config/ifort_example.cfg
Normal file
60
config/ifort_example.cfg
Normal file
@ -0,0 +1,60 @@
|
||||
# Common flags
|
||||
##############
|
||||
#
|
||||
# -mkl=[parallel|sequential] : Use the MKL library
|
||||
# --align=32 : Align all provided arrays on a 32-byte boundary
|
||||
#
|
||||
[COMMON]
|
||||
FC : ifort
|
||||
LAPACK_LIB : -mkl=parallel
|
||||
IRPF90_FLAGS : --align=32
|
||||
|
||||
# Global options
|
||||
################
|
||||
#
|
||||
# 1 : Activate
|
||||
# 0 : Deactivate
|
||||
#
|
||||
[OPTION]
|
||||
MODE : OPT ; [ OPT | PROFILE | DEBUG ] : Chooses the section below
|
||||
CACHE : 1 ; 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 : -xHost -O2 -ip -qopt-prefetch -ftz
|
||||
|
||||
# Profiling flags
|
||||
#################
|
||||
#
|
||||
[PROFILE]
|
||||
FC : -p -g
|
||||
FCFLAGS : -xHost -O2 -ip -qopt-prefetch -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
|
||||
|
||||
# OpenMP flags
|
||||
#################
|
||||
#
|
||||
[OPENMP]
|
||||
FC : -fopenmp
|
||||
IRPF90_FLAGS : --openmp
|
||||
|
@ -51,9 +51,11 @@ def get_hash_key(command, input_data):
|
||||
def run_and_save_the_data(command, path_output, path_key, is_mod):
|
||||
|
||||
# Compile the file -> .o
|
||||
os.system(command)
|
||||
# Read the .o
|
||||
pid = os.fork()
|
||||
if pid == 0:
|
||||
os.execvpe(command.split()[0],command.split(),os.environ)
|
||||
|
||||
os.waitpid(pid)
|
||||
# Copy the .o in database if is not a module
|
||||
if not is_mod:
|
||||
try:
|
||||
@ -102,4 +104,4 @@ if __name__ == '__main__':
|
||||
try:
|
||||
cache_utility(command)
|
||||
except:
|
||||
os.system(command)
|
||||
os.execvpe(command.split()[0],command.split(),os.environ)
|
||||
|
@ -1,20 +0,0 @@
|
||||
[OPTION]
|
||||
OPENMP: 1
|
||||
PROFILE: 0
|
||||
DEBUG: 0
|
||||
|
||||
[COMMON]
|
||||
FC: gfortran -ffree-line-length-none -march=native
|
||||
FCFLAGS: -ffast-math -Ofast
|
||||
MKL: -lblas -llapack
|
||||
|
||||
[OPENMP]
|
||||
FC: -fopenmp
|
||||
IRPF90_FLAGS: --openmp
|
||||
|
||||
[PROFILE]
|
||||
FC: -p -g
|
||||
CXX: -pg
|
||||
|
||||
[DEBUG]
|
||||
FCFLAGS: -fcheck=all
|
@ -313,7 +313,12 @@ def ninja_irpf90_make_build(l_all_needed_molule,
|
||||
path_module,
|
||||
d_irp):
|
||||
|
||||
path_irpf90_make = join(path_module.abs, "irpf90.make")
|
||||
l_creation = [join(path_module.abs,i) for i in ["irpf90.make",
|
||||
"irpf90_entities",
|
||||
"tags",
|
||||
"IRPF90_temp",
|
||||
"IRPF90_man"]]
|
||||
str_creation = " ".join(l_creation)
|
||||
|
||||
l_irp_need = []
|
||||
for module in [path_module] + l_all_needed_molule:
|
||||
@ -330,7 +335,8 @@ 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(path_irpf90_make,
|
||||
|
||||
l_string = ["build {0}: build_irpf90.make {1}".format(str_creation,
|
||||
str_depend)]
|
||||
|
||||
l_string += [" module = {0}".format(path_module.abs)]
|
||||
@ -499,7 +505,7 @@ def ninja_binary_rule(pwd_config_file):
|
||||
str_ = "export {0}='{1}'".format(flag, get_compilation_option(pwd_config_file, flag))
|
||||
l_flag.append(str_)
|
||||
|
||||
mkl = get_compilation_option(pwd_config_file, "MKL")
|
||||
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)
|
||||
|
@ -6,17 +6,26 @@ import ConfigParser
|
||||
|
||||
|
||||
def get_l_option_section(config):
|
||||
return [o for o in ['OPENMP', 'PROFILE', 'DEBUG'] if config.getboolean("OPTION", o)]
|
||||
"""List of options chosen by the user"""
|
||||
l = [o for o in ['OPENMP'] if config.getboolean("OPTION", o)]
|
||||
l.append(config.get("OPTION", "MODE").strip())
|
||||
return l
|
||||
|
||||
|
||||
def get_compilation_option(pwd_cfg, flag_name):
|
||||
|
||||
"""
|
||||
Return the flag compilation of a compile.cfg located in pwd_cfg
|
||||
"""
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(pwd_cfg)
|
||||
|
||||
if flag_name == "FC" and config.getboolean("OPTION","CACHE"):
|
||||
l = ["cache_compile.py"]
|
||||
else:
|
||||
l = []
|
||||
|
||||
l_option_section = get_l_option_section(config)
|
||||
|
||||
l = []
|
||||
for section in ["COMMON"] + l_option_section:
|
||||
try:
|
||||
l.extend(config.get(section, flag_name).split())
|
||||
@ -28,6 +37,7 @@ def get_compilation_option(pwd_cfg, flag_name):
|
||||
if __name__ == '__main__':
|
||||
|
||||
qpackage_root = os.environ['QPACKAGE_ROOT']
|
||||
pwd_cfg = os.path.join(qpackage_root, "scripts/compilation/compilation_ifort.cfg")
|
||||
pwd_cfg = os.path.join(qpackage_root, "config/gfortran_example.cfg")
|
||||
|
||||
print get_compilation_option(pwd_cfg, "FC")
|
||||
print get_compilation_option(pwd_cfg, "FCFLAGS")
|
||||
|
Loading…
Reference in New Issue
Block a user