From e7363b47640bbddb935c1ccc0e54d0cadef11eef Mon Sep 17 00:00:00 2001 From: sjplimp Date: Tue, 26 Apr 2016 19:38:50 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14881 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/MAKE/README | 3 +- src/Make.py | 125 ++++++++++++++++++++++++++++++------------------ 2 files changed, 80 insertions(+), 48 deletions(-) diff --git a/src/MAKE/README b/src/MAKE/README index 9e2a6cabca..95f6c72a1a 100644 --- a/src/MAKE/README +++ b/src/MAKE/README @@ -69,8 +69,7 @@ Makefile.gpu GPU package, using default MPI Makefile.intel_cpu_intelmpi USER-INTEL package for CPU with Intel MPI Makefile.intel_cpu_mpich USER-INTEL package for CPU with MPICH Makefile.intel_cpu_openmpi USER-INTEL package for CPU with OpenMPI -Makefile.intel_phi USER-INTEL package with Xeon Phi support -Makefile.intel_knl USER-INTEL package with KNL support +Makefile.intel_coprocessor USER-INTEL package with Xeon Phi support Makefile.knl USER-INTEL package with KNL support Makefile.kokkos_cuda_mpich KOKKOS package with GPU support for MPICH diff --git a/src/Make.py b/src/Make.py index 0a05255277..1aecfeace9 100755 --- a/src/Make.py +++ b/src/Make.py @@ -93,13 +93,13 @@ def compile_check(compiler,ccflags,warn): if os.path.isfile("tmpauto.o"): os.remove("tmpauto.o") return flag -# check if linker works with linkflags on tmpauto.o file +# check if linker works with linkflags and libs on tmpauto.o file # return 1 if successful, else 0 # warn = 1 = print warning if not successful, warn = 0 = no warning -def link_check(linker,linkflags,warn): +def link_check(linker,linkflags,libs,warn): open("tmpauto.cpp",'w').write("int main(int, char **) {}\n") - str = "%s %s -o tmpauto tmpauto.cpp" % (linker,linkflags) + str = "%s %s -o tmpauto tmpauto.cpp %s" % (linker,linkflags,libs) txt = commands.getoutput(str) flag = 1 if txt or not os.path.isfile("tmpauto"): @@ -298,18 +298,6 @@ class Actions: make.setvar("LINKFLAGS","-g") make.addvar("LINKFLAGS","-O") - # add CC and LINK flags - - if flags: - for flag in flags.CC: - flag = "-" + flag - if flag[:2] == "-O": make.delvar("CCFLAGS","-O*") - make.addvar("CCFLAGS",flag) - for flag in flags.LINK: - flag = "-" + flag - if flag[:2] == "-O": make.delvar("LINKFLAGS","-O*") - make.addvar("LINKFLAGS",flag) - # add MPI settings if mpi: @@ -358,23 +346,48 @@ class Actions: if final["user-intel"]: if intel.mode == "cpu": - if compile_check(compiler,"-fopenmp",1): - make.addvar("CCFLAGS","-fopenmp") - make.addvar("LINKFLAGS","-fopenmp") - make.addvar("CCFLAGS","-DLAMMPS_MEMALIGN=64") + make.delvar("CCFLAGS","-O*") + make.addvar("CCFLAGS","-O2") + if compile_check(compiler,"-openmp",1): + make.addvar("CCFLAGS","-openmp") if compile_check(compiler,"-restrict",1): make.addvar("CCFLAGS","-restrict") - if compile_check(compiler,"-xHost",1): - make.addvar("CCFLAGS","-xHost") - make.addvar("LINKFLAGS","-xHost") + if compile_check(compiler,"-no-offload",1): + make.addvar("CCFLAGS","-no-offload") if compile_check(compiler,"-fno-alias",1): make.addvar("CCFLAGS","-fno-alias") if compile_check(compiler,"-ansi-alias",1): make.addvar("CCFLAGS","-ansi-alias") + if compile_check(compiler,"-xAVX",1): + make.addvar("CCFLAGS","-xAVX") + if compile_check(compiler,"-fpmodel fast=2",1): + make.addvar("CCFLAGS","-fpmodel fast=2") + if compile_check(compiler,"-no-prec-div",1): + make.addvar("CCFLAGS","-no-prec-div") if compile_check(compiler,"-override-limits",1): make.addvar("CCFLAGS","-override-limits") + make.addvar("CCFLAGS","-DLAMMPS_MEMALIGN=64") make.delvar("CCFLAGS","-DLMP_INTEL_OFFLOAD") + + make.delvar("LINKFLAGS","-O*") + make.addvar("LINKFLAGS","-O2") + if link_check(linker,"-openmp","",1): + make.addvar("LINKFLAGS","-openmp") + if link_check(linker,"-xAVX","",1): + make.addvar("LINKFLAGS","-xAVX") + if link_check(linker,"-fpmodel fast=2","",1): + make.addvar("LINKFLAGS","-fpmodel fast=2") + if link_check(linker,"-no-prec-div","",1): + make.addvar("LINKFLAGS","-no-prec-div") + if link_check(linker,"-override-limits","",1): + make.addvar("LINKFLAGS","-override-limits") make.delvar("LINKFLAGS","-offload") + + if link_check(linker,"","-ltbbmalloc",1): + make.addvar("LIB","-ltbbmalloc") + if link_check(linker,"","-ltbbmalloc_proxy",1): + make.addvar("LIB","-ltbbmalloc_proxy") + elif intel.mode == "phi": if compile_check(compiler,"-fopenmp",1): make.addvar("CCFLAGS","-fopenmp") @@ -397,7 +410,7 @@ class Actions: make.addvar("CCFLAGS",'-offload-option,mic,compiler,' + '"-fp-model fast=2 -mGLOB_default_function_attrs=' + '\\"gather_scatter_loop_unroll=4\\""') - if link_check(linker,"-offload",1): + if link_check(linker,"-offload","",1): make.addvar("LINKFLAGS","-offload") if final["kokkos"]: @@ -485,6 +498,18 @@ class Actions: if png.incdir: make.addvar("JPG_INC","-I%s" % png.incdir) if png.libdir: make.addvar("JPG_PATH","-L%s" % png.libdir) + # finally after all other settings, add explicit flags + + if flags: + for var,action,flist in flags.flags: + values = make.getvar(var) + if values == None: + error("Flags for a non-existent Makefile.auto variable") + for flag in flist: + flag = "-" + flag + if action == "add": make.addvar(var,flag) + elif action == "del": make.delvar(var,flag) + # set self.stubs if Makefile.auto uses STUBS lib in MPI settings if make.getvar("MPI_LIB") and "-lmpi_stubs" in make.getvar("MPI_LIB"): @@ -506,9 +531,10 @@ class Actions: ccflags = ' '.join(make.getvar("CCFLAGS")) linker = precompiler + ' '.join(make.getvar("LINK")) linkflags = ' '.join(make.getvar("LINKFLAGS")) + libs = ' '.join(make.getvar("LIB")) if not compile_check(compiler,ccflags,1): error("Test of compilation failed") - if not link_check(linker,linkflags,1): error("Test of link failed") + if not link_check(linker,linkflags,libs,1): error("Test of link failed") # invoke "make clean-auto" to force clean before build @@ -1720,36 +1746,42 @@ class Cc: class Flags: def __init__(self,list): self.inlist = copy.copy(list) - self.CC = [] - self.LINK = [] + self.flags = [] def help(self): return """ --flags flag f1 f2 ... flag f1 f2 ... - alter CCFLAGS or LINKFLAGS settings in Makefile.auto +-flags var action N f1 f2 ... var action N f1 f2 ... + alter variable settings (flags) in Makefile.auto only happens if new Makefile.auto is created by use of "file" action - flag = CC or LINK - one or both can be specified - f1,f2,etc = flag to add or replace - "-" char will be prepended to each - for example: g, O3, xHost, "fp-model fast=2" - will become: -g, -O3, -xHost, -fp-model fast=2 + var = CCFLAGS, LINKFLAGS, LIB, etc + any variable in Makefile.auto, must already exist + action = add or del + N = # of flags to follow + f1,f2,etc = flag to add or delete + "-" char will be prepended to each flag + for example: add 4 g O3 xHost "fp-model fast=2" + will add: -g -O3 -xHost -fp-model fast=2 + for add: if flag already exists, no change is made + for delete: flag of form "-O*", will delete any wildcard match for -O,-O2,-O3,etc: existing -O* will first be removed """ def check(self): if len(self.inlist) < 1: error("-flags args are invalid") - self.CC = [] # necessary? - self.LINK = [] - mode = "" - for one in self.inlist: - if one == "CC": mode = "CC" - elif one == "LINK": mode = "LINK" - else: - if not mode: error("-flags args are invalid") - if mode == "CC": self.CC.append(one) - elif mode == "LINK": self.LINK.append(one) - + narg = len(self.inlist) + i = 0 + while i < narg: + if i+3 > narg: error("-flags args are invalid") + var = self.inlist[i] + action = self.inlist[i+1] + if action != "add" and action != "del": error("-flags args are invalid") + nflag = int(self.inlist[i+2]) + i += 3 + if i+nflag > narg: error("-flags args are invalid") + flags = self.inlist[i:i+nflag] + self.flags.append([var,action,flags]) + i += nflag + # Mpi class class Mpi: @@ -1941,7 +1973,8 @@ class MakeReader: # varinfo = list of variable info: (name, name with whitespace for print) # add index into varinfo to newlines # ccindex = index of "CC =" line, to add OMPI var before it - # lmpindex = index of "LAMMPS-specific settings" line to add KOKKOS vars before it + # lmpindex = index of "LAMMPS-specific settings" + # line to add KOKKOS vars before it var = {} varinfo = []