# IT4Innovations 2019

easyblock = 'ConfigureMake'

name = 'OpenMPI'
version = '3.1.3'

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

toolchain = {'name': 'PGI', 'version': '19.4-GCC-8.2.0-2.31.1'}
toolchainopts = {'pic': True}

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
]

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

#preconfigopts = 'export CFLAGS="-O1"'

configopts = ' CFLAGS="-O1" --with-threads=posix --enable-shared --enable-static --enable-mpi-thread-multiple --with-verbs '
# suppress failure modes in relation to mpirun path
configopts += '--enable-mpirun-prefix-by-default '
configopts += '--with-hwloc=$EBROOTHWLOC '  # hwloc support
# statically link local_component, don't do dynamic loading
configopts += '--disable-dlopen '
configopts += '--with-tm=/opt/pbs/default '  # Enable PBS

# for PBS Pro 13
preconfigopts = 'export LIBS="-ldl" && export CC="pgcc -noswitcherror" && export CXX="pgc++ -noswitcherror" && export FC="pgfortran -noswitcherror" && '

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

libs = [
    "mpi_cxx",
    "mpi_mpifh",
    "mpi",
    "ompitrace",
    "open-pal",
    "open-rte",
    "vt",
    "vt-hyb",
    "vt-mpi",
    "vt-mpi-unify"]

sanity_check_paths = {
    'files': [],
    'dirs': ['bin', 'lib', 'include'],
}

sanity_check_commands = [
    ('mpicc --version | grep pgcc', ''),
    ('mpicxx --version | grep pgc++', ''),
    ('mpifort --version | grep pgfortran', ''),
]

modextravars = {'OMPI_MCA_btl_openib_if_include': 'mlx4_0',
                'OMPI_MCA_oob_tcp_if_include': '10.0.0.0/8',
                }

moduleclass = 'mpi'