[cp2k] build psmp variants (MPI+OpenMP)
Dominik Mierzejewski
rathann at fedoraproject.org
Tue Jul 2 22:34:56 UTC 2013
commit cd07234edba30d52cf2a14b943246f1c2885f92b
Author: Dominik Mierzejewski <rpm at greysector.net>
Date: Wed Jul 3 00:34:12 2013 +0200
build psmp variants (MPI+OpenMP)
- move ssmp build to main package and drop smp subpackage
- drop local config files, patch upstream's and symlink when necessary
- save the output of tools/get_arch_code and re-use it
Linux-gfortran-openmpi.popt | 21 ------------
Linux-i686-gfortran.sopt | 21 ------------
Linux-i686-gfortran.ssmp | 21 ------------
cp2k-rpm.patch | 50 ++++++++++++++++++++++++----
cp2k.spec | 75 ++++++++++++++++++++++--------------------
5 files changed, 82 insertions(+), 106 deletions(-)
---
diff --git a/cp2k-rpm.patch b/cp2k-rpm.patch
index 8b32da6..4945c74 100644
--- a/cp2k-rpm.patch
+++ b/cp2k-rpm.patch
@@ -1,6 +1,42 @@
+diff -up cp2k-2.4/arch/Linux-x86-64-gfortran.popt.r cp2k-2.4/arch/Linux-x86-64-gfortran.popt
+--- cp2k-2.4/arch/Linux-x86-64-gfortran.popt.r 2013-04-17 11:28:09.000000000 +0200
++++ cp2k-2.4/arch/Linux-x86-64-gfortran.popt 2013-07-02 21:46:11.102063718 +0200
+@@ -12,9 +12,10 @@ LD = mpif90
+ AR = ar -r
+
+ CPPFLAGS =
+-DFLAGS = -D__GFORTRAN -D__FFTSG -D__LIBINT -D__FFTW3 -D__parallel -D__SCALAPACK -D__BLACS -D__HAS_smm_dnn -D__LIBXC2
+-FCFLAGS = -O3 -march=native -ffast-math -funroll-loops -g -ffree-form $(DFLAGS)
+-LDFLAGS = $(FCFLAGS) -L/data/vjoost/libint/install/lib/ -L/data/vjoost/libsmm/lib/ -L/opt/intel/composerxe-2011.3.174/mkl/lib/intel64 -L/data/vjoost/libxc-2.0.1/install/lib
+-LIBS = -lsmm_dnn -lderiv -lint -lstdc++ -lfftw3 -lmkl_gf_lp64 -lmkl_scalapack_lp64 -lmkl_blacs_openmpi_lp64 -lmkl_sequential -lmkl_core -lxc
++DFLAGS = -D__GFORTRAN -D__FFTSG -D__LIBINT -D__FFTW3 -D__parallel -D__SCALAPACK -D__BLACS -D__LIBXC2 -D__LIBINT_MAX_AM=8 -D__LIBDERIV_MAX_AM1=6
++OPTFLAGS = -O3 -march=native -ffast-math -funroll-loops -g
++FCFLAGS = $(OPTFLAGS) -ffree-form -ffree-line-length-none $(DFLAGS)
++LDFLAGS = $(FCFLAGS)
++LIBS = -lderiv -lint -lfftw3 -lstdc++ -llapack -lscalapack -lf77blas -lmpiblacsF77init -lmpiblacs -lmpiblacsCinit -lxc
+
+ OBJECTS_ARCHITECTURE = machine_gfortran.o
+diff -up cp2k-2.4/arch/Linux-x86-64-gfortran.psmp.r cp2k-2.4/arch/Linux-x86-64-gfortran.psmp
+--- cp2k-2.4/arch/Linux-x86-64-gfortran.psmp.r 2013-04-17 11:28:09.000000000 +0200
++++ cp2k-2.4/arch/Linux-x86-64-gfortran.psmp 2013-07-02 22:05:27.872818114 +0200
+@@ -13,9 +13,10 @@ LD = mpif90
+ AR = ar -r
+
+ CPPFLAGS =
+-DFLAGS = -D__GFORTRAN -D__FFTSG -D__LIBINT -D__FFTW3 -D__parallel -D__SCALAPACK -D__BLACS -D__HAS_smm_dnn -D__LIBXC2
+-FCFLAGS = -fopenmp -O3 -march=native -ffast-math -funroll-loops -g -ffree-form $(DFLAGS)
+-LDFLAGS = $(FCFLAGS) -L/data/vjoost/libint/install/lib/ -L/data/vjoost/libsmm/lib/ -L/opt/intel/composerxe-2011.3.174/mkl/lib/intel64 -L/data/vjoost/libxc-2.0.1/install/lib
+-LIBS = -lsmm_dnn -lderiv -lint -lstdc++ -lfftw3_threads -lfftw3 -lmkl_gf_lp64 -lmkl_scalapack_lp64 -lmkl_blacs_openmpi_lp64 -lmkl_sequential -lmkl_core -lxc
++DFLAGS = -D__GFORTRAN -D__FFTSG -D__LIBINT -D__FFTW3 -D__parallel -D__SCALAPACK -D__BLACS -D__LIBXC2 -D__LIBINT_MAX_AM=8 -D__LIBDERIV_MAX_AM1=6
++OPTFLAGS = -fopenmp -O3 -march=native -ffast-math -funroll-loops -g
++FCFLAGS = $(OPTFLAGS) -ffree-form -ffree-line-length-none $(DFLAGS)
++LDFLAGS = $(FCFLAGS)
++LIBS = -lderiv -lint -lfftw3_omp -lfftw3 -lstdc++ -llapack -lscalapack -lf77blas -lmpiblacsF77init -lmpiblacs -lmpiblacsCinit -lxc
+
+ OBJECTS_ARCHITECTURE = machine_gfortran.o
diff -up cp2k-2.4/arch/Linux-x86-64-gfortran.sopt.r cp2k-2.4/arch/Linux-x86-64-gfortran.sopt
---- cp2k-2.4/arch/Linux-x86-64-gfortran.sopt.r 2013-04-18 12:10:47.000000000 +0200
-+++ cp2k-2.4/arch/Linux-x86-64-gfortran.sopt 2013-04-18 12:19:18.000000000 +0200
+--- cp2k-2.4/arch/Linux-x86-64-gfortran.sopt.r 2013-04-17 11:28:09.000000000 +0200
++++ cp2k-2.4/arch/Linux-x86-64-gfortran.sopt 2013-06-19 21:59:08.051612836 +0200
@@ -12,9 +12,10 @@ LD = gfortran
AR = ar -r
@@ -17,9 +53,9 @@ diff -up cp2k-2.4/arch/Linux-x86-64-gfortran.sopt.r cp2k-2.4/arch/Linux-x86-64-g
OBJECTS_ARCHITECTURE = machine_gfortran.o
diff -up cp2k-2.4/arch/Linux-x86-64-gfortran.ssmp.r cp2k-2.4/arch/Linux-x86-64-gfortran.ssmp
---- cp2k-2.4/arch/Linux-x86-64-gfortran.ssmp.r 2013-04-18 12:10:47.000000000 +0200
-+++ cp2k-2.4/arch/Linux-x86-64-gfortran.ssmp 2013-04-18 12:24:17.000000000 +0200
-@@ -12,9 +11,10 @@ LD = gfortran
+--- cp2k-2.4/arch/Linux-x86-64-gfortran.ssmp.r 2013-04-17 11:28:09.000000000 +0200
++++ cp2k-2.4/arch/Linux-x86-64-gfortran.ssmp 2013-06-19 21:59:08.051612836 +0200
+@@ -12,9 +12,10 @@ LD = gfortran
AR = ar -r
CPPFLAGS =
@@ -36,7 +72,7 @@ diff -up cp2k-2.4/arch/Linux-x86-64-gfortran.ssmp.r cp2k-2.4/arch/Linux-x86-64-g
OBJECTS_ARCHITECTURE = machine_gfortran.o
diff -up cp2k-2.4/makefiles/Makefile.r cp2k-2.4/makefiles/Makefile
--- cp2k-2.4/makefiles/Makefile.r 2013-05-27 13:12:21.000000000 +0200
-+++ cp2k-2.4/makefiles/Makefile 2013-06-17 18:14:52.704045939 +0200
++++ cp2k-2.4/makefiles/Makefile 2013-06-19 21:59:08.051612836 +0200
@@ -96,17 +96,17 @@ CLEAN_TARGETS = $(addsuffix /clean ,$(VE
# lists the targets that are not files
#
@@ -114,7 +150,7 @@ diff -up cp2k-2.4/makefiles/Makefile.r cp2k-2.4/makefiles/Makefile
# the rule how to generate the .o from the .F
diff -up cp2k-2.4/tools/do_regtest.r cp2k-2.4/tools/do_regtest
--- cp2k-2.4/tools/do_regtest.r 2012-08-21 10:25:41.000000000 +0200
-+++ cp2k-2.4/tools/do_regtest 2013-06-17 18:09:22.516209901 +0200
++++ cp2k-2.4/tools/do_regtest 2013-06-19 21:59:08.051612836 +0200
@@ -103,8 +103,8 @@ leakcheck="NO"
# *** how to execute an input file [ cp2k_prefix input cp2k_postfix ]
diff --git a/cp2k.spec b/cp2k.spec
index 806581a..a9fed19 100644
--- a/cp2k.spec
+++ b/cp2k.spec
@@ -3,7 +3,7 @@
Name: cp2k
Version: 2.4
-Release: 2%{?dist}
+Release: 3%{?dist}
Group: Applications/Engineering
Summary: A molecular dynamics engine capable of classical and Car-Parrinello simulations
License: GPLv2+
@@ -14,17 +14,11 @@ Source0: cp2k-%{version}-%{snapshot}.tar.bz2
%else
Source0: http://downloads.sourceforge.net/project/cp2k/cp2k-%{version}.tar.bz2
%endif
-# custom openmpi arch file
-# also works for mpich2 and possibly others
-# only assumption for mpi library: fortran compiler is named mpif90
-Source1: Linux-gfortran-openmpi.popt
-Source2: Linux-i686-gfortran.ssmp
-Source3: Linux-i686-gfortran.sopt
Source4: cp2k-snapshot.sh
# patch to:
# use rpm optflags
# link with atlas instead of vanilla blas/lapack
-# link with libint
+# build with libint and libxc
# use external makedepf90
# skip compilation during regtests
Patch0: %{name}-rpm.patch
@@ -38,6 +32,8 @@ BuildRequires: libxc-devel
BuildRequires: makedepf90
BuildRequires: /bin/hostname
Requires: %{name}-common = %{version}-%{release}
+Obsoletes: %{name}-smp < 2.4-3
+Provides: %{name}-smp = %{version}-%{release}
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%global cp2k_desc_base \
@@ -51,17 +47,7 @@ many-body potentials.
%description
%{cp2k_desc_base}
-This package contains the single process version.
-
-%package smp
-Group: Applications/Engineering
-Summary: Molecular simulations software - OpenMP version
-Requires: %{name}-common = %{version}-%{release}
-
-%description smp
-%{cp2k_desc_base}
-
-This package contains the multi-threaded version (using OpenMP).
+This package contains the non-MPI single process and multi-threaded versions.
%package openmpi
Group: Applications/Engineering
@@ -76,7 +62,8 @@ Requires: scalapack-openmpi
%description openmpi
%{cp2k_desc_base}
-This package contains the multi-threaded version (using OpenMPI).
+This package contains the parallel single- and multi-threaded versions
+using OpenMPI.
%package mpich2
Group: Applications/Engineering
@@ -91,7 +78,8 @@ Requires: scalapack-mpich2
%description mpich2
%{cp2k_desc_base}
-This package contains the multi-threaded version (using mpich2).
+This package contains the parallel single- and multi-threaded versions
+using mpich2.
%package common
Group: Applications/Engineering
@@ -104,43 +92,53 @@ This package contains the documentation and the manual.
%prep
%setup -q
-cp -p %{SOURCE1} arch/
-cp -p %{SOURCE1} arch/Linux-gfortran-mpich2.popt
-cp -p %{SOURCE2} arch/
-cp -p %{SOURCE3} arch/
+TARGET=$(tools/get_arch_code)
+%ifnarch x86_64
+ln -s Linux-x86-64-gfortran.sopt arch/${TARGET}.sopt
+ln -s Linux-x86-64-gfortran.ssmp arch/${TARGET}.ssmp
+%endif
+ln -s Linux-x86-64-gfortran.popt arch/${TARGET}-openmpi.popt
+ln -s Linux-x86-64-gfortran.popt arch/${TARGET}-mpich2.popt
+ln -s Linux-x86-64-gfortran.psmp arch/${TARGET}-openmpi.psmp
+ln -s Linux-x86-64-gfortran.psmp arch/${TARGET}-mpich2.psmp
%patch0 -p1 -b .r
rm -r tools/makedepf90
chmod -x src/harris_{functional,{env,energy}_types}.F
# fix crashes in fftw on i686
%ifarch i686
-sed -i 's/-D__FFTW3/-D__FFTW3 -D__FFTW3_UNALIGNED/g' arch/Linux-i686-gfortran* arch/Linux-gfortran-{mpich2,openmpi}.popt
+sed -i 's/-D__FFTW3/-D__FFTW3 -D__FFTW3_UNALIGNED/g' arch/Linux-i686-gfortran*
%endif
%build
+TARGET=$(tools/get_arch_code)
pushd makefiles
%{_openmpi_load}
- make OPTFLAGS="%{optflags} -L%{_libdir}/atlas" %{?_smp_mflags} ARCH="Linux-gfortran-openmpi" VERSION=popt
+ make OPTFLAGS="%{optflags} -L%{_libdir}/atlas" %{?_smp_mflags} ARCH="${TARGET}-openmpi" VERSION=popt
+ make OPTFLAGS="%{optflags} -L%{_libdir}/atlas" %{?_smp_mflags} ARCH="${TARGET}-openmpi" VERSION=psmp
%{_openmpi_unload}
%{_mpich2_load}
- make OPTFLAGS="%{optflags} -L%{_libdir}/atlas" %{?_smp_mflags} ARCH="Linux-gfortran-mpich2" VERSION=popt
+ make OPTFLAGS="%{optflags} -L%{_libdir}/atlas" %{?_smp_mflags} ARCH="${TARGET}-mpich2" VERSION=popt
+ make OPTFLAGS="%{optflags} -L%{_libdir}/atlas" %{?_smp_mflags} ARCH="${TARGET}-mpich2" VERSION=psmp
%{_mpich2_unload}
make OPTFLAGS="%{optflags} -L%{_libdir}/atlas" %{?_smp_mflags} sopt ssmp
popd
%install
-rm -rf %{buildroot}
+TARGET=$(tools/get_arch_code)
install -d %{buildroot}%{_bindir}
%{_openmpi_load}
mkdir -p %{buildroot}%{_libdir}/openmpi%{?_opt_cc_suffix}/bin/
- install -pm755 exe/Linux-gfortran-openmpi/cp2k.popt %{buildroot}%{_libdir}/openmpi%{?_opt_cc_suffix}/bin/cp2k.popt_openmpi
+ install -pm755 exe/${TARGET}-openmpi/cp2k.popt %{buildroot}%{_libdir}/openmpi%{?_opt_cc_suffix}/bin/cp2k.popt_openmpi
+ install -pm755 exe/${TARGET}-openmpi/cp2k.psmp %{buildroot}%{_libdir}/openmpi%{?_opt_cc_suffix}/bin/cp2k.psmp_openmpi
%{_openmpi_unload}
%{_mpich2_load}
mkdir -p %{buildroot}%{_libdir}/mpich2%{?_opt_cc_suffix}/bin/
- install -pm755 exe/Linux-gfortran-mpich2/cp2k.popt %{buildroot}%{_libdir}/mpich2%{?_opt_cc_suffix}/bin/cp2k.popt_mpich2
+ install -pm755 exe/${TARGET}-mpich2/cp2k.popt %{buildroot}%{_libdir}/mpich2%{?_opt_cc_suffix}/bin/cp2k.popt_mpich2
+ install -pm755 exe/${TARGET}-mpich2/cp2k.psmp %{buildroot}%{_libdir}/mpich2%{?_opt_cc_suffix}/bin/cp2k.psmp_mpich2
%{_mpich2_unload}
-install -pm755 exe/`tools/get_arch_code`/cp2k.sopt %{buildroot}%{_bindir}
-install -pm755 exe/`tools/get_arch_code`/cp2k.ssmp %{buildroot}%{_bindir}
+install -pm755 exe/${TARGET}/cp2k.sopt %{buildroot}%{_bindir}
+install -pm755 exe/${TARGET}/cp2k.ssmp %{buildroot}%{_bindir}
%clean
rm -rf %{buildroot}
@@ -169,20 +167,25 @@ popd
%files
%defattr(-,root,root,-)
%{_bindir}/cp2k.sopt
-
-%files smp
-%defattr(-,root,root,-)
%{_bindir}/cp2k.ssmp
%files openmpi
%defattr(-,root,root,-)
%{_libdir}/openmpi%{?_opt_cc_suffix}/bin/cp2k.popt_openmpi
+%{_libdir}/openmpi%{?_opt_cc_suffix}/bin/cp2k.psmp_openmpi
%files mpich2
%defattr(-,root,root,-)
%{_libdir}/mpich2%{?_opt_cc_suffix}/bin/cp2k.popt_mpich2
+%{_libdir}/mpich2%{?_opt_cc_suffix}/bin/cp2k.psmp_mpich2
%changelog
+* Tue Jul 02 2013 Dominik Mierzejewski <rpm at greysector.net> - 2.4-3
+- build psmp variants (MPI+OpenMP)
+- move ssmp build to main package and drop smp subpackage
+- drop local config files, patch upstream's and symlink when necessary
+- save the output of tools/get_arch_code and re-use it
+
* Wed Jun 19 2013 Dominik Mierzejewski <rpm at greysector.net> - 2.4-2
- add MPI implementation suffix back to MPI binaries (required by guidelines)
More information about the scm-commits
mailing list