Adding package namd (#4321)
* Initial version of the namd package * Modified charm to consider compile against intel/intel-mpi * Correction of namd to compile with intel-mkl and intel compiler * Adding inclue64 in the prefix * adding property for the build directory * removing useless function build
This commit is contained in:
parent
bc2c4a14c2
commit
f06c23ef42
4 changed files with 194 additions and 21 deletions
|
@ -60,17 +60,18 @@ class Prefix(str):
|
|||
|
||||
def __new__(cls, path):
|
||||
s = super(Prefix, cls).__new__(cls, path)
|
||||
s.bin = join_path(s, 'bin')
|
||||
s.bin64 = join_path(s, 'bin64')
|
||||
s.sbin = join_path(s, 'sbin')
|
||||
s.etc = join_path(s, 'etc')
|
||||
s.include = join_path(s, 'include')
|
||||
s.lib = join_path(s, 'lib')
|
||||
s.lib64 = join_path(s, 'lib64')
|
||||
s.libexec = join_path(s, 'libexec')
|
||||
s.share = join_path(s, 'share')
|
||||
s.doc = join_path(s.share, 'doc')
|
||||
s.info = join_path(s.share, 'info')
|
||||
s.bin = join_path(s, 'bin')
|
||||
s.bin64 = join_path(s, 'bin64')
|
||||
s.sbin = join_path(s, 'sbin')
|
||||
s.etc = join_path(s, 'etc')
|
||||
s.include = join_path(s, 'include')
|
||||
s.include64 = join_path(s, 'include64')
|
||||
s.lib = join_path(s, 'lib')
|
||||
s.lib64 = join_path(s, 'lib64')
|
||||
s.libexec = join_path(s, 'libexec')
|
||||
s.share = join_path(s, 'share')
|
||||
s.doc = join_path(s.share, 'doc')
|
||||
s.info = join_path(s.share, 'info')
|
||||
|
||||
s.man = join_path(s, 'man')
|
||||
s.man1 = join_path(s.man, 'man1')
|
||||
|
|
|
@ -115,29 +115,43 @@ def install(self, spec, prefix):
|
|||
# We assume that Spack's compiler wrappers make this work. If
|
||||
# not, then we need to query the compiler vendor from Spack
|
||||
# here.
|
||||
compiler = "gcc"
|
||||
compiler = os.path.basename(self.compiler.cc)
|
||||
|
||||
options = [compiler,
|
||||
"--with-production", # Note: turn this into a variant
|
||||
"-j%d" % make_jobs,
|
||||
"--destination=%s" % prefix]
|
||||
if "+mpi" in spec:
|
||||
options.append("--basedir=%s" % spec["mpi"].prefix)
|
||||
options = [compiler]
|
||||
if compiler == 'icc':
|
||||
options.append('ifort')
|
||||
|
||||
options.extend([
|
||||
"--with-production", # Note: turn this into a variant
|
||||
"-j%d" % make_jobs,
|
||||
"--destination=%s" % prefix])
|
||||
|
||||
if 'backend=mpi' in spec:
|
||||
# in intelmpi <prefix>/include and <prefix>/lib fails so --basedir
|
||||
# cannot be used
|
||||
options.extend([
|
||||
'--incdir={0}'.format(incdir)
|
||||
for incdir in spec["mpi"].headers.directories
|
||||
])
|
||||
options.extend([
|
||||
'--libdir={0}'.format(libdir)
|
||||
for libdir in spec["mpi"].libs.directories
|
||||
])
|
||||
if "+papi" in spec:
|
||||
options.extend(["papi", "--basedir=%s" % spec["papi"].prefix])
|
||||
if "+smp" in spec:
|
||||
if "+multicore" in spec:
|
||||
if 'backend=multicore' in spec:
|
||||
# This is a Charm++ limitation; it would lead to a
|
||||
# build error
|
||||
raise InstallError("Cannot combine +smp with +multicore")
|
||||
options.append("smp")
|
||||
if "+tcp" in spec:
|
||||
if "+net" not in spec:
|
||||
if 'backend=net' not in spec:
|
||||
# This is a Charm++ limitation; it would lead to a
|
||||
# build error
|
||||
raise InstallError(
|
||||
"The +tcp variant requires "
|
||||
"the +net communication mechanism")
|
||||
"the backend=net communication mechanism")
|
||||
options.append("tcp")
|
||||
if "+shared" in spec:
|
||||
options.append("--build-shared")
|
||||
|
|
|
@ -54,6 +54,13 @@ def mpi_libs(self):
|
|||
libraries, root=self.prefix.lib64, shared=True, recurse=True
|
||||
)
|
||||
|
||||
@property
|
||||
def mpi_headers(self):
|
||||
# recurse from self.prefix will find too many things for all the
|
||||
# supported sub-architectures like 'mic'
|
||||
return find_headers(
|
||||
'mpi', root=self.prefix.include64, recurse=False)
|
||||
|
||||
def install(self, spec, prefix):
|
||||
self.intel_prefix = prefix
|
||||
IntelInstaller.install(self, spec, prefix)
|
||||
|
|
151
var/spack/repos/builtin/packages/namd/package.py
Normal file
151
var/spack/repos/builtin/packages/namd/package.py
Normal file
|
@ -0,0 +1,151 @@
|
|||
##############################################################################
|
||||
# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the LICENSE file for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License (as
|
||||
# published by the Free Software Foundation) version 2.1, February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
import platform
|
||||
import shutil
|
||||
import sys
|
||||
import os
|
||||
from spack import *
|
||||
|
||||
|
||||
class Namd(MakefilePackage):
|
||||
"""NAMDis a parallel molecular dynamics code designed for
|
||||
high-performance simulation of large biomolecular systems."""
|
||||
|
||||
homepage = "http://www.ks.uiuc.edu/Research/namd/"
|
||||
url = "file://{0}/NAMD_2.12_Source.tar.gz".format(os.getcwd())
|
||||
|
||||
version('2.12', '2a1191909b1ab03bf0205971ad4d8ee9')
|
||||
|
||||
variant('fftw', default='3', values=('none', '2', '3', 'mkl'),
|
||||
description='Enable the use of FFTW/FFTW3/MKL FFT')
|
||||
|
||||
variant('interface', default='none', values=('none', 'tcl', 'python'),
|
||||
description='Enables TCL and/or python interface')
|
||||
|
||||
depends_on('charm')
|
||||
|
||||
depends_on('fftw@:2.99', when="fftw=2")
|
||||
depends_on('fftw@3:', when="fftw=3")
|
||||
|
||||
depends_on('intel-mkl', when="fftw=mkl")
|
||||
|
||||
depends_on('tcl', when='interface=tcl')
|
||||
|
||||
depends_on('tcl', when='interface=python')
|
||||
depends_on('python', when='interface=python')
|
||||
|
||||
def _copy_arch_file(self, lib):
|
||||
config_filename = 'arch/{0}.{1}'.format(self.arch, lib)
|
||||
shutil.copy('arch/Linux-x86_64.{0}'.format(lib),
|
||||
config_filename)
|
||||
if lib == 'tcl':
|
||||
filter_file(r'-ltcl8\.5',
|
||||
'-ltcl{0}'.format(self.spec['tcl'].version.up_to(2)),
|
||||
config_filename)
|
||||
|
||||
def _append_option(self, opts, lib):
|
||||
if lib != 'python':
|
||||
self._copy_arch_file(lib)
|
||||
spec = self.spec
|
||||
opts.extend([
|
||||
'--with-{0}'.format(lib),
|
||||
'--{0}-prefix'.format(lib), spec[lib].prefix
|
||||
])
|
||||
|
||||
@property
|
||||
def arch(self):
|
||||
plat = sys.platform
|
||||
if plat.startswith("linux"):
|
||||
plat = "linux"
|
||||
march = platform.machine()
|
||||
return '{0}-{1}'.format(plat, march)
|
||||
|
||||
@property
|
||||
def build_directory(self):
|
||||
return '{0}-spack'.format(self.arch)
|
||||
|
||||
def edit(self, spec, prefix):
|
||||
with working_dir('arch'):
|
||||
with open('{0}.arch'.format(self.build_directory), 'w') as fh:
|
||||
# this options are take from the default provided
|
||||
# configuration files
|
||||
optims_opts = {
|
||||
'gcc': '-m64 -O3 -fexpensive-optimizations -ffast-math',
|
||||
'intel': '-O2 -ip'
|
||||
}
|
||||
|
||||
optim_opts = optims_opts[self.compiler.name] \
|
||||
if self.compiler.name in optims_opts else ''
|
||||
|
||||
fh.write('\n'.join([
|
||||
'NAMD_ARCH = {0}'.format(self.arch),
|
||||
'CHARMARCH = ',
|
||||
'CXX = {0.cxx} {0.cxx11_flag}'.format(
|
||||
self.compiler),
|
||||
'CXXOPTS = {0}'.format(optim_opts),
|
||||
'CC = {0}'.format(self.compiler.cc),
|
||||
'COPTS = {0}'.format(optim_opts),
|
||||
''
|
||||
]))
|
||||
|
||||
self._copy_arch_file('base')
|
||||
|
||||
opts = ['--charm-base', spec['charm'].prefix]
|
||||
fftw_version = spec.variants['fftw'].value
|
||||
if fftw_version == 'none':
|
||||
opts.append('--without-fftw')
|
||||
elif fftw_version == 'mkl':
|
||||
self._append_option(opts, 'mkl')
|
||||
else:
|
||||
_fftw = 'fftw{0}'.format('' if fftw_version == '2' else '3')
|
||||
|
||||
self._copy_arch_file(_fftw)
|
||||
opts.extend(['--with-{0}'.format(_fftw),
|
||||
'--fftw-prefix', spec['fftw'].prefix])
|
||||
|
||||
interface_type = spec.variants['interface'].value
|
||||
if interface_type != 'none':
|
||||
self._append_option(opts, 'tcl')
|
||||
|
||||
if interface_type == 'python':
|
||||
self._append_option(opts, 'python')
|
||||
else:
|
||||
opts.extend([
|
||||
'--without-tcl',
|
||||
'--without-python'
|
||||
])
|
||||
|
||||
config = Executable('./config')
|
||||
|
||||
config(self.build_directory, *opts)
|
||||
|
||||
def install(self, spec, prefix):
|
||||
with working_dir(self.build_directory):
|
||||
mkdirp(prefix.bin)
|
||||
install('namd2', prefix.bin)
|
||||
|
||||
# I'm not sure this is a good idea or if an autoload of the charm
|
||||
# module would not be better.
|
||||
install('charmrun', prefix.bin)
|
Loading…
Reference in a new issue