git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14805 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
216
src/Make.py
216
src/Make.py
@ -15,14 +15,14 @@ import sys,os,commands,re,copy,subprocess
|
||||
# setargs = makefile settings
|
||||
# actionargs = allowed actions (also lib-dir and machine)
|
||||
|
||||
abbrevs = "adhjmoprsv"
|
||||
abbrevs = "adhjmoprsvz"
|
||||
|
||||
switchclasses = ("actions","dir","help","jmake","makefile",
|
||||
"output","packages","redo","settings","verbose")
|
||||
"output","packages","redo","settings","verbose","zoutput")
|
||||
libclasses = ("atc","awpmd","colvars","cuda","gpu","h5md",
|
||||
"meam","poems","python","qmmm","reax","voronoi")
|
||||
buildclasses = ("intel","kokkos")
|
||||
makeclasses = ("cc","mpi","fft","jpg","png")
|
||||
makeclasses = ("cc","flags","mpi","fft","jpg","png")
|
||||
|
||||
setargs = ("gzip","#gzip","ffmpeg","#ffmpeg","smallbig","bigbig","smallsmall")
|
||||
actionargs = ("lib-all","file","clean","exe")
|
||||
@ -137,27 +137,37 @@ class Actions:
|
||||
lib-all builds all auxiliary libs needed by installed packages
|
||||
lib-dir builds a specific lib whether package installed or not
|
||||
dir is any dir in lib directory (atc, cuda, meam, etc) except linalg
|
||||
(2) file = create src/MAKE/MINE/Makefile.auto
|
||||
use -m switch for Makefile.machine to start from,
|
||||
else use existing Makefile.auto
|
||||
adds settings needed for installed accelerator packages
|
||||
existing Makefile.auto is NOT changed unless "file" action is specified
|
||||
(2) file = create a new src/MAKE/MINE/Makefile.auto
|
||||
if file not specified, existing Makefile.auto is NOT changed
|
||||
except by -m switch, which will copy Makefile.machine to Makefile.auto
|
||||
note that exe action can add an -m switch, as described below
|
||||
if file is specified, new Makefile.auto is created
|
||||
if "-m machine" specified (or added by exe),
|
||||
start with existing Makefile.machine, else existing Makefile.auto
|
||||
if "-m none" specified, start Makefile.auto from scratch
|
||||
must use -cc and -mpi switches to specify compiler and MPI
|
||||
settings for these switches will alter Makefile.auto
|
||||
-s, -intel, -kokkos, -cc, -mpi, -fft, -jpg, -png
|
||||
if these accelerator packages are installed, they induce settings
|
||||
that will alter Makefile.auto: opt, user-omp, user-intel, kokkos
|
||||
use -z switch to copy final Makefile.auto to new filename
|
||||
(3) clean = invoke "make clean-auto" to insure clean build on current files
|
||||
useful if compiler flags have changed
|
||||
(4) exe or machine = build LAMMPS
|
||||
machine can be any existing Makefile.machine suffix
|
||||
machine is converted to "exe" action, as well as:
|
||||
machine is converted to "exe" action, and additionally:
|
||||
"-m machine" is added if -m switch is not specified
|
||||
"-o machine" is added if -o switch is not specified
|
||||
if either "-m" or "-o" are specified, they are not overridden
|
||||
does not invoke any lib builds, since libs could be previously built
|
||||
exe always builds using src/MAKE/MINE/Makefile.auto
|
||||
if file action also specified, it creates Makefile.auto
|
||||
exe ALWAYS builds using src/MAKE/MINE/Makefile.auto
|
||||
if file action also specified, it creates a new Makefile.auto
|
||||
else if -m switch specified,
|
||||
existing Makefile.machine is copied to create Makefile.auto
|
||||
else Makefile.auto must already exist and is not changed
|
||||
produces src/lmp_auto, or error message if unsuccessful
|
||||
build produces src/lmp_auto, or error message if unsuccessful
|
||||
use -o switch to copy src/lmp_auto to new filename
|
||||
use -z switch to copy src/MAKE/MINE/Makefile.auto to new filename
|
||||
"""
|
||||
|
||||
def check(self):
|
||||
@ -177,7 +187,7 @@ class Actions:
|
||||
cleans.append(one)
|
||||
elif one == "exe":
|
||||
exes.append(one)
|
||||
# one action can be unknown in case is a machine (checked in setup)
|
||||
# one action can be unknown, must be a machine (checked in setup)
|
||||
else:
|
||||
exes.append(one)
|
||||
if len(set(libs)) != len(libs) or \
|
||||
@ -236,9 +246,9 @@ class Actions:
|
||||
|
||||
def file(self,caller):
|
||||
|
||||
# if caller = "file", create from mpi or read from makefile.machine or auto
|
||||
# if caller = "exe" and "file" action already invoked, read from auto
|
||||
# if caller = "exe" and no "file" action, read from makefile.machine or auto
|
||||
# if caller="file", create from mpi or read from Makefile.machine or auto
|
||||
# if caller="exe" and "file" action already invoked, read from auto
|
||||
# if caller="exe" and no "file" action, read from Makefile.machine or auto
|
||||
|
||||
if caller == "file":
|
||||
if makefile and makefile.machine == "none":
|
||||
@ -279,7 +289,7 @@ class Actions:
|
||||
make.addvar("CC","-cxx=%s" % wrapper)
|
||||
make.addvar("LINK","-cxx=%s" % wrapper)
|
||||
elif "-lmpi" in txt:
|
||||
make.addvar("OMPI_CXX",wrapper,"cc")
|
||||
make.addvar("export OMPI_CXX",wrapper,"cc")
|
||||
precompiler = "env OMPI_CXX=%s " % wrapper
|
||||
else: error("Could not add MPI wrapper compiler, " +
|
||||
"did not recognize OpenMPI or MPICH")
|
||||
@ -287,8 +297,20 @@ class Actions:
|
||||
make.addvar("CCFLAGS","-O3")
|
||||
make.setvar("LINKFLAGS","-g")
|
||||
make.addvar("LINKFLAGS","-O")
|
||||
|
||||
# add CC and LINK flags
|
||||
|
||||
# add MPI settings
|
||||
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:
|
||||
make.delvar("MPI_INC","*")
|
||||
@ -397,7 +419,7 @@ class Actions:
|
||||
make.addvar("KOKKOS_DEVICES","OpenMP","lmp")
|
||||
make.addvar("KOKKOS_ARCH","KNC","lmp")
|
||||
|
||||
# add LMP settings
|
||||
# add LMP_INC ifdef settings
|
||||
|
||||
if settings:
|
||||
list = settings.inlist
|
||||
@ -465,12 +487,13 @@ class Actions:
|
||||
|
||||
# set self.stubs if Makefile.auto uses STUBS lib in MPI settings
|
||||
|
||||
if "-lmpi_stubs" in make.getvar("MPI_LIB"): self.stubs = 1
|
||||
if make.getvar("MPI_LIB") and "-lmpi_stubs" in make.getvar("MPI_LIB"):
|
||||
self.stubs = 1
|
||||
else: self.stubs = 0
|
||||
|
||||
# write out Makefile.auto
|
||||
# unless caller = "exe" and "file" action already invoked
|
||||
|
||||
|
||||
if caller == "file" or "file" not in self.alist:
|
||||
make.write("%s/MAKE/MINE/Makefile.auto" % dir.src,1)
|
||||
print "Created src/MAKE/MINE/Makefile.auto"
|
||||
@ -510,13 +533,23 @@ class Actions:
|
||||
print txt
|
||||
error('Unsuccessful "make stubs"')
|
||||
print "Created src/STUBS/libmpi_stubs.a"
|
||||
if jmake: str = "cd %s; make -j %d auto" % (dir.src,jmake.n)
|
||||
else: str = "cd %s; make auto" % dir.src
|
||||
|
||||
# special hack for shannon GPU cluster
|
||||
# must use "srun make" if on it and building w/ GPU package, else just make
|
||||
# this is b/c Cuda libs are not all available on host
|
||||
|
||||
make = "make"
|
||||
if "shannon" in os.environ.get("HOST") and packages.final["gpu"]:
|
||||
make = "srun make"
|
||||
|
||||
if jmake: str = "cd %s; %s -j %d auto" % (dir.src,make,jmake.n)
|
||||
else: str = "cd %s; %s auto" % (dir.src,make)
|
||||
|
||||
# if verbose, print output as build proceeds, else only print if fails
|
||||
|
||||
if verbose: subprocess.call(str,shell=True)
|
||||
else:
|
||||
print str
|
||||
try: subprocess.check_output(str,stderr=subprocess.STDOUT,shell=True)
|
||||
except Exception as e: print e.output
|
||||
|
||||
@ -574,8 +607,8 @@ Syntax: Make.py switch args ...
|
||||
list one or more actions, in any order
|
||||
machine is a Makefile.machine suffix
|
||||
one-letter switches:
|
||||
-d (dir), -j (jmake), -m (makefile), -o (output),
|
||||
-p (packages), -r (redo), -s (settings), -v (verbose)
|
||||
-d (dir), -j (jmake), -m (makefile), -o (output), -p (packages),
|
||||
-r (redo), -s (settings), -v (verbose), -z (makefile output)
|
||||
switches for libs:
|
||||
-atc, -awpmd, -colvars, -cuda, -gpu, -h5md,
|
||||
-meam, -poems, -python, -qmmm, -reax, -voronoi
|
||||
@ -898,9 +931,13 @@ class Settings:
|
||||
def help(self):
|
||||
return """
|
||||
-s set1 set2 ...
|
||||
possible settings = gzip smallbig bigbig smallsmall
|
||||
add each setting as LAMMPS setting to created Makefile.auto
|
||||
if -s not specified, no settings are changed in Makefile.auto
|
||||
possible settings = gzip #gzip ffmpeg #ffmpeg smallbig bigbig smallsmall
|
||||
alter LAMMPS ifdef settings in Makefile.auto
|
||||
only happens if new Makefile.auto is created by use of "file" action
|
||||
gzip and #gzip turn on/off LAMMPS_GZIP setting
|
||||
ffmpeg and #ffmpeg turn on/off LAMMPS_FFMPEG setting
|
||||
smallbig, bigbig, smallsmall turn on LAMMPS_SMALLBIG, etc
|
||||
and turn off other two
|
||||
"""
|
||||
|
||||
def check(self):
|
||||
@ -924,6 +961,23 @@ class Verbose:
|
||||
def check(self):
|
||||
if len(self.inlist): error("-v args are invalid")
|
||||
|
||||
# zoutput switch for making copy of final Makefile.auto
|
||||
|
||||
class Zoutput:
|
||||
def __init__(self,list):
|
||||
self.inlist = copy.copy(list)
|
||||
|
||||
def help(self):
|
||||
return """
|
||||
-z machine
|
||||
copy created/used src/MAKE/MINE/Makefile.auto to Makefile.machine in same dir
|
||||
this can be used to preserve the machine makefile
|
||||
"""
|
||||
|
||||
def check(self):
|
||||
if len(self.inlist) != 1: error("-z args are invalid")
|
||||
self.machine = self.inlist[0]
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# lib classes, one per LAMMPS auxiliary lib
|
||||
# ----------------------------------------------------------------
|
||||
@ -1087,15 +1141,15 @@ class CUDA:
|
||||
def __init__(self,list):
|
||||
self.inlist = copy.copy(list)
|
||||
self.mode = "double"
|
||||
self.arch = "31"
|
||||
self.arch = "35"
|
||||
|
||||
def help(self):
|
||||
return """
|
||||
-cuda mode=double arch=31
|
||||
-cuda mode=double arch=35
|
||||
all args are optional and can be in any order
|
||||
mode = double or mixed or single (def = double)
|
||||
arch = M (def = 31)
|
||||
M = 31 for Kepler
|
||||
arch = M (def = 35)
|
||||
M = 31,35,37,etc for Kepler
|
||||
M = 20 for CC2.0 (GF100/110, e.g. C2050,GTX580,GTX470)
|
||||
M = 21 for CC2.1 (GF104/114, e.g. GTX560, GTX460, GTX450)
|
||||
M = 13 for CC1.3 (GF200, e.g. C1060, GTX285)
|
||||
@ -1144,16 +1198,18 @@ class GPU:
|
||||
def __init__(self,list):
|
||||
self.inlist = copy.copy(list)
|
||||
self.make = "linux.double"
|
||||
self.lammpsflag = self.modeflag = self.archflag = 0
|
||||
self.lammpsflag = self.modeflag = self.archflag = self.homeflag = 0
|
||||
|
||||
def help(self):
|
||||
return """
|
||||
-gpu make=suffix lammps=suffix2 mode=double arch=N
|
||||
-gpu make=suffix lammps=suffix2 mode=double arch=N home=path
|
||||
all args are optional and can be in any order
|
||||
make = use Makefile.suffix (def = linux.double)
|
||||
lammps = use Makefile.lammps.suffix2 (def = EXTRAMAKE in makefile)
|
||||
mode = double or mixed or single (def = CUDA_PREC in makefile)
|
||||
arch = 31 (Kepler) or 21 (Fermi) (def = CUDA_ARCH in makefile)
|
||||
arch = 3x (x = digit for Kepler) or 2x (x = digit for Fermi)
|
||||
(def = CUDA_ARCH in makefile)
|
||||
home = path to Cuda, e.g. /usr/local/cuda (def = CUDA_HOME in makefile)
|
||||
"""
|
||||
|
||||
def check(self):
|
||||
@ -1172,6 +1228,9 @@ class GPU:
|
||||
elif words[0] == "arch":
|
||||
self.arch = words[1]
|
||||
self.archflag = 1
|
||||
elif words[0] == "home":
|
||||
self.home = words[1]
|
||||
self.homeflag = 1
|
||||
else: error("-gpu args are invalid")
|
||||
if self.modeflag and (self.mode != "double" and
|
||||
self.mode != "mixed" and
|
||||
@ -1192,13 +1251,22 @@ class GPU:
|
||||
make.setvar("CUDA_PRECISION","-D_SINGLE_SINGLE")
|
||||
if self.archflag:
|
||||
make.setvar("CUDA_ARCH","-arch=sm_%s" % self.arch)
|
||||
if self.homeflag:
|
||||
make.setvar("CUDA_HOME",self.home)
|
||||
if self.lammpsflag:
|
||||
make.setvar("EXTRAMAKE","Makefile.lammps.%s" % self.lammps)
|
||||
make.write("%s/Makefile.auto" % libdir)
|
||||
|
||||
commands.getoutput("cd %s; make -f Makefile.auto clean" % libdir)
|
||||
if jmake: str = "cd %s; make -j %d -f Makefile.auto" % (libdir,jmake.n)
|
||||
else: str = "cd %s; make -f Makefile.auto" % libdir
|
||||
# special hack for shannon GPU cluster
|
||||
# must use "srun make" if on it, else just make
|
||||
# this is b/c Cuda libs are not all available on host
|
||||
|
||||
make = "make"
|
||||
if "shannon" in os.environ.get("HOST"): make = "srun make"
|
||||
|
||||
commands.getoutput("cd %s; %s -f Makefile.auto clean" % (libdir,make))
|
||||
if jmake: str = "cd %s; %s -j %d -f Makefile.auto" % (libdir,make,jmake.n)
|
||||
else: str = "cd %s; %s -f Makefile.auto" % (libdir,make)
|
||||
|
||||
# if verbose, print output as build proceeds, else only print if fails
|
||||
|
||||
@ -1574,14 +1642,16 @@ class Kokkos:
|
||||
mode is not optional, arch is optional
|
||||
mode = omp or cuda or phi (def = KOKKOS_DEVICES setting in Makefile )
|
||||
build Kokkos package for omp or cuda or phi
|
||||
set KOKKOS_DEVICES to "OpenMP" (omp, phi) or "Cuda, OpenMP" (cuda)
|
||||
arch = 31 (Kepler) or 21 (Fermi) (def = -arch setting in Makefile)
|
||||
sets KOKKOS_DEVICES to "OpenMP" (omp, phi) or "Cuda, OpenMP" (cuda)
|
||||
arch = number like 35 (Kepler) or 21 (Fermi)
|
||||
sets KOKKOS_ARCH to appropriate value
|
||||
"""
|
||||
|
||||
def check(self):
|
||||
print self.inlist
|
||||
if self.inlist != None and len(self.inlist) == 0:
|
||||
error("-kokkos args are invalid")
|
||||
|
||||
|
||||
if self.inlist == None: return
|
||||
if len(self.inlist) < 1: error("-kokkos args are invalid")
|
||||
self.mode = self.inlist[0]
|
||||
@ -1596,7 +1666,7 @@ class Kokkos:
|
||||
else: error("-kokkos args are invalid")
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# makefile classes for CC, MPI, JPG, PNG, FFT settings
|
||||
# makefile classes for CC, FLAGS, MPI, JPG, PNG, FFT settings
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
# Cc class
|
||||
@ -1610,7 +1680,8 @@ class Cc:
|
||||
def help(self):
|
||||
return """
|
||||
-cc compiler wrap=wcompiler
|
||||
change CC setting in makefile
|
||||
alter CC setting in Makefile.auto
|
||||
only happens if new Makefile.auto is created by use of "file" action
|
||||
compiler is required, all other args are optional
|
||||
compiler = any string with g++ or icc or icpc
|
||||
or mpi (or mpicxx, mpiCC, mpiicpc, etc)
|
||||
@ -1644,6 +1715,41 @@ class Cc:
|
||||
self.wrap = words[1]
|
||||
else: error("-cc args are invalid")
|
||||
|
||||
# Flags class
|
||||
|
||||
class Flags:
|
||||
def __init__(self,list):
|
||||
self.inlist = copy.copy(list)
|
||||
self.CC = []
|
||||
self.LINK = []
|
||||
|
||||
def help(self):
|
||||
return """
|
||||
-flags flag f1 f2 ... flag f1 f2 ...
|
||||
alter CCFLAGS or LINKFLAGS settings 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
|
||||
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)
|
||||
|
||||
# Mpi class
|
||||
|
||||
class Mpi:
|
||||
@ -1654,7 +1760,8 @@ class Mpi:
|
||||
def help(self):
|
||||
return """
|
||||
-mpi style dir=path
|
||||
change MPI settings in makefile
|
||||
alter MPI settings in Makefile.auto
|
||||
only happens if new Makefile.auto is created by use of "file" action
|
||||
style is required, all other args are optional
|
||||
style = mpi or mpich or ompi or serial
|
||||
mpi = no MPI settings (assume compiler is MPI wrapper)
|
||||
@ -1687,9 +1794,10 @@ class Fft:
|
||||
def help(self):
|
||||
return """
|
||||
-fft mode lib=libname dir=homedir idir=incdir ldir=libdir
|
||||
change FFT settings in makefile
|
||||
alter FFT settings in Makefile.auto
|
||||
only happens if new Makefile.auto is created by use of "file" action
|
||||
mode is required, all other args are optional
|
||||
removes all current FFT variable settings
|
||||
first removes all current FFT variable settings
|
||||
mode = none or fftw or fftw3 or ...
|
||||
adds -DFFT_MODE setting
|
||||
lib = name of FFT library to link with (def is libname = mode)
|
||||
@ -1727,6 +1835,8 @@ class Jpg:
|
||||
def help(self):
|
||||
return """
|
||||
-jpg flag dir=homedir idir=incdir ldir=libdir
|
||||
alter JPG settings in Makefile.auto
|
||||
only happens if new Makefile.auto is created by use of "file" action
|
||||
change JPG settings in makefile
|
||||
all args are optional, flag must come first if specified
|
||||
flag = yes or no (def = yes)
|
||||
@ -1764,7 +1874,8 @@ class Png:
|
||||
def help(self):
|
||||
return """
|
||||
-png flag dir=homedir idir=incdir ldir=libdir
|
||||
change PNG settings in makefile
|
||||
alter PNG settings in Makefile.auto
|
||||
only happens if new Makefile.auto is created by use of "file" action
|
||||
all args are optional, flag must come first if specified
|
||||
flag = yes or no (def = yes)
|
||||
include or exclude PNG support
|
||||
@ -2143,13 +2254,22 @@ while 1:
|
||||
|
||||
packages.uninstall()
|
||||
|
||||
# create output file if requested and exe action performed
|
||||
# create copy of executable if requested, and exe action performed
|
||||
|
||||
if output and actions and "exe" in actions.alist:
|
||||
txt = "cp %s/lmp_auto %s/lmp_%s" % (dir.src,dir.cwd,output.machine)
|
||||
commands.getoutput(txt)
|
||||
print "Created lmp_%s in %s" % (output.machine,dir.cwd)
|
||||
|
||||
# create copy of Makefile.auto if requested, and file or exe action performed
|
||||
|
||||
if zoutput and actions and \
|
||||
("file" in actions.alist or "exe" in actions.alist):
|
||||
txt = "cp %s/MAKE/MINE/Makefile.auto %s/MAKE/MINE/Makefile.%s" % \
|
||||
(dir.src,dir.src,zoutput.machine)
|
||||
commands.getoutput(txt)
|
||||
print "Created Makefile.%s in %s/MAKE/MINE" % (zoutput.machine,dir.src)
|
||||
|
||||
# write current Make.py command to src/Make.py.last
|
||||
|
||||
fp = open("%s/Make.py.last" % dir.src,'w')
|
||||
|
||||
Reference in New Issue
Block a user