mvapich2 : variant strings are associated with a named variable

This commit is contained in:
Massimiliano Culpo 2015-11-09 15:45:23 +01:00
parent 79ed9de4c1
commit 42bc552dd7

View File

@ -23,22 +23,43 @@ class Mvapich2(Package):
########## ##########
# TODO : Process managers should be grouped into the same variant, as soon as variant capabilities will be extended # 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 # See https://groups.google.com/forum/#!topic/spack/F8-f8B4_0so
variant('slurm', default=False, description='Sets slurm as the only process manager') SLURM = 'slurm'
variant('hydra', default=False, description='Sets hydra as one of the process managers') HYDRA = 'hydra'
variant('gforker', default=False, description='Sets gforker as one of the process managers') GFORKER = 'gforker'
variant('remshell', default=False, description='Sets remshell as one of the process managers') REMSHELL = 'remshell'
SLURM_INCOMPATIBLE_PMS = (HYDRA, GFORKER, REMSHELL)
variant(SLURM, default=False, description='Sets slurm as the only process manager')
variant(HYDRA, default=False, description='Sets hydra as one of the process managers')
variant(GFORKER, default=False, description='Sets gforker as one of the process managers')
variant(REMSHELL, default=False, description='Sets remshell as one of the process managers')
########## ##########
########## ##########
# TODO : Network types should be grouped into the same variant, as soon as variant capabilities will be extended # TODO : Network types should be grouped into the same variant, as soon as variant capabilities will be extended
variant('psm', default=False, description='Configures a build for QLogic PSM-CH3') PSM = 'psm'
variant('sock', default=False, description='Configures a build for TCP/IP-CH3') SOCK = 'sock'
variant('nemesisibtcp', default=False, description='Configures a build for both OFA-IB-Nemesis and TCP/IP-Nemesis') NEMESISIBTCP = 'nemesisibtcp'
variant('nemesisib', default=False, description='Configures a build for OFA-IB-Nemesis') NEMESISIB = 'nemesisib'
variant('nemesis', default=False, description='Configures a build for TCP/IP-Nemesis') NEMESIS = 'nemesis'
SUPPORTED_NETWORKS = (PSM, SOCK, NEMESIS, NEMESISIB, NEMESISIBTCP)
variant(PSM, default=False, description='Configures a build for QLogic PSM-CH3')
variant(SOCK, default=False, description='Configures a build for TCP/IP-CH3')
variant(NEMESISIBTCP, default=False, description='Configures a build for both OFA-IB-Nemesis and TCP/IP-Nemesis')
variant(NEMESISIB, default=False, description='Configures a build for OFA-IB-Nemesis')
variant(NEMESIS, default=False, description='Configures a build for TCP/IP-Nemesis')
########## ##########
# TODO : CUDA support is missing # FIXME : CUDA support is missing
@staticmethod
def enabled(x):
"""
Given a variant name returns the string that means the variant is enabled
:param x: variant name
:return:
"""
return '+' + x
def set_build_type_flags(self, spec, configure_args): def set_build_type_flags(self, spec, configure_args):
""" """
@ -67,56 +88,45 @@ def set_process_manager(self, spec, configure_args):
:param configure_args: list of current configure arguments :param configure_args: list of current configure arguments
""" """
# Check that slurm variant is not activated together with other pm variants # Check that slurm variant is not activated together with other pm variants
has_slurm_incompatible_variant = any((x in spec for x in ['+hydra', '+gforker', '+remshell'])) has_slurm_incompatible_variants = any(self.enabled(x) in spec for x in Mvapich2.SLURM_INCOMPATIBLE_PMS)
if '+slurm' in spec and has_slurm_incompatible_variant: 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) raise RuntimeError(" %s : 'slurm' cannot be activated together with other process managers" % self.name)
process_manager_options = [] process_manager_options = []
if '+slurm' in spec: if self.enabled(Mvapich2.SLURM) in spec:
process_manager_options = [ process_manager_options = [
"--with-pm=slurm" "--with-pm=slurm"
] ]
elif has_slurm_incompatible_variant: elif has_slurm_incompatible_variants:
pm = [] pms = []
if '+hydra' in spec: # The variant name is equal to the process manager name in the configuration options
pm.append('hydra') for x in Mvapich2.SLURM_INCOMPATIBLE_PMS:
if '+gforker' in spec: if self.enabled(x) in spec:
pm.append('gforker') pms.append(x)
if '+remshell' in spec:
pm.append('remshell')
process_manager_options = [ process_manager_options = [
"--with-pm=%s" % ':'.join(pm) "--with-pm=%s" % ':'.join(pms)
] ]
configure_args.extend(process_manager_options) configure_args.extend(process_manager_options)
def set_network_type(self, spec, configure_args): def set_network_type(self, spec, configure_args):
# Check that at most one variant has been activated # Check that at most one variant has been activated
# FIXME : ugly, as it does not scale at all (and is full of conditionals)
count = 0 count = 0
if '+psm' in spec: for x in Mvapich2.SUPPORTED_NETWORKS:
count += 1 if self.enabled(x) in spec:
if '+sock' in spec: count += 1
count += 1
if '+nemesisibtcp' in spec:
count += 1
if '+nemesisib' in spec:
count += 1
if '+nemesis' in spec:
count += 1
if count > 1: if count > 1:
raise RuntimeError('MVAPICH2 network variants are mutually exclusive : only one can be selected at a time') raise RuntimeError('network variants are mutually exclusive (only one can be selected at a time)')
# From here on I can suppose that ony one variant has been selected # From here on I can suppose that ony one variant has been selected
if '+psm' in spec: if self.enabled(Mvapich2.PSM) in spec:
network_options = ["--with-device=ch3:psm"] network_options = ["--with-device=ch3:psm"]
elif '+sock' in spec: elif self.enabled(Mvapich2.SOCK) in spec:
network_options = ["--with-device=ch3:sock"] network_options = ["--with-device=ch3:sock"]
elif '+nemesisibtcp' in spec: elif self.enabled(Mvapich2.NEMESISIBTCP) in spec:
network_options = ["--with-device=ch3:nemesis:ib,tcp"] network_options = ["--with-device=ch3:nemesis:ib,tcp"]
elif '+nemesisib' in spec: elif self.enabled(Mvapich2.NEMESISIB) in spec:
network_options = ["--with-device=ch3:nemesis:ib"] network_options = ["--with-device=ch3:nemesis:ib"]
elif '+nemesis' in spec: elif self.enabled(Mvapich2.NEMESIS) in spec:
network_options = ["--with-device=ch3:nemesis"] network_options = ["--with-device=ch3:nemesis"]
else: else:
network_options = ["--with-device=ch3:mrail", "--with-rdma=gen2"] network_options = ["--with-device=ch3:mrail", "--with-rdma=gen2"]