* [gentoo-science] sci-physics/lammps: question on proper integration of mpi
@ 2013-05-12 21:22 Nicolas Bock
2013-05-12 23:08 ` Christoph Junghans
0 siblings, 1 reply; 3+ messages in thread
From: Nicolas Bock @ 2013-05-12 21:22 UTC (permalink / raw
To: gentoo-science
[-- Attachment #1.1: Type: text/plain, Size: 568 bytes --]
Hi,
I recently added a lammps ebuild to the science overlay. It so far only
builds the serial version, and has very limited support for build time
options. I now added the mpi use flag and changed the ebuild so that it
builds the mpi version. I have attached a patch against master that does
this. I would like to get some feedback on those changes. Are they
acceptable in this form? What should I have done differently? How would I
go about writing an ebuild that builds both, the serial _and_ the mpi
version in case the mpi use flag is set?
Thanks already,
nick
[-- Attachment #1.2: Type: text/html, Size: 717 bytes --]
[-- Attachment #2: 0001-Added-mpi-use-flag.patch --]
[-- Type: application/octet-stream, Size: 10779 bytes --]
From ec211e8ef2497f098b2a29769b79ca3e89064657 Mon Sep 17 00:00:00 2001
From: Nicolas Bock <nicolasbock@gmail.com>
Date: Sun, 12 May 2013 15:15:19 -0600
Subject: [PATCH] Added mpi use flag.
This ebuild builds either the serial version (without the mpi use flag), or the parallel version.
Package-Manager: portage-2.2.0_alpha174
---
sci-physics/lammps/ChangeLog | 6 ++
.../lammps/files/Makefile.gentoo-serial.patch | 111 ---------------------
sci-physics/lammps/files/Makefile.gentoo.patch | 111 +++++++++++++++++++++
sci-physics/lammps/lammps-20130512.ebuild | 47 +++++----
4 files changed, 147 insertions(+), 128 deletions(-)
delete mode 100755 sci-physics/lammps/files/Makefile.gentoo-serial.patch
create mode 100755 sci-physics/lammps/files/Makefile.gentoo.patch
diff --git a/sci-physics/lammps/ChangeLog b/sci-physics/lammps/ChangeLog
index 93b6717..5b6f579 100644
--- a/sci-physics/lammps/ChangeLog
+++ b/sci-physics/lammps/ChangeLog
@@ -2,6 +2,12 @@
# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2
# $Header: $
+ 12 May 2013; Nicolas Bock <nicolasbock@gmail.com>
+ +files/Makefile.gentoo.patch, -files/Makefile.gentoo-serial.patch,
+ lammps-20130512.ebuild:
+ Added mpi use flag. This ebuild builds either the serial version (without the
+ mpi use flag), or the parallel version.
+
10 May 2013; Nicolas Bock <nicolasbock@gmail.com> lammps-20130512.ebuild:
Moved a variable definition.
diff --git a/sci-physics/lammps/files/Makefile.gentoo-serial.patch b/sci-physics/lammps/files/Makefile.gentoo-serial.patch
deleted file mode 100755
index 7b9267c..0000000
--- a/sci-physics/lammps/files/Makefile.gentoo-serial.patch
+++ /dev/null
@@ -1,111 +0,0 @@
---- /dev/null 2013-04-18 18:31:27.695818552 -0600
-+++ src/MAKE/Makefile.gentoo-serial 2013-05-09 15:24:20.000000000 -0600
-@@ -0,0 +1,108 @@
-+# gentoo-serial = Gentoo, serial code
-+
-+SHELL = /bin/sh
-+
-+# ---------------------------------------------------------------------
-+# compiler/linker settings
-+# specify flags and libraries needed for your compiler
-+
-+CC = g++
-+CCFLAGS = -g -O # -Wunused
-+SHFLAGS = -fPIC
-+DEPFLAGS = -M
-+
-+LINK = g++
-+LINKFLAGS = -g -O
-+LIB =
-+SIZE = size
-+
-+ARCHIVE = ar
-+ARFLAGS = -rc
-+SHLIBFLAGS = -shared
-+
-+# ---------------------------------------------------------------------
-+# LAMMPS-specific settings
-+# specify settings for LAMMPS features you will use
-+# if you change any -D setting, do full re-compile after "make clean"
-+
-+# LAMMPS ifdef settings, OPTIONAL
-+# see possible settings in doc/Section_start.html#2_2 (step 4)
-+
-+LMP_INC = -DLAMMPS_GZIP
-+
-+# MPI library, REQUIRED
-+# see discussion in doc/Section_start.html#2_2 (step 5)
-+# can point to dummy MPI library in src/STUBS as in Makefile.serial
-+# INC = path for mpi.h, MPI compiler settings
-+# PATH = path for MPI library
-+# LIB = name of MPI library
-+
-+MPI_INC = -I../STUBS
-+MPI_PATH = -L../STUBS
-+MPI_LIB = -lmpi_stubs
-+
-+# FFT library, OPTIONAL
-+# see discussion in doc/Section_start.html#2_2 (step 6)
-+# can be left blank to use provided KISS FFT library
-+# INC = -DFFT setting, e.g. -DFFT_FFTW, FFT compiler settings
-+# PATH = path for FFT library
-+# LIB = name of FFT library
-+
-+FFT_INC =
-+FFT_PATH =
-+FFT_LIB =
-+
-+# JPEG library, OPTIONAL
-+# see discussion in doc/Section_start.html#2_2 (step 7)
-+# only needed if -DLAMMPS_JPEG listed with LMP_INC
-+# INC = path for jpeglib.h
-+# PATH = path for JPEG library
-+# LIB = name of JPEG library
-+
-+JPG_INC =
-+JPG_PATH =
-+JPG_LIB =
-+
-+# ---------------------------------------------------------------------
-+# build rules and dependencies
-+# no need to edit this section
-+
-+include Makefile.package.settings
-+include Makefile.package
-+
-+EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) $(JPG_INC) $(PKG_SYSINC)
-+EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(JPG_PATH) $(PKG_SYSPATH)
-+EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB)
-+
-+# Path to src files
-+
-+vpath %.cpp ..
-+vpath %.h ..
-+
-+# Link target
-+
-+$(EXE): $(OBJ)
-+ $(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE)
-+ $(SIZE) $(EXE)
-+
-+# Library targets
-+
-+lib: $(OBJ)
-+ $(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
-+
-+shlib: $(OBJ)
-+ $(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \
-+ $(OBJ) $(EXTRA_LIB) $(LIB)
-+
-+# Compilation rules
-+
-+%.o:%.cpp
-+ $(CC) $(CCFLAGS) $(SHFLAGS) $(EXTRA_INC) -c $<
-+
-+%.d:%.cpp
-+ $(CC) $(CCFLAGS) $(EXTRA_INC) $(DEPFLAGS) $< > $@
-+
-+# Individual dependencies
-+
-+DEPENDS = $(OBJ:.o=.d)
-+sinclude $(DEPENDS)
diff --git a/sci-physics/lammps/files/Makefile.gentoo.patch b/sci-physics/lammps/files/Makefile.gentoo.patch
new file mode 100755
index 0000000..aea924b
--- /dev/null
+++ b/sci-physics/lammps/files/Makefile.gentoo.patch
@@ -0,0 +1,111 @@
+--- /dev/null 2013-04-18 18:31:27.695818552 -0600
++++ src/MAKE/Makefile.gentoo 2013-05-09 15:24:20.000000000 -0600
+@@ -0,0 +1,108 @@
++# gentoo-serial = Gentoo, serial code
++
++SHELL = /bin/sh
++
++# ---------------------------------------------------------------------
++# compiler/linker settings
++# specify flags and libraries needed for your compiler
++
++CC = g++
++CCFLAGS = -g -O # -Wunused
++SHFLAGS = -fPIC
++DEPFLAGS = -M
++
++LINK = g++
++LINKFLAGS = -g -O
++LIB =
++SIZE = size
++
++ARCHIVE = ar
++ARFLAGS = -rc
++SHLIBFLAGS = -shared
++
++# ---------------------------------------------------------------------
++# LAMMPS-specific settings
++# specify settings for LAMMPS features you will use
++# if you change any -D setting, do full re-compile after "make clean"
++
++# LAMMPS ifdef settings, OPTIONAL
++# see possible settings in doc/Section_start.html#2_2 (step 4)
++
++LMP_INC = -DLAMMPS_GZIP
++
++# MPI library, REQUIRED
++# see discussion in doc/Section_start.html#2_2 (step 5)
++# can point to dummy MPI library in src/STUBS as in Makefile.serial
++# INC = path for mpi.h, MPI compiler settings
++# PATH = path for MPI library
++# LIB = name of MPI library
++
++MPI_INC = -I../STUBS
++MPI_PATH = -L../STUBS
++MPI_LIB = -lmpi_stubs
++
++# FFT library, OPTIONAL
++# see discussion in doc/Section_start.html#2_2 (step 6)
++# can be left blank to use provided KISS FFT library
++# INC = -DFFT setting, e.g. -DFFT_FFTW, FFT compiler settings
++# PATH = path for FFT library
++# LIB = name of FFT library
++
++FFT_INC =
++FFT_PATH =
++FFT_LIB =
++
++# JPEG library, OPTIONAL
++# see discussion in doc/Section_start.html#2_2 (step 7)
++# only needed if -DLAMMPS_JPEG listed with LMP_INC
++# INC = path for jpeglib.h
++# PATH = path for JPEG library
++# LIB = name of JPEG library
++
++JPG_INC =
++JPG_PATH =
++JPG_LIB =
++
++# ---------------------------------------------------------------------
++# build rules and dependencies
++# no need to edit this section
++
++include Makefile.package.settings
++include Makefile.package
++
++EXTRA_INC = $(LMP_INC) $(PKG_INC) $(MPI_INC) $(FFT_INC) $(JPG_INC) $(PKG_SYSINC)
++EXTRA_PATH = $(PKG_PATH) $(MPI_PATH) $(FFT_PATH) $(JPG_PATH) $(PKG_SYSPATH)
++EXTRA_LIB = $(PKG_LIB) $(MPI_LIB) $(FFT_LIB) $(JPG_LIB) $(PKG_SYSLIB)
++
++# Path to src files
++
++vpath %.cpp ..
++vpath %.h ..
++
++# Link target
++
++$(EXE): $(OBJ)
++ $(LINK) $(LINKFLAGS) $(EXTRA_PATH) $(OBJ) $(EXTRA_LIB) $(LIB) -o $(EXE)
++ $(SIZE) $(EXE)
++
++# Library targets
++
++lib: $(OBJ)
++ $(ARCHIVE) $(ARFLAGS) $(EXE) $(OBJ)
++
++shlib: $(OBJ)
++ $(CC) $(CCFLAGS) $(SHFLAGS) $(SHLIBFLAGS) $(EXTRA_PATH) -o $(EXE) \
++ $(OBJ) $(EXTRA_LIB) $(LIB)
++
++# Compilation rules
++
++%.o:%.cpp
++ $(CC) $(CCFLAGS) $(SHFLAGS) $(EXTRA_INC) -c $<
++
++%.d:%.cpp
++ $(CC) $(CCFLAGS) $(EXTRA_INC) $(DEPFLAGS) $< > $@
++
++# Individual dependencies
++
++DEPENDS = $(OBJ:.o=.d)
++sinclude $(DEPENDS)
diff --git a/sci-physics/lammps/lammps-20130512.ebuild b/sci-physics/lammps/lammps-20130512.ebuild
index dd8c6c4..6af876d 100644
--- a/sci-physics/lammps/lammps-20130512.ebuild
+++ b/sci-physics/lammps/lammps-20130512.ebuild
@@ -15,51 +15,64 @@ SRC_URI="http://lammps.sandia.gov/tars/lammps-${LAMMPSDATE}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
-IUSE="lammps-gzip lammps-memalign package-meam package-dipole package-rigid"
+IUSE="mpi lammps-gzip lammps-memalign package-meam package-dipole package-rigid"
DEPEND=""
+use mpi && DEPEND+="virtual/mpi"
RDEPEND="${DEPEND}"
S="${WORKDIR}/${PN}-${LAMMPSDATE}"
src_prepare() {
- epatch "${FILESDIR}/Makefile.gentoo-serial.patch"
+ epatch "${FILESDIR}/Makefile.gentoo.patch"
LAMMPS_INCLUDEFLAGS=""
use lammps-gzip && LAMMPS_INCLUDEFLAGS+=" -DLAMMPS_GZIP"
use lammps-memalign && LAMMPS_INCLUDEFLAGS+=" -DLAMMPS_MEMALIGN"
+ LAMMPS_CC="$(tc-getCXX)"
+ use mpi && LAMMPS_CC="mpic++"
+
+ LAMMPS_FC="$(tc-getFC)"
+ use mpi && LAMMPS_FC="mpif90"
+
# Patch up the patch.
sed -i \
- -e "s/ARCHIVE\s*=.*$/ARCHIVE = $(tc-getAR)/" \
- -e "s/CC\s*=.*$/CC = $(tc-getCXX)/" \
- -e "s/CCFLAGS\s*=.*$/CCFLAGS = ${CXXFLAGS}/" \
- -e "s/LINK\s*=.*$/LINK = $(tc-getCXX)/" \
- -e "s/LINKFLAGS\s*=.*$/LINKFLAGS = ${LDFLAGS}/" \
- -e "s/LMP_INC\s*=.*$/LMP_INC = ${LAMMPS_INCLUDEFLAGS}/" \
- "${S}/src/MAKE/Makefile.gentoo-serial"
+ -e "s/^ARCHIVE\s*=.*$/ARCHIVE = $(tc-getAR)/" \
+ -e "s/^CC\s*=.*$/CC = ${LAMMPS_CC}/" \
+ -e "s/^CCFLAGS\s*=.*$/CCFLAGS = ${CXXFLAGS}/" \
+ -e "s/^LINK\s*=.*$/LINK = ${LAMMPS_CC}/" \
+ -e "s/^LINKFLAGS\s*=.*$/LINKFLAGS = ${LDFLAGS}/" \
+ -e "s/^LMP_INC\s*=.*$/LMP_INC = ${LAMMPS_INCLUDEFLAGS}/" \
+ "${S}/src/MAKE/Makefile.gentoo"
+
+ use mpi && sed -i \
+ -e "s/^MPI_INC\s*=.*$//" \
+ -e "s/^MPI_PATH\s*=.*$//" \
+ -e "s/^MPI_LIB\s*=.*$//" \
+ "${S}/src/MAKE/Makefile.gentoo"
# Patch up other makefiles.
use package-meam && sed -i \
- -e "s/ARCHIVE\s*=.*$/ARCHIVE = $(tc-getAR)/" \
- -e "s/F90\s*=.*$/F90 = $(tc-getFC)/" \
- -e "s/F90FLAGS\s*=.*$/F90FLAGS = ${FCFLAGS}/" \
- -e "s/LINK\s*=.*$/LINK = $(tc-getFC)/" \
- -e "s/LINKFLAGS\s*=.*$/LINKFLAGS = ${LDFLAGS}/" \
+ -e "s/^ARCHIVE\s*=.*$/ARCHIVE = $(tc-getAR)/" \
+ -e "s/^F90\s*=.*$/F90 = ${LAMMPS_FC}/" \
+ -e "s/^F90FLAGS\s*=.*$/F90FLAGS = ${FCFLAGS}/" \
+ -e "s/^LINK\s*=.*$/LINK = ${LAMMPS_FC}/" \
+ -e "s/^LINKFLAGS\s*=.*$/LINKFLAGS = ${LDFLAGS}/" \
"${S}/lib/meam/Makefile.gfortran"
}
src_compile() {
- emake -C src stubs
+ use mpi || emake -C src stubs
use package-meam && {
emake -C src yes-meam
emake -j1 -C lib/meam -f Makefile.gfortran
}
use package-dipole && emake -C src yes-dipole
use package-rigid && emake -C src yes-rigid
- emake -C src gentoo-serial
+ emake -C src gentoo
}
src_install() {
- newbin "$S/src/lmp_gentoo-serial" "lmp-serial"
+ newbin "$S/src/lmp_gentoo" "lmp"
}
--
1.8.1.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [gentoo-science] sci-physics/lammps: question on proper integration of mpi
2013-05-12 21:22 [gentoo-science] sci-physics/lammps: question on proper integration of mpi Nicolas Bock
@ 2013-05-12 23:08 ` Christoph Junghans
2013-05-13 16:22 ` Nicolas Bock
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Junghans @ 2013-05-12 23:08 UTC (permalink / raw
To: gentoo-science
Hi Nick,
thanks for your contribution.
I think there is no general answer to your question. It depends if it
is a disadvantage of running the mpi-version with 1 MPI process over
running the serial version. I imagine that LAMMPS enable some special
optimization if mpi is disabled as it can assume that everything
happens locally and no mpi message need to be send. On the other hand,
if the build of LAMMPS takes hours, one might prefer building it only
once. Do LAMMPS offer other palatalizations like OpenMP or Threads to
use multiple cores?
From a brief look at our patch I see the following issues:
- I am not sold on this Makefile patch and patching of the patch
approach, seems a bit fragile. It might be better to use the default
gcc Makefile and patch that. I prefer adding CC,CFLAGS etc, on emake
comandline, you could create a function to avoid writing it on every
emake call. (my_emake() { emake "$@" CC= CFLAGS=; } )
- sed calls need to secured with "|| die"
- DEPEND should be static, DEPEND="mpi? ( vitrual/mpi )" should do it
- virtual/fortran is missing in DEPEND or use fortran-2.eclass and
FORTRAN_NEEDED="fortran" instead.
- lammps-gzip enables normal gzip support, so the use flags should be
called gzip.
If you are unsure about some technical details in an ebuild, create a
pull request on github and somebody will give you advice in the
review.
Otherwise good job, looking forward to more commits from you,
Christoph
2013/5/12 Nicolas Bock <nicolasbock@gmail.com>:
> Hi,
>
> I recently added a lammps ebuild to the science overlay. It so far only
> builds the serial version, and has very limited support for build time
> options. I now added the mpi use flag and changed the ebuild so that it
> builds the mpi version. I have attached a patch against master that does
> this. I would like to get some feedback on those changes. Are they
> acceptable in this form? What should I have done differently? How would I go
> about writing an ebuild that builds both, the serial _and_ the mpi version
> in case the mpi use flag is set?
>
> Thanks already,
>
> nick
>
--
Christoph Junghans
http://dev.gentoo.org/~ottxor/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-science] sci-physics/lammps: question on proper integration of mpi
2013-05-12 23:08 ` Christoph Junghans
@ 2013-05-13 16:22 ` Nicolas Bock
0 siblings, 0 replies; 3+ messages in thread
From: Nicolas Bock @ 2013-05-13 16:22 UTC (permalink / raw
To: gentoo-science
[-- Attachment #1: Type: text/plain, Size: 2624 bytes --]
Hi Christoph,
thanks for the detailed answer. I have made a few changes to the ebuild,
implementing what you suggested. The only thing missing right now is a
better way to deal with the Makefile. I am working on that. In the meantime
I have created a pull request.
Thanks again,
nick
On Sun, May 12, 2013 at 5:08 PM, Christoph Junghans <ottxor@gentoo.org>wrote:
> Hi Nick,
>
> thanks for your contribution.
>
> I think there is no general answer to your question. It depends if it
> is a disadvantage of running the mpi-version with 1 MPI process over
> running the serial version. I imagine that LAMMPS enable some special
> optimization if mpi is disabled as it can assume that everything
> happens locally and no mpi message need to be send. On the other hand,
> if the build of LAMMPS takes hours, one might prefer building it only
> once. Do LAMMPS offer other palatalizations like OpenMP or Threads to
> use multiple cores?
>
> From a brief look at our patch I see the following issues:
> - I am not sold on this Makefile patch and patching of the patch
> approach, seems a bit fragile. It might be better to use the default
> gcc Makefile and patch that. I prefer adding CC,CFLAGS etc, on emake
> comandline, you could create a function to avoid writing it on every
> emake call. (my_emake() { emake "$@" CC= CFLAGS=; } )
> - sed calls need to secured with "|| die"
> - DEPEND should be static, DEPEND="mpi? ( vitrual/mpi )" should do it
> - virtual/fortran is missing in DEPEND or use fortran-2.eclass and
> FORTRAN_NEEDED="fortran" instead.
> - lammps-gzip enables normal gzip support, so the use flags should be
> called gzip.
>
> If you are unsure about some technical details in an ebuild, create a
> pull request on github and somebody will give you advice in the
> review.
>
> Otherwise good job, looking forward to more commits from you,
>
> Christoph
>
> 2013/5/12 Nicolas Bock <nicolasbock@gmail.com>:
> > Hi,
> >
> > I recently added a lammps ebuild to the science overlay. It so far only
> > builds the serial version, and has very limited support for build time
> > options. I now added the mpi use flag and changed the ebuild so that it
> > builds the mpi version. I have attached a patch against master that does
> > this. I would like to get some feedback on those changes. Are they
> > acceptable in this form? What should I have done differently? How would
> I go
> > about writing an ebuild that builds both, the serial _and_ the mpi
> version
> > in case the mpi use flag is set?
> >
> > Thanks already,
> >
> > nick
> >
>
>
>
> --
> Christoph Junghans
> http://dev.gentoo.org/~ottxor/
>
>
[-- Attachment #2: Type: text/html, Size: 3526 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-13 16:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-12 21:22 [gentoo-science] sci-physics/lammps: question on proper integration of mpi Nicolas Bock
2013-05-12 23:08 ` Christoph Junghans
2013-05-13 16:22 ` Nicolas Bock
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox