2016-05-12 12:22:25 +08:00
|
|
|
##############################################################################
|
|
|
|
# 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
|
|
|
|
##############################################################################
|
2014-02-08 09:29:10 +08:00
|
|
|
from spack import *
|
2017-03-17 22:09:09 +08:00
|
|
|
import sys
|
2015-10-27 20:23:15 +08:00
|
|
|
|
2016-06-01 22:43:08 +08:00
|
|
|
|
2014-02-08 09:29:10 +08:00
|
|
|
class Mvapich2(Package):
|
2015-10-29 17:45:29 +08:00
|
|
|
"""MVAPICH2 is an MPI implementation for Infiniband networks."""
|
2014-02-08 09:29:10 +08:00
|
|
|
homepage = "http://mvapich.cse.ohio-state.edu/"
|
2016-09-15 10:42:57 +08:00
|
|
|
url = "http://mvapich.cse.ohio-state.edu/download/mvapich/mv2/mvapich2-2.2.tar.gz"
|
2017-04-04 02:04:42 +08:00
|
|
|
list_url = "http://mvapich.cse.ohio-state.edu/downloads/"
|
2014-02-08 09:29:10 +08:00
|
|
|
|
2017-04-04 02:04:42 +08:00
|
|
|
# Newer alpha release
|
|
|
|
version('2.3a', '87c3fbf8a755b53806fa9ecb21453445')
|
|
|
|
|
|
|
|
# Prefer the latest stable release
|
|
|
|
version('2.2', '939b65ebe5b89a5bc822cdab0f31f96e', preferred=True)
|
2016-09-15 10:42:57 +08:00
|
|
|
version('2.1', '0095ceecb19bbb7fb262131cb9c2cdd6')
|
|
|
|
version('2.0', '9fbb68a4111a8b6338e476dc657388b4')
|
|
|
|
version('1.9', '5dc58ed08fd3142c260b70fe297e127c')
|
2015-10-27 20:23:15 +08:00
|
|
|
|
2014-07-11 07:55:38 +08:00
|
|
|
patch('ad_lustre_rwcontig_open_source.patch', when='@1.9')
|
|
|
|
|
2015-10-27 20:23:15 +08:00
|
|
|
provides('mpi@:2.2', when='@1.9') # MVAPICH2-1.9 supports MPI 2.2
|
|
|
|
provides('mpi@:3.0', when='@2.0:') # MVAPICH2-2.0 supports MPI 3.0
|
2014-02-08 09:29:10 +08:00
|
|
|
|
2016-08-10 16:50:00 +08:00
|
|
|
variant('debug', default=False,
|
|
|
|
description='Enable debug info and error messages at run-time')
|
2014-07-11 07:55:38 +08:00
|
|
|
|
2015-11-09 20:58:34 +08:00
|
|
|
##########
|
2016-06-01 22:43:08 +08:00
|
|
|
# TODO : Process managers should be grouped into the same variant,
|
|
|
|
# as soon as variant capabilities will be extended See
|
|
|
|
# https://groups.google.com/forum/#!topic/spack/F8-f8B4_0so
|
2015-11-09 22:45:23 +08:00
|
|
|
SLURM = 'slurm'
|
|
|
|
HYDRA = 'hydra'
|
|
|
|
GFORKER = 'gforker'
|
|
|
|
REMSHELL = 'remshell'
|
|
|
|
SLURM_INCOMPATIBLE_PMS = (HYDRA, GFORKER, REMSHELL)
|
2016-08-10 16:50:00 +08:00
|
|
|
variant(SLURM, default=False,
|
|
|
|
description='Set slurm as the only process manager')
|
|
|
|
variant(HYDRA, default=False,
|
|
|
|
description='Set hydra as one of the process managers')
|
|
|
|
variant(GFORKER, default=False,
|
|
|
|
description='Set gforker as one of the process managers')
|
|
|
|
variant(REMSHELL, default=False,
|
|
|
|
description='Set remshell as one of the process managers')
|
2015-11-09 20:58:34 +08:00
|
|
|
##########
|
2014-02-08 09:29:10 +08:00
|
|
|
|
2015-11-09 21:35:54 +08:00
|
|
|
##########
|
2016-06-01 22:43:08 +08:00
|
|
|
# TODO : Network types should be grouped into the same variant, as
|
|
|
|
# soon as variant capabilities will be extended
|
2015-11-09 22:45:23 +08:00
|
|
|
PSM = 'psm'
|
|
|
|
SOCK = 'sock'
|
|
|
|
NEMESISIBTCP = 'nemesisibtcp'
|
|
|
|
NEMESISIB = 'nemesisib'
|
|
|
|
NEMESIS = 'nemesis'
|
2016-01-20 02:46:15 +08:00
|
|
|
MRAIL = 'mrail'
|
2015-11-09 22:45:23 +08:00
|
|
|
SUPPORTED_NETWORKS = (PSM, SOCK, NEMESIS, NEMESISIB, NEMESISIBTCP)
|
2016-08-10 16:50:00 +08:00
|
|
|
variant(
|
|
|
|
PSM, default=False,
|
|
|
|
description='Configure for QLogic PSM-CH3')
|
|
|
|
variant(
|
|
|
|
SOCK, default=False,
|
|
|
|
description='Configure for TCP/IP-CH3')
|
|
|
|
variant(
|
|
|
|
NEMESISIBTCP, default=False,
|
|
|
|
description='Configure for both OFA-IB-Nemesis and TCP/IP-Nemesis')
|
|
|
|
variant(
|
|
|
|
NEMESISIB, default=False,
|
|
|
|
description='Configure for OFA-IB-Nemesis')
|
|
|
|
variant(
|
|
|
|
NEMESIS, default=False,
|
|
|
|
description='Configure for TCP/IP-Nemesis')
|
|
|
|
variant(
|
|
|
|
MRAIL, default=False,
|
|
|
|
description='Configure for OFA-IB-CH3')
|
2015-11-09 21:35:54 +08:00
|
|
|
##########
|
|
|
|
|
2015-11-09 22:45:23 +08:00
|
|
|
# FIXME : CUDA support is missing
|
2016-09-15 10:42:57 +08:00
|
|
|
depends_on('bison')
|
2017-03-17 22:09:09 +08:00
|
|
|
depends_on('libpciaccess', when=(sys.platform != 'darwin'))
|
2015-11-09 22:45:23 +08:00
|
|
|
|
2016-01-20 02:46:15 +08:00
|
|
|
def url_for_version(self, version):
|
|
|
|
base_url = "http://mvapich.cse.ohio-state.edu/download"
|
|
|
|
if version < Version('2.0'):
|
|
|
|
return "%s/mvapich2/mv2/mvapich2-%s.tar.gz" % (base_url, version)
|
|
|
|
else:
|
|
|
|
return "%s/mvapich/mv2/mvapich2-%s.tar.gz" % (base_url, version)
|
|
|
|
|
2015-11-09 22:45:23 +08:00
|
|
|
@staticmethod
|
|
|
|
def enabled(x):
|
2016-06-01 22:43:08 +08:00
|
|
|
"""Given a variant name returns the string that means the variant is
|
|
|
|
enabled
|
2015-11-09 22:45:23 +08:00
|
|
|
|
|
|
|
:param x: variant name
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
return '+' + x
|
2014-07-11 07:55:38 +08:00
|
|
|
|
2015-11-09 22:55:44 +08:00
|
|
|
def set_build_type(self, spec, configure_args):
|
2016-06-01 22:43:08 +08:00
|
|
|
"""Appends to configure_args the flags that depends only on the build
|
|
|
|
type (i.e. release or debug)
|
2014-07-11 07:55:38 +08:00
|
|
|
|
2015-10-27 20:23:15 +08:00
|
|
|
:param spec: spec
|
|
|
|
:param configure_args: list of current configure arguments
|
|
|
|
"""
|
2014-07-11 07:55:38 +08:00
|
|
|
if '+debug' in spec:
|
2015-10-27 20:23:15 +08:00
|
|
|
build_type_options = [
|
|
|
|
"--disable-fast",
|
|
|
|
"--enable-error-checking=runtime",
|
2015-11-09 21:35:54 +08:00
|
|
|
"--enable-error-messages=all",
|
2016-06-01 22:43:08 +08:00
|
|
|
# Permits debugging with TotalView
|
|
|
|
"--enable-g=dbg", "--enable-debuginfo"
|
2015-10-27 20:23:15 +08:00
|
|
|
]
|
2014-07-11 07:55:38 +08:00
|
|
|
else:
|
2015-10-27 20:23:15 +08:00
|
|
|
build_type_options = ["--enable-fast=all"]
|
2015-11-09 20:58:34 +08:00
|
|
|
|
2015-10-27 20:23:15 +08:00
|
|
|
configure_args.extend(build_type_options)
|
|
|
|
|
|
|
|
def set_process_manager(self, spec, configure_args):
|
2016-06-01 22:43:08 +08:00
|
|
|
"""Appends to configure_args the flags that will enable the
|
|
|
|
appropriate process managers
|
2015-10-27 20:23:15 +08:00
|
|
|
|
|
|
|
:param spec: spec
|
|
|
|
:param configure_args: list of current configure arguments
|
|
|
|
"""
|
2016-06-01 22:43:08 +08:00
|
|
|
# Check that slurm variant is not activated together with
|
|
|
|
# other pm variants
|
|
|
|
has_slurm_incompatible_variants = \
|
|
|
|
any(self.enabled(x) in spec
|
|
|
|
for x in Mvapich2.SLURM_INCOMPATIBLE_PMS)
|
|
|
|
|
|
|
|
if self.enabled(Mvapich2.SLURM) in spec and \
|
|
|
|
has_slurm_incompatible_variants:
|
|
|
|
raise RuntimeError(" %s : 'slurm' cannot be activated \
|
|
|
|
together with other process managers" % self.name)
|
2015-11-09 20:58:34 +08:00
|
|
|
|
|
|
|
process_manager_options = []
|
2016-06-01 21:58:00 +08:00
|
|
|
# See: http://slurm.schedmd.com/mpi_guide.html#mvapich2
|
2015-11-09 22:45:23 +08:00
|
|
|
if self.enabled(Mvapich2.SLURM) in spec:
|
2016-06-01 21:58:00 +08:00
|
|
|
if self.version > Version('2.0'):
|
|
|
|
process_manager_options = [
|
|
|
|
"--with-pmi=pmi2",
|
|
|
|
"--with-pm=slurm"
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
process_manager_options = [
|
|
|
|
"--with-pmi=slurm",
|
|
|
|
"--with-pm=no"
|
|
|
|
]
|
|
|
|
|
2015-11-09 22:45:23 +08:00
|
|
|
elif has_slurm_incompatible_variants:
|
|
|
|
pms = []
|
2016-06-01 22:43:08 +08:00
|
|
|
# The variant name is equal to the process manager name in
|
|
|
|
# the configuration options
|
2015-11-09 22:45:23 +08:00
|
|
|
for x in Mvapich2.SLURM_INCOMPATIBLE_PMS:
|
|
|
|
if self.enabled(x) in spec:
|
|
|
|
pms.append(x)
|
2015-11-09 20:58:34 +08:00
|
|
|
process_manager_options = [
|
2015-11-09 22:45:23 +08:00
|
|
|
"--with-pm=%s" % ':'.join(pms)
|
2015-10-27 20:23:15 +08:00
|
|
|
]
|
2015-11-09 20:58:34 +08:00
|
|
|
configure_args.extend(process_manager_options)
|
2015-10-27 20:23:15 +08:00
|
|
|
|
|
|
|
def set_network_type(self, spec, configure_args):
|
|
|
|
# Check that at most one variant has been activated
|
|
|
|
count = 0
|
2015-11-09 22:45:23 +08:00
|
|
|
for x in Mvapich2.SUPPORTED_NETWORKS:
|
|
|
|
if self.enabled(x) in spec:
|
|
|
|
count += 1
|
2015-10-27 20:23:15 +08:00
|
|
|
if count > 1:
|
2016-06-01 22:43:08 +08:00
|
|
|
raise RuntimeError('network variants are mutually exclusive \
|
|
|
|
(only one can be selected at a time)')
|
|
|
|
|
2016-03-15 17:49:33 +08:00
|
|
|
network_options = []
|
2016-01-20 02:46:15 +08:00
|
|
|
# From here on I can suppose that only one variant has been selected
|
2015-11-09 22:45:23 +08:00
|
|
|
if self.enabled(Mvapich2.PSM) in spec:
|
2015-10-27 20:23:15 +08:00
|
|
|
network_options = ["--with-device=ch3:psm"]
|
2015-11-09 22:45:23 +08:00
|
|
|
elif self.enabled(Mvapich2.SOCK) in spec:
|
2015-10-27 20:23:15 +08:00
|
|
|
network_options = ["--with-device=ch3:sock"]
|
2015-11-09 22:45:23 +08:00
|
|
|
elif self.enabled(Mvapich2.NEMESISIBTCP) in spec:
|
2015-11-09 21:35:54 +08:00
|
|
|
network_options = ["--with-device=ch3:nemesis:ib,tcp"]
|
2015-11-09 22:45:23 +08:00
|
|
|
elif self.enabled(Mvapich2.NEMESISIB) in spec:
|
2015-11-09 21:35:54 +08:00
|
|
|
network_options = ["--with-device=ch3:nemesis:ib"]
|
2015-11-09 22:45:23 +08:00
|
|
|
elif self.enabled(Mvapich2.NEMESIS) in spec:
|
2015-11-09 21:35:54 +08:00
|
|
|
network_options = ["--with-device=ch3:nemesis"]
|
2016-01-20 02:46:15 +08:00
|
|
|
elif self.enabled(Mvapich2.MRAIL) in spec:
|
2015-10-27 20:23:15 +08:00
|
|
|
network_options = ["--with-device=ch3:mrail", "--with-rdma=gen2"]
|
2014-07-11 07:55:38 +08:00
|
|
|
|
2015-10-27 20:23:15 +08:00
|
|
|
configure_args.extend(network_options)
|
2014-07-11 07:55:38 +08:00
|
|
|
|
2016-06-01 21:58:00 +08:00
|
|
|
def setup_environment(self, spack_env, run_env):
|
|
|
|
if self.enabled(Mvapich2.SLURM) in self.spec and \
|
|
|
|
self.version > Version('2.0'):
|
|
|
|
run_env.set('SLURM_MPI_TYPE', 'pmi2')
|
2016-06-01 22:43:08 +08:00
|
|
|
|
2017-03-15 13:26:44 +08:00
|
|
|
def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
|
2016-06-23 23:08:40 +08:00
|
|
|
spack_env.set('MPICC', join_path(self.prefix.bin, 'mpicc'))
|
|
|
|
spack_env.set('MPICXX', join_path(self.prefix.bin, 'mpicxx'))
|
|
|
|
spack_env.set('MPIF77', join_path(self.prefix.bin, 'mpif77'))
|
|
|
|
spack_env.set('MPIF90', join_path(self.prefix.bin, 'mpif90'))
|
|
|
|
|
2016-04-07 05:51:47 +08:00
|
|
|
spack_env.set('MPICH_CC', spack_cc)
|
|
|
|
spack_env.set('MPICH_CXX', spack_cxx)
|
|
|
|
spack_env.set('MPICH_F77', spack_f77)
|
|
|
|
spack_env.set('MPICH_F90', spack_fc)
|
|
|
|
spack_env.set('MPICH_FC', spack_fc)
|
2016-05-05 16:24:32 +08:00
|
|
|
|
2017-03-15 13:26:44 +08:00
|
|
|
def setup_dependent_package(self, module, dependent_spec):
|
2016-05-04 23:33:19 +08:00
|
|
|
self.spec.mpicc = join_path(self.prefix.bin, 'mpicc')
|
|
|
|
self.spec.mpicxx = join_path(self.prefix.bin, 'mpicxx')
|
|
|
|
self.spec.mpifc = join_path(self.prefix.bin, 'mpif90')
|
|
|
|
self.spec.mpif77 = join_path(self.prefix.bin, 'mpif77')
|
2016-09-03 23:13:47 +08:00
|
|
|
self.spec.mpicxx_shared_libs = [
|
|
|
|
join_path(self.prefix.lib, 'libmpicxx.{0}'.format(dso_suffix)),
|
|
|
|
join_path(self.prefix.lib, 'libmpi.{0}'.format(dso_suffix))
|
|
|
|
]
|
2016-06-01 22:43:08 +08:00
|
|
|
|
2015-10-27 20:23:15 +08:00
|
|
|
def install(self, spec, prefix):
|
2016-10-27 00:12:26 +08:00
|
|
|
# Until we can pass variants such as +fortran through virtual
|
|
|
|
# dependencies depends_on('mpi'), require Fortran compiler to
|
|
|
|
# avoid delayed build errors in dependents.
|
|
|
|
if (self.compiler.f77 is None) or (self.compiler.fc is None):
|
|
|
|
raise InstallError('Mvapich2 requires both C and Fortran ',
|
|
|
|
'compilers!')
|
|
|
|
|
2016-06-01 22:43:08 +08:00
|
|
|
# we'll set different configure flags depending on our
|
|
|
|
# environment
|
2015-10-27 20:23:15 +08:00
|
|
|
configure_args = [
|
|
|
|
"--prefix=%s" % prefix,
|
|
|
|
"--enable-shared",
|
|
|
|
"--enable-romio",
|
2014-07-11 07:55:38 +08:00
|
|
|
"--disable-silent-rules",
|
2015-10-27 20:23:15 +08:00
|
|
|
]
|
2016-01-20 02:46:15 +08:00
|
|
|
|
|
|
|
if self.compiler.f77 and self.compiler.fc:
|
|
|
|
configure_args.append("--enable-fortran=all")
|
|
|
|
elif self.compiler.f77:
|
|
|
|
configure_args.append("--enable-fortran=f77")
|
|
|
|
elif self.compiler.fc:
|
|
|
|
configure_args.append("--enable-fortran=fc")
|
|
|
|
else:
|
2015-10-27 20:23:15 +08:00
|
|
|
configure_args.append("--enable-fortran=none")
|
|
|
|
|
2015-11-09 22:55:44 +08:00
|
|
|
# Set the type of the build (debug, release)
|
|
|
|
self.set_build_type(spec, configure_args)
|
2015-10-27 20:23:15 +08:00
|
|
|
# Set the process manager
|
|
|
|
self.set_process_manager(spec, configure_args)
|
|
|
|
# Determine network type by variant
|
|
|
|
self.set_network_type(spec, configure_args)
|
|
|
|
|
|
|
|
configure(*configure_args)
|
2014-02-08 09:29:10 +08:00
|
|
|
make()
|
|
|
|
make("install")
|
2015-12-10 03:00:54 +08:00
|
|
|
|
|
|
|
self.filter_compilers()
|
|
|
|
|
|
|
|
def filter_compilers(self):
|
|
|
|
"""Run after install to make the MPI compilers use the
|
|
|
|
compilers that Spack built the package with.
|
|
|
|
|
|
|
|
If this isn't done, they'll have CC, CXX, F77, and FC set
|
|
|
|
to Spack's generic cc, c++, f77, and f90. We want them to
|
|
|
|
be bound to whatever compiler they were built with.
|
|
|
|
"""
|
|
|
|
bin = self.prefix.bin
|
2016-06-15 19:16:29 +08:00
|
|
|
mpicc = join_path(bin, 'mpicc')
|
|
|
|
mpicxx = join_path(bin, 'mpicxx')
|
|
|
|
mpif77 = join_path(bin, 'mpif77')
|
|
|
|
mpif90 = join_path(bin, 'mpif90')
|
2015-12-10 03:00:54 +08:00
|
|
|
|
2016-06-15 19:16:29 +08:00
|
|
|
# Substitute Spack compile wrappers for the real
|
|
|
|
# underlying compiler
|
2016-06-16 03:37:12 +08:00
|
|
|
kwargs = {'ignore_absent': True, 'backup': False, 'string': True}
|
|
|
|
filter_file(env['CC'], self.compiler.cc, mpicc, **kwargs)
|
|
|
|
filter_file(env['CXX'], self.compiler.cxx, mpicxx, **kwargs)
|
|
|
|
filter_file(env['F77'], self.compiler.f77, mpif77, **kwargs)
|
|
|
|
filter_file(env['FC'], self.compiler.fc, mpif90, **kwargs)
|
2016-06-15 19:16:29 +08:00
|
|
|
|
|
|
|
# Remove this linking flag if present
|
|
|
|
# (it turns RPATH into RUNPATH)
|
|
|
|
for wrapper in (mpicc, mpicxx, mpif77, mpif90):
|
|
|
|
filter_file('-Wl,--enable-new-dtags', '', wrapper, **kwargs)
|