From 2220623f345546d3a1fab2458127c1035aeac69a Mon Sep 17 00:00:00 2001 From: KAWASHIMA Takahiro Date: Thu, 20 Dec 2018 22:27:06 +0900 Subject: [PATCH 1/2] config/ompi_ext: Don't include mpiext_*_mpifh.h in mpi_f08_ext Including `mpiext_*_mpifh.h` in the source file of the `mpi_f08_ext` module is not always appropriate. For example, if you want to define a new datatype in an MPI extension, the `include 'mpif-ext.h'` binding defines the datatype as `integer` but the `use mpi_f08_ext` binding defines it as `type(mpi_datatype)`. They conflict. This commit allows each MPI extension to declare whether it wants to include its `mpiext_*_mpifh.h` in `mpi_f08` and `mpi_f08_ext` respectively. The default (no declaration) is 'want'. See `ompi/mpiext/example/configure.m4` for an example. Signed-off-by: KAWASHIMA Takahiro --- config/ompi_ext.m4 | 20 ++++++++++++++++---- ompi/mpiext/example/configure.m4 | 8 ++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/config/ompi_ext.m4 b/config/ompi_ext.m4 index 88001e0142f..82f2687013a 100644 --- a/config/ompi_ext.m4 +++ b/config/ompi_ext.m4 @@ -601,9 +601,15 @@ EOF # # Include the mpif.h header if it is available. Cannot do # this from inside the usempi.h since, for VPATH builds, the - # srcdir is needed to find the header. + # srcdir is needed to find the header. Each extension can + # refuse it by defining the OMPI_MPIEXT_$1_INCLUDE_MPIFH_IN_USEMPI + # macro in its ompi/mpiext/*/configure.m4. See + # ompi/mpiext/example/configure.m4 for an example. # - if test "$enabled_mpifh" = 1; then + m4_ifdef([OMPI_MPIEXT_]$1[_INCLUDE_MPIFH_IN_USEMPI], + [include_mpifh=OMPI_MPIEXT_$1_INCLUDE_MPIFH_IN_USEMPI], + [include_mpifh=1]) + if test "$enabled_mpifh" = 1 && test "$include_mpifh" != 0; then mpifh_component_header="mpiext_${component}_mpifh.h" cat >> $mpiusempi_ext_h <> $mpiusempif08_ext_h < Date: Thu, 20 Dec 2018 22:48:50 +0900 Subject: [PATCH 2/2] config/ompi_ext: use mpi module in mpi_ext module If MPI extensions are enabled, all `ompi/mpiext/pcollreq/use-mpi/mpiext_*_usempi.h` are included in `ompi/mpi/fortran/mpiext-use-mpi/mpi-ext-module.F90` and all `ompi/mpiext/pcollreq/use-mpi/mpiext_*_usempif08.h` are included in `ompi/mpi/fortran/mpiext-use-mpi-f08/mpi-f08-ext-module.F90` using `#include` directives. In `mpiext_*_usempi.h` and `mpiext_*_usempif08.h`, some MPI extension may want to use constants or handles defined in the `mpi` module and the `mpi_f08` module. For example, if you want to define a new datatype in `mpi_f08_ext`, you'll need the definition of `type(mpi_datatype)`. However, putting `use mpi_f08` line in thier `mpiext_*_usempif08.h` may cause a compilation error if more than one MPI extensions are enabled because the `use` statement must be put prior to any variable declarations. To resolve this problem, this commit puts `use mpi` and `use mpi_f08` as first lines of `mpi-ext-module.F90` and `mpi-f08-ext-module.F90` respectively. Signed-off-by: KAWASHIMA Takahiro --- config/ompi_ext.m4 | 6 ++++++ ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am | 1 + ompi/mpi/fortran/mpiext-use-mpi/Makefile.am | 1 + 3 files changed, 8 insertions(+) diff --git a/config/ompi_ext.m4 b/config/ompi_ext.m4 index 82f2687013a..a30bcdb3c9c 100644 --- a/config/ompi_ext.m4 +++ b/config/ompi_ext.m4 @@ -171,6 +171,9 @@ EOF #include "ompi/mpi/fortran/configure-fortran-output.h" module mpi_ext +! Some mpi_ext extensions may require the mpi module. + use mpi +! ! Even though this is not a useful parameter (cannot be used as a ! preprocessor catch) define it to keep the linker from complaining ! during the build. @@ -213,6 +216,9 @@ EOF #include "ompi/mpi/fortran/configure-fortran-output.h" module mpi_f08_ext +! Some mpi_f08_ext extensions may require the mpi_f08 module. + use mpi_f08 +! ! Even though this is not a useful parameter (cannot be used as a ! preprocessor catch) define it to keep the linker from complaining ! during the build. diff --git a/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am b/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am index d5326b2c54f..616982611aa 100644 --- a/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am +++ b/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am @@ -22,6 +22,7 @@ if OMPI_BUILD_FORTRAN_USEMPI_OR_USEMPIF08_EXT AM_FCFLAGS = -I$(top_builddir)/ompi/include -I$(top_srcdir)/ompi/include \ $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/base \ $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi-f08/mod \ + $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi-f08 \ -I$(top_srcdir) $(FCFLAGS_f90) flibs = diff --git a/ompi/mpi/fortran/mpiext-use-mpi/Makefile.am b/ompi/mpi/fortran/mpiext-use-mpi/Makefile.am index 944add7bc18..b8318ce93ce 100644 --- a/ompi/mpi/fortran/mpiext-use-mpi/Makefile.am +++ b/ompi/mpi/fortran/mpiext-use-mpi/Makefile.am @@ -21,6 +21,7 @@ if OMPI_BUILD_FORTRAN_USEMPI_OR_USEMPIF08_EXT AM_FCFLAGS = -I$(top_builddir)/ompi/include -I$(top_srcdir)/ompi/include \ $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/base \ + $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi-ignore-tkr \ -I$(top_srcdir) $(FCFLAGS_f90) flibs =