Skip to content

Commit

Permalink
Improved OMP support in config and makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
andeplane committed Jul 29, 2017
1 parent 01db6eb commit b2d91b3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
20 changes: 14 additions & 6 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ def run_command(cmd):
os.chdir(currentPath)
# Set up LAMMPS
ompSupport = True
specifiedCompiler = None

if _platform == "darwin":
lammps_build_type = "atomify"
ompSupport = False
if len(sys.argv) > 1 and sys.argv[1] == "brew":
ompSupport = True
specifiedCompiler = sys.argv[2]
elif _platform == "win32":
print "Windows is not supported yet"
exit()
Expand Down Expand Up @@ -102,10 +106,7 @@ def run_command(cmd):
original_file = join(lammps_source_dir_src, basename.replace(".patch", ""))
run_command("patch %s < %s" % (original_file, patch_file))

if ompSupport:
shutil.copy(join(patch_path, "Makefile.atomify-omp"), join(lammps_source_dir_src, "MAKE", "Makefile.atomify"))
else:
shutil.copy(join(patch_path, "Makefile.atomify"), join(lammps_source_dir_src, "MAKE", "Makefile.atomify"))
shutil.copy(join(patch_path, "Makefile.atomify"), join(lammps_source_dir_src, "MAKE", "Makefile.atomify"))

print "\nLAMMPS was (probably) successfully patched."

Expand Down Expand Up @@ -138,5 +139,12 @@ def run_command(cmd):
print("Copying ", filename)
shutil.copy2(filename, lammps_source_dir_src)

run_command("make -j4 " + lammps_build_type + " mode=lib")
os.chdir(root_path)
if specifiedCompiler is not None:
run_command("CC="+specifiedCompiler+" OMP=1 make -j4 " + lammps_build_type + " mode=lib")
else:
if ompSupport:
run_command("OMP=1 make -j4 " + lammps_build_type + " mode=lib")
else:
run_command("make -j4 " + lammps_build_type + " mode=lib")

os.chdir(root_path)
15 changes: 14 additions & 1 deletion lammps-patch/Makefile.atomify
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@ SHELL = /bin/sh
# compiler/linker settings
# specify flags and libraries needed for your compiler

ifndef CC
CC = g++
endif

ifdef OMP
CCFLAGS = -g -O3 -fopenmp
else
CCFLAGS = -g -O3
endif

SHFLAGS = -fPIC
DEPFLAGS = -M

LINK = g++
LINK = $(CC)
ifdef OMP
LINKFLAGS = -g -O -fopenmp
else
LINKFLAGS = -g -O
endif

LIB =
SIZE = size

Expand Down

0 comments on commit b2d91b3

Please sign in to comment.