|
| 1 | +## |
| 2 | +# Copyright 2022-2022 Ghent University |
| 3 | +# |
| 4 | +# This file is part of EasyBuild, |
| 5 | +# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en), |
| 6 | +# with support of Ghent University (http://ugent.be/hpc), |
| 7 | +# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be), |
| 8 | +# Flemish Research Foundation (FWO) (http://www.fwo.be/en) |
| 9 | +# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en). |
| 10 | +# |
| 11 | +# https://github.com/easybuilders/easybuild |
| 12 | +# |
| 13 | +# EasyBuild is free software: you can redistribute it and/or modify |
| 14 | +# it under the terms of the GNU General Public License as published by |
| 15 | +# the Free Software Foundation v2. |
| 16 | +# |
| 17 | +# EasyBuild is distributed in the hope that it will be useful, |
| 18 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | +# GNU General Public License for more details. |
| 21 | +# |
| 22 | +# You should have received a copy of the GNU General Public License |
| 23 | +# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>. |
| 24 | +## |
| 25 | +""" |
| 26 | +Support for MPItrampoline as toolchain MPI library. |
| 27 | +
|
| 28 | +:author: Alan O'Cais (CECAM) |
| 29 | +""" |
| 30 | + |
| 31 | +from easybuild.tools.toolchain.constants import COMPILER_VARIABLES, MPI_COMPILER_VARIABLES |
| 32 | +from easybuild.tools.toolchain.mpi import Mpi |
| 33 | +from easybuild.tools.toolchain.variables import CommandFlagList |
| 34 | + |
| 35 | + |
| 36 | +TC_CONSTANT_MPITRAMPOLINE = "MPItrampoline" |
| 37 | +TC_CONSTANT_MPI_TYPE_MPITRAMPOLINE = "MPI_TYPE_MPITRAMPOLINE" |
| 38 | + |
| 39 | + |
| 40 | +class MPItrampoline(Mpi): |
| 41 | + """MPItrampoline MPI class""" |
| 42 | + MPI_MODULE_NAME = ['MPItrampoline'] |
| 43 | + MPI_FAMILY = TC_CONSTANT_MPITRAMPOLINE |
| 44 | + MPI_TYPE = TC_CONSTANT_MPI_TYPE_MPITRAMPOLINE |
| 45 | + |
| 46 | + MPI_LIBRARY_NAME = 'mpi' |
| 47 | + |
| 48 | + # May be version-dependent, so defined at runtime |
| 49 | + MPI_COMPILER_MPIF77 = None |
| 50 | + MPI_COMPILER_MPIF90 = None |
| 51 | + MPI_COMPILER_MPIFC = None |
| 52 | + |
| 53 | + # MPItrampoline reads from CC etc env variables |
| 54 | + MPI_SHARED_OPTION_MAP = dict([('_opt_%s' % var, '') for var, _ in MPI_COMPILER_VARIABLES]) |
| 55 | + |
| 56 | + MPI_LINK_INFO_OPTION = '-showme:link' |
| 57 | + |
| 58 | + def __init__(self, *args, **kwargs): |
| 59 | + """Toolchain constructor""" |
| 60 | + super(MPItrampoline, self).__init__(*args, **kwargs) |
| 61 | + |
| 62 | + def _set_mpi_compiler_variables(self): |
| 63 | + """Define MPI wrapper commands and add MPITRAMPOLINE_* variables to set.""" |
| 64 | + |
| 65 | + self.MPI_COMPILER_MPIF77 = 'mpifort' |
| 66 | + self.MPI_COMPILER_MPIF90 = 'mpifort' |
| 67 | + self.MPI_COMPILER_MPIFC = 'mpifort' |
| 68 | + |
| 69 | + # this needs to be done first, otherwise e.g., CC is set to MPICC if the usempi toolchain option is enabled |
| 70 | + for var, _ in COMPILER_VARIABLES: |
| 71 | + self.variables.nappend( |
| 72 | + 'MPITRAMPOLINE_%s' % var, str(self.variables[var].get_first()), |
| 73 | + var_class=CommandFlagList |
| 74 | + ) |
| 75 | + |
| 76 | + super(MPItrampoline, self)._set_mpi_compiler_variables() |
0 commit comments