git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14881 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2016-04-26 19:38:50 +00:00
parent 325295bfaa
commit e7363b4764
2 changed files with 80 additions and 48 deletions

View File

@ -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_intelmpi USER-INTEL package for CPU with Intel MPI
Makefile.intel_cpu_mpich USER-INTEL package for CPU with MPICH Makefile.intel_cpu_mpich USER-INTEL package for CPU with MPICH
Makefile.intel_cpu_openmpi USER-INTEL package for CPU with OpenMPI Makefile.intel_cpu_openmpi USER-INTEL package for CPU with OpenMPI
Makefile.intel_phi USER-INTEL package with Xeon Phi support Makefile.intel_coprocessor USER-INTEL package with Xeon Phi support
Makefile.intel_knl USER-INTEL package with KNL support
Makefile.knl USER-INTEL package with KNL support Makefile.knl USER-INTEL package with KNL support
Makefile.kokkos_cuda_mpich KOKKOS package with GPU support for MPICH Makefile.kokkos_cuda_mpich KOKKOS package with GPU support for MPICH

View File

@ -93,13 +93,13 @@ def compile_check(compiler,ccflags,warn):
if os.path.isfile("tmpauto.o"): os.remove("tmpauto.o") if os.path.isfile("tmpauto.o"): os.remove("tmpauto.o")
return flag 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 # return 1 if successful, else 0
# warn = 1 = print warning if not successful, warn = 0 = no warning # 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") 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) txt = commands.getoutput(str)
flag = 1 flag = 1
if txt or not os.path.isfile("tmpauto"): if txt or not os.path.isfile("tmpauto"):
@ -298,18 +298,6 @@ class Actions:
make.setvar("LINKFLAGS","-g") make.setvar("LINKFLAGS","-g")
make.addvar("LINKFLAGS","-O") 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 # add MPI settings
if mpi: if mpi:
@ -358,23 +346,48 @@ class Actions:
if final["user-intel"]: if final["user-intel"]:
if intel.mode == "cpu": if intel.mode == "cpu":
if compile_check(compiler,"-fopenmp",1): make.delvar("CCFLAGS","-O*")
make.addvar("CCFLAGS","-fopenmp") make.addvar("CCFLAGS","-O2")
make.addvar("LINKFLAGS","-fopenmp") if compile_check(compiler,"-openmp",1):
make.addvar("CCFLAGS","-DLAMMPS_MEMALIGN=64") make.addvar("CCFLAGS","-openmp")
if compile_check(compiler,"-restrict",1): if compile_check(compiler,"-restrict",1):
make.addvar("CCFLAGS","-restrict") make.addvar("CCFLAGS","-restrict")
if compile_check(compiler,"-xHost",1): if compile_check(compiler,"-no-offload",1):
make.addvar("CCFLAGS","-xHost") make.addvar("CCFLAGS","-no-offload")
make.addvar("LINKFLAGS","-xHost")
if compile_check(compiler,"-fno-alias",1): if compile_check(compiler,"-fno-alias",1):
make.addvar("CCFLAGS","-fno-alias") make.addvar("CCFLAGS","-fno-alias")
if compile_check(compiler,"-ansi-alias",1): if compile_check(compiler,"-ansi-alias",1):
make.addvar("CCFLAGS","-ansi-alias") 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): if compile_check(compiler,"-override-limits",1):
make.addvar("CCFLAGS","-override-limits") make.addvar("CCFLAGS","-override-limits")
make.addvar("CCFLAGS","-DLAMMPS_MEMALIGN=64")
make.delvar("CCFLAGS","-DLMP_INTEL_OFFLOAD") 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") 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": elif intel.mode == "phi":
if compile_check(compiler,"-fopenmp",1): if compile_check(compiler,"-fopenmp",1):
make.addvar("CCFLAGS","-fopenmp") make.addvar("CCFLAGS","-fopenmp")
@ -397,7 +410,7 @@ class Actions:
make.addvar("CCFLAGS",'-offload-option,mic,compiler,' + make.addvar("CCFLAGS",'-offload-option,mic,compiler,' +
'"-fp-model fast=2 -mGLOB_default_function_attrs=' + '"-fp-model fast=2 -mGLOB_default_function_attrs=' +
'\\"gather_scatter_loop_unroll=4\\""') '\\"gather_scatter_loop_unroll=4\\""')
if link_check(linker,"-offload",1): if link_check(linker,"-offload","",1):
make.addvar("LINKFLAGS","-offload") make.addvar("LINKFLAGS","-offload")
if final["kokkos"]: if final["kokkos"]:
@ -485,6 +498,18 @@ class Actions:
if png.incdir: make.addvar("JPG_INC","-I%s" % png.incdir) if png.incdir: make.addvar("JPG_INC","-I%s" % png.incdir)
if png.libdir: make.addvar("JPG_PATH","-L%s" % png.libdir) 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 # 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"): if make.getvar("MPI_LIB") and "-lmpi_stubs" in make.getvar("MPI_LIB"):
@ -506,9 +531,10 @@ class Actions:
ccflags = ' '.join(make.getvar("CCFLAGS")) ccflags = ' '.join(make.getvar("CCFLAGS"))
linker = precompiler + ' '.join(make.getvar("LINK")) linker = precompiler + ' '.join(make.getvar("LINK"))
linkflags = ' '.join(make.getvar("LINKFLAGS")) linkflags = ' '.join(make.getvar("LINKFLAGS"))
libs = ' '.join(make.getvar("LIB"))
if not compile_check(compiler,ccflags,1): if not compile_check(compiler,ccflags,1):
error("Test of compilation failed") 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 # invoke "make clean-auto" to force clean before build
@ -1720,36 +1746,42 @@ class Cc:
class Flags: class Flags:
def __init__(self,list): def __init__(self,list):
self.inlist = copy.copy(list) self.inlist = copy.copy(list)
self.CC = [] self.flags = []
self.LINK = []
def help(self): def help(self):
return """ return """
-flags flag f1 f2 ... flag f1 f2 ... -flags var action N f1 f2 ... var action N f1 f2 ...
alter CCFLAGS or LINKFLAGS settings in Makefile.auto alter variable settings (flags) in Makefile.auto
only happens if new Makefile.auto is created by use of "file" action only happens if new Makefile.auto is created by use of "file" action
flag = CC or LINK var = CCFLAGS, LINKFLAGS, LIB, etc
one or both can be specified any variable in Makefile.auto, must already exist
f1,f2,etc = flag to add or replace action = add or del
"-" char will be prepended to each N = # of flags to follow
for example: g, O3, xHost, "fp-model fast=2" f1,f2,etc = flag to add or delete
will become: -g, -O3, -xHost, -fp-model fast=2 "-" 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 for -O,-O2,-O3,etc: existing -O* will first be removed
""" """
def check(self): def check(self):
if len(self.inlist) < 1: error("-flags args are invalid") if len(self.inlist) < 1: error("-flags args are invalid")
self.CC = [] # necessary? narg = len(self.inlist)
self.LINK = [] i = 0
mode = "" while i < narg:
for one in self.inlist: if i+3 > narg: error("-flags args are invalid")
if one == "CC": mode = "CC" var = self.inlist[i]
elif one == "LINK": mode = "LINK" action = self.inlist[i+1]
else: if action != "add" and action != "del": error("-flags args are invalid")
if not mode: error("-flags args are invalid") nflag = int(self.inlist[i+2])
if mode == "CC": self.CC.append(one) i += 3
elif mode == "LINK": self.LINK.append(one) 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 # Mpi class
class Mpi: class Mpi:
@ -1941,7 +1973,8 @@ class MakeReader:
# varinfo = list of variable info: (name, name with whitespace for print) # varinfo = list of variable info: (name, name with whitespace for print)
# add index into varinfo to newlines # add index into varinfo to newlines
# ccindex = index of "CC =" line, to add OMPI var before it # 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 = {} var = {}
varinfo = [] varinfo = []