# IT4Innovations 2019

easyblock = 'ConfigureMake'

name = 'OpenMPI'
version = '3.1.3'

homepage = 'https://www.open-mpi.org/'
description = """The Open MPI Project is an open source MPI-3 implementation."""

toolchain = {'name': 'GCC', 'version': '8.2.0-2.31.1'}

source_urls = ['https://www.open-mpi.org/software/ompi/v%(version_major_minor)s/downloads']
sources = [SOURCELOWER_TAR_GZ]
patches = [
    '%(name)s-%(version)s-add_ompi_datatype_attribute_to_release_ucp_datatype.patch',
    'OpenMPI-3.1_fix-ib-query.patch',
]
checksums = [
    '0254627d8a9b12a8f50213ed01e7a94dd7e91b340abf5c53bcf0b89afe6fb77d',  # openmpi-3.1.3.tar.gz
    # OpenMPI-3.1.3-add_ompi_datatype_attribute_to_release_ucp_datatype.patch
    '46fa94eb417954bdb297291bad4f4d32018af4911bebf3e59af6276eba6a50a9',
    '8031ff093788a750f30ec7b4b06573af008009e62ddfd558ecfe97cbe404d9d2',  # OpenMPI-3.1_fix-ib-query.patch
]

# needed for --with-verbs
osdependencies = [('libibverbs-dev', 'libibverbs-devel', 'rdma-core-devel')]

dependencies = [
    ('zlib', '1.2.11'),
    ('hwloc', '1.11.11')
]

configopts = '--with-slurm ' # Enable slurm
configopts += '--enable-shared --with-verbs '
configopts += '--enable-mpirun-prefix-by-default '  # suppress failure modes in relation to mpirun path
configopts += '--with-hwloc=$EBROOTHWLOC '  # hwloc support

# to enable SLURM integration (site-specific)
# configopts += '--with-slurm --with-pmi=/usr/include/slurm --with-pmi-libdir=/usr'

local_libs = ["mpi_mpifh", "mpi", "ompitrace", "open-pal", "open-rte"]
sanity_check_paths = {
    'files': ["bin/%s" % binfile for binfile in ["ompi_info", "opal_wrapper", "orterun"]] +
             ["lib/lib%s.%s" % (libfile, SHLIB_EXT) for libfile in local_libs] +
             ["include/%s.h" % x for x in ["mpi-ext", "mpif-config", "mpif", "mpi", "mpi_portable_platform"]],
    'dirs': [],
}

moduleclass = 'mpi'
