From 08a80c59830af8add68b2f4ba38f7e9aa39e34d2 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sun, 2 Jan 2022 14:26:35 -0500 Subject: [PATCH 01/10] ompi_fortran_check_ignore_tkr.m4: fix fortran test errors Fix bugs in the Fortran test code: 1. Called with "type(*)" instead of "type(*), dimension(*)" 2. Subroutine type was "real" when it should have been "complex" 3. Don't use a common block + BIND in the "use...only" test. Per https://github.com/open-mpi/ompi/pull/9812#issuecomment-1004012835, this seems to violate the Fortran standard. Instead, just use conflicting variables in the aaa and bbb modules, and trust "use...only" to avoid the conflicts. Signed-off-by: Jeff Squyres --- config/ompi_fortran_check_ignore_tkr.m4 | 6 +++--- config/ompi_fortran_check_use_only.m4 | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config/ompi_fortran_check_ignore_tkr.m4 b/config/ompi_fortran_check_ignore_tkr.m4 index bb64eb50565..4e2ea7a6c51 100644 --- a/config/ompi_fortran_check_ignore_tkr.m4 +++ b/config/ompi_fortran_check_ignore_tkr.m4 @@ -13,7 +13,7 @@ dnl All rights reserved. dnl Copyright (c) 2007 Los Alamos National Security, LLC. All rights dnl reserved. dnl Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved. -dnl Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved. +dnl Copyright (c) 2009-2022 Cisco Systems, Inc. All rights reserved. dnl $COPYRIGHT$ dnl dnl Additional copyrights may follow @@ -72,7 +72,7 @@ AC_DEFUN([_OMPI_FORTRAN_CHECK_IGNORE_TKR], [ # Vendor-neutral, TYPE(*) syntax OMPI_FORTRAN_CHECK_IGNORE_TKR_SUB( - [!], [type(*)], + [!], [type(*), dimension(*)], [TYPE(*), DIMENSION(*)], [happy=1], [happy=0]) @@ -185,7 +185,7 @@ AC_DEFUN([OMPI_FORTRAN_CHECK_IGNORE_TKR_SUB], [ subroutine force_assumed_shape(a, count) integer :: count - real, dimension(:,:) :: a + complex, dimension(:,:) :: a call foo(a, count) end subroutine force_assumed_shape diff --git a/config/ompi_fortran_check_use_only.m4 b/config/ompi_fortran_check_use_only.m4 index c147167391d..c95c0f1db91 100644 --- a/config/ompi_fortran_check_use_only.m4 +++ b/config/ompi_fortran_check_use_only.m4 @@ -42,14 +42,19 @@ AC_DEFUN([OMPI_FORTRAN_CHECK_USE_ONLY],[ [AC_LANG_PUSH([Fortran]) cat > aaa.f90 << EOF MODULE aaa -INTEGER :: CMON(1) -COMMON/CMMON/CMON +! These 2 have the same names as variables in bbb +! but they should not clash if we only import global_aaa +INTEGER :: local1 +REAL :: local2 INTEGER :: global_aaa END MODULE aaa EOF cat > bbb.f90 << EOF MODULE bbb -integer, bind(C, name="cmmon_") :: CMON +! These 2 have the same names as variables in aaa +! but they should not clash if we only import global_bbb +INTEGER :: local1 +COMPLEX :: local2 INTEGER :: global_bbb END MODULE bbb EOF From b40f19ffd324d646929d58e9209311b2aab810db Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Mon, 3 Jan 2022 09:48:53 -0800 Subject: [PATCH 02/10] ompi_fortran_get_alignment.m4: fix test LOC() is not a universal Fortran function (perhaps it's a GNU extension that at least some Fortran compilers have adopted? It doesn't seem to exist in the NAG compiler, at least). Additionally, doing the pointer arithmetic is not technically valid Fortran. So make the test for mpi_f08 handle alignment be similar to the other alignment tests: make instances of the variable in a common block and use C to compute the alignment. Signed-off-by: Jeff Squyres --- config/ompi_fortran_get_alignment.m4 | 96 +++++++++++++++++++--------- 1 file changed, 65 insertions(+), 31 deletions(-) diff --git a/config/ompi_fortran_get_alignment.m4 b/config/ompi_fortran_get_alignment.m4 index 141e062d5d7..578d0f701fc 100644 --- a/config/ompi_fortran_get_alignment.m4 +++ b/config/ompi_fortran_get_alignment.m4 @@ -136,44 +136,78 @@ EOF # OMPI_FORTRAN_F08_GET_HANDLE_ALIGNMENT(type, variable to set) # ------------------------------------------ AC_DEFUN([OMPI_FORTRAN_F08_GET_HANDLE_ALIGNMENT],[ + unset happy + OPAL_VAR_SCOPE_PUSH([happy ompi_conftest_h]) + # Use of m4_translit suggested by Eric Blake: # http://lists.gnu.org/archive/html/bug-autoconf/2010-10/msg00016.html AS_VAR_PUSHDEF([type_var], m4_translit([[ompi_cv_fortran_alignment_$1]], [*], [p])) AC_CACHE_CHECK([alignment of Fortran $1], type_var, - [AC_LANG_PUSH([Fortran]) - AC_LINK_IFELSE([AC_LANG_SOURCE([[module alignment_mod -type, BIND(C) :: test_mpi_handle - integer :: MPI_VAL -end type test_mpi_handle -type(test_mpi_handle) :: t1 -type(test_mpi_handle) :: t2 -end module - -program falignment - use alignment_mod - OPEN(UNIT=10, FILE="conftestval") - if (LOC(t1) > LOC(t2)) then - write (10,'(I5)') LOC(t1)-LOC(t2) - else - write (10,'(I5)') LOC(t2)-LOC(t1) - endif - CLOSE(10) - -end program]])], - [AS_IF([test "$cross_compiling" = "yes"], - [AC_MSG_ERROR([Can not determine alignment of $1 when cross-compiling])], - [OPAL_LOG_COMMAND([./conftest], - [AS_VAR_SET(type_var, [`cat conftestval`])], - [AC_MSG_ERROR([Could not determine alignment of $1])])])], - - [AC_MSG_WARN([Could not determine alignment of $1]) - AC_MSG_WARN([See config.log for details]) - AC_MSG_ERROR([Cannot continue])]) - rm -rf conftest* *.mod 2> /dev/null - AC_LANG_POP([Fortran])]) + [OMPI_FORTRAN_MAKE_C_FUNCTION([ompi_ac_align_fn], [align]) + # Fortran module + cat > conftestf.f < conftest.c < +#include + +void $ompi_ac_align_fn(char *w, char *x, char *y, char *z) +{ + unsigned long aw, ax, ay, az; + FILE *f = fopen("conftestval", "w"); + if (!f) exit(1); + aw = (unsigned long) w; + ax = (unsigned long) x; + ay = (unsigned long) y; + az = (unsigned long) z; + if (! ((aw%16)||(ax%16)||(ay%16)||(az%16))) fprintf(f, "%d\n", 16); + else if (! ((aw%12)||(ax%12)||(ay%12)||(az%12))) fprintf(f, "%d\n", 12); + else if (! ((aw%8)||(ax%8)||(ay%8)||(az%8))) fprintf(f, "%d\n", 8); + else if (! ((aw%4)||(ax%4)||(ay%4)||(az%4))) fprintf(f, "%d\n", 4); + else if (! ((aw%2)||(ax%2)||(ay%2)||(az%2))) fprintf(f, "%d\n", 2); + else fprintf(f, "%d\n", 1); + fclose(f); +} +EOF + + OPAL_LOG_COMMAND([$CC $CFLAGS -I. -c conftest.c], + [OPAL_LOG_COMMAND([$FC $FCFLAGS conftestf.f conftest.o -o conftest $LDFLAGS $LIBS], + [happy="yes"], [happy="no"])], [happy="no"]) + + if test "$happy" = "no" ; then + AC_MSG_RESULT([Error!]) + AC_MSG_ERROR([Could not determine alignment of $1]) + fi + + AS_IF([test "$cross_compiling" = "yes"], + [AC_MSG_RESULT([Error!]) + AC_MSG_ERROR([Can not determine alignment of $1 when cross-compiling])], + [OPAL_LOG_COMMAND([./conftest], + [AS_VAR_SET(type_var, [`cat conftestval`])], + [AC_MSG_RESULT([Error!]) + AC_MSG_ERROR([Could not determine alignment of $1])])]) + rm -rf conftest*]) AS_VAR_COPY([$2], [type_var]) AS_VAR_POPDEF([type_var])dnl + OPAL_VAR_SCOPE_POP ])dnl From a5aef2d359c3d1957b8a13d1e47cde7944ca81b3 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 6 Jan 2022 11:11:12 -0800 Subject: [PATCH 03/10] Fortran sentinels: use bind(C) Instead of solely relying on common blocks for the MPI Fortran sentinels (e.g., MPI_BOTTOM), also use a bind(C) statement to bind the back-end symbol name to a specific name. There are two benefits to this: 1. We don't have to have 4 back-end symbols (i.e., CAPS, lower, one_underscore_, and two_underscore__) 2. The mpi_f08 and mpi modules can share the same back-end symbol (because they'll both bind(C) to the same back-end symbol) However, keep definition of MPI_STATUS[ES]_IGNORE in its own separate header files/modules because they are different types in the mpi module vs. the mpi_f08 module. We cannot include the mpi module in the mpi_f08 module, or will get confused by seeing MPI_STATUS[ES]_IGNORE of two different types (even if you "use :: mpi, only : ..." and do not include MPI_STATUS[ES]_IGNORE in the imports list). Fixing point 2 avoided some subtle linker issues (see https://github.com/open-mpi/ompi/pull/9812#issuecomment-1006130887 for an explanation). Signed-off-by: Jeff Squyres --- ompi/include/Makefile.am | 5 +-- ompi/include/mpif-sentinels.h | 34 ++++++++++-------- ompi/include/mpif-status.h | 29 +++++++++++++++ ompi/include/mpif.h.in | 1 + ompi/mpi/fortran/base/gen-mpi-mangling.pl | 28 +++------------ ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am | 3 +- .../use-mpi-f08/mod/mpi-f08-sentinels.F90 | 36 +++++++++++++++++++ .../fortran/use-mpi-f08/mod/mpi-f08-types.F90 | 5 +++ ompi/mpi/fortran/use-mpi-f08/mpi-f08.F90 | 1 + .../use-mpi-ignore-tkr/mpi-ignore-tkr.F90 | 8 ++++- ompi/mpi/fortran/use-mpi/Makefile.am | 5 +++ ompi/mpi/fortran/use-mpi/mpi-sentinels.F90 | 19 ++++++++++ ompi/runtime/ompi_mpi_init.c | 19 ---------- 13 files changed, 133 insertions(+), 60 deletions(-) create mode 100644 ompi/include/mpif-status.h create mode 100644 ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-sentinels.F90 create mode 100644 ompi/mpi/fortran/use-mpi/mpi-sentinels.F90 diff --git a/ompi/include/Makefile.am b/ompi/include/Makefile.am index 222ec75bbbc..2122d04a4dc 100644 --- a/ompi/include/Makefile.am +++ b/ompi/include/Makefile.am @@ -41,7 +41,8 @@ include_HEADERS += \ mpif-handles.h \ mpif-io-constants.h \ mpif-io-handles.h \ - mpif-sentinels.h + mpif-sentinels.h \ + mpif-status.h endif @@ -125,7 +126,7 @@ CLEANFILES = mpif-sizeof.f90 distclean-local: rm -f mpi-ext.h mpif-ext.h mpi_portable_platform.h \ mpif-sizeof.h \ - mpif-c-constants-decl.h mpif-c-constants.h mpif-f08-types.h + mpif-c-constants-decl.h mpif-c-constants.h mpi_portable_platform.h: $(top_srcdir)/opal/include/opal/opal_portable_platform_real.h -@rm -f mpi_portable_platform.h diff --git a/ompi/include/mpif-sentinels.h b/ompi/include/mpif-sentinels.h index 082154cdbbc..c194c68d0c0 100644 --- a/ompi/include/mpif-sentinels.h +++ b/ompi/include/mpif-sentinels.h @@ -33,14 +33,26 @@ ! that we already have overloaded F90 bindings for all available ! types), so any type is fine. integer MPI_BOTTOM + common/mpi_fortran_bottom/MPI_BOTTOM + bind(C, name="mpi_fortran_bottom")/mpi_fortran_bottom/ + ! MPI_IN_PLACE has the same rationale as MPI_BOTTOM. integer MPI_IN_PLACE + common/mpi_fortran_in_place/MPI_IN_PLACE + bind(C, name="mpi_fortran_in_place")/mpi_fortran_in_place/ + ! Making MPI_ARGV_NULL be the same type as the parameter that is ! exepected in the F90 binding for MPI_COMM_SPAWN means that we ! don't need another interface for MPI_COMM_SPAWN. character MPI_ARGV_NULL(1) + common/mpi_fortran_argv_null/MPI_ARGV_NULL + bind(C, name="mpi_fortran_argv_null")/mpi_fortran_argv_null/ + ! Ditto for MPI_ARGVS_NULL / MPI_COMM_SPAWN_MULTIPLE. character MPI_ARGVS_NULL(1, 1) + common/mpi_fortran_argvs_null/MPI_ARGVS_NULL + bind(C, name="mpi_fortran_argvs_null")/mpi_fortran_argvs_null/ + ! MPI_ERRCODES_IGNORE has similar rationale to MPI_ARGV_NULL. The ! F77 functions are all smart enough to check that the errcodes ! parameter is not ERRCODES_IGNORE before assigning values into it @@ -48,21 +60,15 @@ ! matter -- we'll never overrun it because we never assign values ! into it). integer MPI_ERRCODES_IGNORE(1) -! MPI_STATUS_IGNORE has similar rationale to MPI_ERRCODES_IGNORE. - integer MPI_STATUS_IGNORE(MPI_STATUS_SIZE) -! Ditto for MPI_STATUSES_IGNORE - integer MPI_STATUSES_IGNORE(MPI_STATUS_SIZE, 1) + common/mpi_fortran_errc_ign/MPI_ERRCODES_IGNORE + bind(C, name="mpi_fortran_errcodes_ignore")/mpi_fortran_errc_ign/ + ! Ditto for MPI_UNWEIGHTED integer MPI_UNWEIGHTED(1) + common/mpi_fortran_unwghtd/MPI_UNWEIGHTED + bind(C, name="mpi_fortran_unweighted")/mpi_fortran_unwghtd/ + ! Ditto for MPI_WEIGHTS_EMPTY integer MPI_WEIGHTS_EMPTY(1) - - common/mpi_fortran_bottom/MPI_BOTTOM - common/mpi_fortran_in_place/MPI_IN_PLACE - common/mpi_fortran_argv_null/MPI_ARGV_NULL - common/mpi_fortran_argvs_null/MPI_ARGVS_NULL - common/mpi_fortran_errcodes_ignore/MPI_ERRCODES_IGNORE - common/mpi_fortran_status_ignore/MPI_STATUS_IGNORE - common/mpi_fortran_statuses_ignore/MPI_STATUSES_IGNORE - common/mpi_fortran_unweighted/MPI_UNWEIGHTED - common/mpi_fortran_weights_empty/MPI_WEIGHTS_EMPTY + common/mpi_fortran_wghts_empty/MPI_WEIGHTS_EMPTY + bind(C, name="mpi_fortran_weights_empty")/mpi_fortran_wghts_empty/ diff --git a/ompi/include/mpif-status.h b/ompi/include/mpif-status.h new file mode 100644 index 00000000000..e7318490877 --- /dev/null +++ b/ompi/include/mpif-status.h @@ -0,0 +1,29 @@ +! -*- fortran -*- +! +! Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana +! University Research and Technology +! Corporation. All rights reserved. +! Copyright (c) 2004-2005 The University of Tennessee and The University +! of Tennessee Research Foundation. All rights +! reserved. +! Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +! University of Stuttgart. All rights reserved. +! Copyright (c) 2004-2005 The Regents of the University of California. +! All rights reserved. +! Copyright (c) 2006-2017 Cisco Systems, Inc. All rights reserved +! $COPYRIGHT$ +! +! Additional copyrights may follow +! +! $HEADER$ +! + + ! MPI_STATUS[ES]_IGNORE are also sentinels, but they are different + ! types than they are in mpi_f08. + integer MPI_STATUS_IGNORE(MPI_STATUS_SIZE) + common/mpi_fortran_st_ign/MPI_STATUS_IGNORE + bind(C, name="mpi_fortran_status_ignore")/mpi_fortran_st_ign/ + + integer MPI_STATUSES_IGNORE(MPI_STATUS_SIZE, 1) + common/mpi_fortran_sts_ign/MPI_STATUSES_IGNORE + bind(C, name="mpi_fortran_statuses_ignore")/mpi_fortran_sts_ign/ diff --git a/ompi/include/mpif.h.in b/ompi/include/mpif.h.in index d4cbd138325..49aef70e0c2 100644 --- a/ompi/include/mpif.h.in +++ b/ompi/include/mpif.h.in @@ -61,3 +61,4 @@ include 'mpif-externals.h' include 'mpif-sentinels.h' include 'mpif-sizeof.h' + include 'mpif-status.h' diff --git a/ompi/mpi/fortran/base/gen-mpi-mangling.pl b/ompi/mpi/fortran/base/gen-mpi-mangling.pl index a049c625228..9795ba77c4a 100755 --- a/ompi/mpi/fortran/base/gen-mpi-mangling.pl +++ b/ompi/mpi/fortran/base/gen-mpi-mangling.pl @@ -32,14 +32,12 @@ my $file_c_constants_decl = "mpif-c-constants-decl.h"; my $file_c_constants = "mpif-c-constants.h"; -my $file_f08_types = "mpif-f08-types.h"; # If we are not building fortran, then just make empty files if ($caps_arg + $plain_arg + $single_underscore_arg + $double_underscore_arg == 0) { system("touch $file_c_constants_decl"); system("touch $file_c_constants"); - system("touch $file_f08_types"); exit(0); } @@ -108,22 +106,6 @@ ############################################################### -sub mangle { - my $name = shift; - - if ($plain_arg) { - return $name; - } elsif ($caps_arg) { - return uc($name); - } elsif ($single_underscore_arg) { - return $name . "_"; - } elsif ($double_underscore_arg) { - return $name . "__"; - } else { - die "Unknown name mangling type"; - } -} - sub gen_c_constants_decl { open(OUT, ">$file_c_constants_decl") || die "Can't write to $file_c_constants_decl"; @@ -139,13 +121,13 @@ sub gen_c_constants_decl { */ /* Note that the rationale for the types of each of these variables is - discussed in ompi/include/mpif-common.h. Do not change the types + discussed in ompi/include/mpif-sentinels.h. Do not change the types without also changing ompi/runtime/ompi_mpi_init.c and - ompi/include/mpif-common.h. */\n\n"; + ompi/include/mpif-sentinels.h. */\n\n"; foreach my $key (sort(keys(%{$fortran}))) { my $f = $fortran->{$key}; - my $m = mangle($f->{c_name}); + my $m = $f->{c_name}; print OUT "extern $f->{c_type} $m; #define OMPI_IS_FORTRAN_" . uc($key) . "(addr) \\ (addr == (void*) &$m)\n\n"; @@ -170,8 +152,8 @@ sub gen_c_constants { foreach my $key (sort(keys(%{$fortran}))) { my $f = $fortran->{$key}; - my $m = mangle($f->{c_name}); - print OUT "$f->{c_type} $m;\n"; + my $m = $f->{c_name}; + print OUT "$f->{c_type} $m = {0};\n"; } close (OUT); diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am b/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am index 87f1c2db8ba..8e813d071a6 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am +++ b/ompi/mpi/fortran/use-mpi-f08/mod/Makefile.am @@ -52,7 +52,8 @@ noinst_LTLIBRARIES = libusempif08_internal_modules.la libforce_usempif08_interna libusempif08_internal_modules_la_SOURCES = \ mpi-f08-types.F90 \ mpi-f08-callbacks.F90 \ - mpi-f08-constants.h + mpi-f08-constants.h \ + mpi-f08-sentinels.F90 libusempif08_internal_modules_la_LIBADD = \ $(top_builddir)/ompi/mpi/fortran/use-mpi/libusempi_internal_modules.la diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-sentinels.F90 b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-sentinels.F90 new file mode 100644 index 00000000000..3407fab1298 --- /dev/null +++ b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-sentinels.F90 @@ -0,0 +1,36 @@ +! -*- f90 -*- +! +! Copyright (c) 2009-2022 Cisco Systems, Inc. All rights reserved +! Copyright (c) 2009-2012 Los Alamos National Security, LLC. +! All rights reserved. +! Copyright (c) 2015-2020 Research Organization for Information Science +! and Technology (RIST). All rights reserved. +! Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. +! Copyright (c) 2020 The University of Tennessee and The University +! of Tennessee Research Foundation. All rights +! reserved. +! $COPYRIGHT$ +! + +module mpi_f08_sentinels + + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! Do NOT "use mpi" in here! You will get conflicts for things that + ! are different types (e.g., MPI_STATUS[ES]_IGNORE). + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + use, intrinsic :: ISO_C_BINDING + + use mpi_types + use mpi_sentinels + + ! These are different types than they are in the mpi module + type(MPI_Status) MPI_STATUS_IGNORE + common/mpi_f08_st_ign/MPI_STATUS_IGNORE + bind(C, name="mpi_f08_status_ignore")/mpi_f08_st_ign/ + + type(MPI_Status) MPI_STATUSES_IGNORE(1) + common/mpi_f08_sts_ign/MPI_STATUSES_IGNORE + bind(C, name="mpi_f08_statuses_ignore")/mpi_f08_sts_ign/ + +end module mpi_f08_sentinels diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-types.F90 b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-types.F90 index f91a800917c..f5fe9394716 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-types.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-types.F90 @@ -20,6 +20,11 @@ module mpi_f08_types + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ! Do NOT "use mpi" in here! You will get conflicts for things that + ! are different types (e.g., MPI_STATUS[ES]_IGNORE). + !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + use, intrinsic :: ISO_C_BINDING use mpi_types diff --git a/ompi/mpi/fortran/use-mpi-f08/mpi-f08.F90 b/ompi/mpi/fortran/use-mpi-f08/mpi-f08.F90 index 89054d8d30e..1da931c7a16 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mpi-f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/mpi-f08.F90 @@ -27,6 +27,7 @@ module mpi_f08 use mpi_f08_types + use mpi_f08_sentinels use mpi_f08_interfaces ! this module contains the mpi_f08 interface declarations use pmpi_f08_interfaces ! this module contains the pmpi_f08 interface declarations use mpi_f08_callbacks ! this module contains the mpi_f08 attribute callback subroutines diff --git a/ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr.F90 b/ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr.F90 index cb1ce70966e..d2662a60702 100644 --- a/ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr.F90 +++ b/ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr.F90 @@ -27,12 +27,18 @@ module mpi #if OMPI_FORTRAN_HAVE_TYPE_MPI_STATUS use mpi_types #endif + + ! Sentinel values such as MPI_BOTTOM (that are the same types as in + ! mpi_f08 -- not including MPI_STATUS[ES]_IGNORE, which are + ! different types in mpi_f08). + use mpi_sentinels + include "mpif-config.h" include "mpif-constants.h" include "mpif-handles.h" include "mpif-io-constants.h" include "mpif-io-handles.h" - include "mpif-sentinels.h" + include "mpif-status.h" ! The MPI attribute callback functions diff --git a/ompi/mpi/fortran/use-mpi/Makefile.am b/ompi/mpi/fortran/use-mpi/Makefile.am index 3f1bc6b1760..3d2f88441f0 100644 --- a/ompi/mpi/fortran/use-mpi/Makefile.am +++ b/ompi/mpi/fortran/use-mpi/Makefile.am @@ -48,6 +48,11 @@ noinst_LTLIBRARIES = libusempi_internal_modules.la nodist_libusempi_internal_modules_la_SOURCES = \ mpi-types.F90 +# mpif-sentinels.F90 is *not* generated, and should be distributed. +libusempi_internal_modules_la_SOURCES = \ + mpi-sentinels.F90 + +mpi-sentinels.lo: mpi-sentinels.F90 mpi-types.lo: mpi-types.F90 # Install the generated .mod files. Unfortunately, each F90 compiler diff --git a/ompi/mpi/fortran/use-mpi/mpi-sentinels.F90 b/ompi/mpi/fortran/use-mpi/mpi-sentinels.F90 new file mode 100644 index 00000000000..a9d05efe319 --- /dev/null +++ b/ompi/mpi/fortran/use-mpi/mpi-sentinels.F90 @@ -0,0 +1,19 @@ +! -*- f90 -*- +! +! Copyright (c) 2020 Research Organization for Information Science +! and Technology (RIST). All rights reserved. +! Copyright (c) 2022 Cisco Systems, Inc. All rights reserved +! $COPYRIGHT$ +! +! Additional copyrights may follow +! +! $HEADER$ +! + +! These sentinel values are needed in both the mpi and mpi_f08 +! modules. +module mpi_sentinels + + include "mpif-sentinels.h" + +end module diff --git a/ompi/runtime/ompi_mpi_init.c b/ompi/runtime/ompi_mpi_init.c index c52db8131e7..27de26a0cd2 100644 --- a/ompi/runtime/ompi_mpi_init.c +++ b/ompi/runtime/ompi_mpi_init.c @@ -209,29 +209,10 @@ struct ompi_status_public_t *ompi_mpi_statuses_ignore_addr = * complain. */ #if OMPI_BUILD_FORTRAN_BINDINGS -# if OMPI_FORTRAN_CAPS -MPI_Fint *MPI_F_STATUS_IGNORE = (MPI_Fint*) &MPI_FORTRAN_STATUS_IGNORE; -MPI_Fint *MPI_F_STATUSES_IGNORE = (MPI_Fint*) &MPI_FORTRAN_STATUSES_IGNORE; -MPI_Fint *MPI_F08_STATUS_IGNORE = (MPI_Fint*) &MPI_FORTRAN_STATUS_IGNORE; -MPI_Fint *MPI_F08_STATUSES_IGNORE = (MPI_Fint*) &MPI_FORTRAN_STATUSES_IGNORE; -# elif OMPI_FORTRAN_PLAIN MPI_Fint *MPI_F_STATUS_IGNORE = (MPI_Fint*) &mpi_fortran_status_ignore; MPI_Fint *MPI_F_STATUSES_IGNORE = (MPI_Fint*) &mpi_fortran_statuses_ignore; MPI_Fint *MPI_F08_STATUS_IGNORE = (MPI_Fint*) &mpi_fortran_status_ignore; MPI_Fint *MPI_F08_STATUSES_IGNORE = (MPI_Fint*) &mpi_fortran_statuses_ignore; -# elif OMPI_FORTRAN_SINGLE_UNDERSCORE -MPI_Fint *MPI_F_STATUS_IGNORE = (MPI_Fint*) &mpi_fortran_status_ignore_; -MPI_Fint *MPI_F_STATUSES_IGNORE = (MPI_Fint*) &mpi_fortran_statuses_ignore_; -MPI_Fint *MPI_F08_STATUS_IGNORE = (MPI_Fint*) &mpi_fortran_status_ignore_; -MPI_Fint *MPI_F08_STATUSES_IGNORE = (MPI_Fint*) &mpi_fortran_statuses_ignore_; -# elif OMPI_FORTRAN_DOUBLE_UNDERSCORE -MPI_Fint *MPI_F_STATUS_IGNORE = (MPI_Fint*) &mpi_fortran_status_ignore__; -MPI_Fint *MPI_F_STATUSES_IGNORE = (MPI_Fint*) &mpi_fortran_statuses_ignore__; -MPI_Fint *MPI_F08_STATUS_IGNORE = (MPI_Fint*) &mpi_fortran_status_ignore__; -MPI_Fint *MPI_F08_STATUSES_IGNORE = (MPI_Fint*) &mpi_fortran_statuses_ignore__; -# else -# error Unrecognized Fortran name mangling scheme -# endif #else MPI_Fint *MPI_F_STATUS_IGNORE = NULL; MPI_Fint *MPI_F_STATUSES_IGNORE = NULL; From 54d95d99beb3e14cdbcf54db9eb79784b203fac2 Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 6 Jan 2022 11:59:55 -0800 Subject: [PATCH 04/10] mpiext/*/use-mpi-f08: ensure CPPFLAGS don't propagate The CPPFLAGS may not be understood by the Fortran compiler. Signed-off-by: Jeff Squyres --- ompi/mpiext/example/use-mpi-f08/Makefile.am | 7 +++++++ ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/ompi/mpiext/example/use-mpi-f08/Makefile.am b/ompi/mpiext/example/use-mpi-f08/Makefile.am index f495b4414d6..6cdeee1a214 100644 --- a/ompi/mpiext/example/use-mpi-f08/Makefile.am +++ b/ompi/mpiext/example/use-mpi-f08/Makefile.am @@ -12,6 +12,13 @@ # This file builds the use_mpi_f08-based bindings for MPI extensions. It # is optional in MPI extensions. +# Note that Automake's Fortran-buidling rules uses CPPFLAGS and +# AM_CPPFLAGS. This can cause weirdness (e.g., +# https://github.com/open-mpi/ompi/issues/7253). Let's just zero +# those out and rely on AM_FCFLAGS. +CPPFLAGS = +AM_CPPFLAGS = + # We must set these #defines and include paths so that the inner OMPI # MPI prototype header files do the Right Thing. AM_FCFLAGS = $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi-f08/mod \ diff --git a/ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am b/ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am index d06c0aa6837..80b746a44cc 100644 --- a/ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am +++ b/ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am @@ -16,6 +16,13 @@ # This file builds the use_mpi_f08-based bindings for MPI extensions. It # is optional in MPI extensions. +# Note that Automake's Fortran-buidling rules uses CPPFLAGS and +# AM_CPPFLAGS. This can cause weirdness (e.g., +# https://github.com/open-mpi/ompi/issues/7253). Let's just zero +# those out and rely on AM_FCFLAGS. +CPPFLAGS = +AM_CPPFLAGS = + # We must set these #defines and include paths so that the inner OMPI # MPI prototype header files do the Right Thing. AM_FCFLAGS = $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi \ From 80a79961fc3b0dd5ff0eb28be58ef1695c481f6e Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 6 Jan 2022 12:04:34 -0800 Subject: [PATCH 05/10] mpi-f08-interfaces.h.in: remove superflous imports Remove some extra "use" imports that weren't actually used (i.e., remove harmless kruft). Signed-off-by: Jeff Squyres --- .../fortran/use-mpi-f08/mod/mpi-f08-interfaces.h.in | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h.in b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h.in index b283a6aa9ba..ab6403dc6bf 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h.in +++ b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.h.in @@ -812,7 +812,7 @@ end interface MPI_Type_get_extent interface MPI_Type_get_extent_x subroutine MPI_Type_get_extent_x_f08(datatype,lb,extent,ierror) - use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND, MPI_COUNT_KIND + use :: mpi_f08_types, only : MPI_Datatype, MPI_COUNT_KIND implicit none TYPE(MPI_Datatype), INTENT(IN) :: datatype INTEGER(MPI_COUNT_KIND), INTENT(OUT) :: lb, extent @@ -832,7 +832,7 @@ end interface MPI_Type_get_true_extent interface MPI_Type_get_true_extent_x subroutine MPI_Type_get_true_extent_x_f08(datatype,true_lb,true_extent,ierror) - use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND, MPI_COUNT_KIND + use :: mpi_f08_types, only : MPI_Datatype, MPI_COUNT_KIND implicit none TYPE(MPI_Datatype), INTENT(IN) :: datatype INTEGER(MPI_COUNT_KIND), INTENT(OUT) :: true_lb, true_extent @@ -2587,7 +2587,7 @@ end interface MPI_Graph_neighbors_count interface MPI_Topo_test subroutine MPI_Topo_test_f08(comm,status,ierror) - use :: mpi_f08_types, only : MPI_Comm, MPI_Status + use :: mpi_f08_types, only : MPI_Comm implicit none TYPE(MPI_Comm), INTENT(IN) :: comm INTEGER, INTENT(OUT) :: status @@ -3294,7 +3294,7 @@ end interface MPI_Compare_and_swap interface MPI_Win_complete subroutine MPI_Win_complete_f08(win,ierror) - use :: mpi_f08_types, only : MPI_Info, MPI_Comm, MPI_Win, MPI_ADDRESS_KIND + use :: mpi_f08_types, only : MPI_Win implicit none TYPE(MPI_Win), INTENT(IN) :: win INTEGER, OPTIONAL, INTENT(OUT) :: ierror @@ -3341,7 +3341,7 @@ end interface MPI_Win_attach interface MPI_Win_detach subroutine MPI_Win_detach_f08(win,base,ierror) - use :: mpi_f08_types, only : MPI_Win, MPI_ADDRESS_KIND + use :: mpi_f08_types, only : MPI_Win implicit none @OMPI_FORTRAN_IGNORE_TKR_PREDECL@ base @OMPI_FORTRAN_IGNORE_TKR_TYPE@ OMPI_ASYNCHRONOUS :: base @@ -3437,7 +3437,7 @@ end interface MPI_Win_start interface MPI_Win_sync subroutine MPI_Win_sync_f08(win,ierror) - use :: mpi_f08_types, only : MPI_Group, MPI_Win + use :: mpi_f08_types, only : MPI_Win implicit none TYPE(MPI_Win), INTENT(IN) :: win INTEGER, OPTIONAL, INTENT(OUT) :: ierror From e2404202a2183f98846a7b1b35b1665c11ac89da Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 6 Jan 2022 14:05:08 -0800 Subject: [PATCH 06/10] mpi-f-interfaces-bind.h: remove superflous imports Signed-off-by: Jeff Squyres --- .../bindings/mpi-f-interfaces-bind.h | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/ompi/mpi/fortran/use-mpi-f08/bindings/mpi-f-interfaces-bind.h b/ompi/mpi/fortran/use-mpi-f08/bindings/mpi-f-interfaces-bind.h index a1a0bf602cd..e25152b9ba7 100644 --- a/ompi/mpi/fortran/use-mpi-f08/bindings/mpi-f-interfaces-bind.h +++ b/ompi/mpi/fortran/use-mpi-f08/bindings/mpi-f-interfaces-bind.h @@ -3679,7 +3679,6 @@ end subroutine ompi_mrecv_f subroutine ompi_neighbor_allgather_f(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype, & comm,ierror) & BIND(C, name="ompi_neighbor_allgather_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf @@ -3692,7 +3691,6 @@ end subroutine ompi_neighbor_allgather_f subroutine ompi_ineighbor_allgather_f(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype, & comm,request,ierror) & BIND(C, name="ompi_ineighbor_allgather_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Request implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) OMPI_ASYNCHRONOUS :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE OMPI_ASYNCHRONOUS :: recvbuf @@ -3706,7 +3704,6 @@ end subroutine ompi_ineighbor_allgather_f subroutine ompi_neighbor_allgather_init_f(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype, & comm,info,request,ierror) & BIND(C, name="ompi_neighbor_allgather_init_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Request implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf @@ -3721,7 +3718,6 @@ end subroutine ompi_neighbor_allgather_init_f subroutine ompi_neighbor_allgatherv_f(sendbuf,sendcount,sendtype,recvbuf,recvcounts,displs, & recvtype,comm,ierror) & BIND(C, name="ompi_neighbor_allgatherv_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf @@ -3735,7 +3731,6 @@ end subroutine ompi_neighbor_allgatherv_f subroutine ompi_ineighbor_allgatherv_f(sendbuf,sendcount,sendtype,recvbuf,recvcounts,displs, & recvtype,comm,request,ierror) & BIND(C, name="ompi_ineighbor_allgatherv_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Request implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) OMPI_ASYNCHRONOUS :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE OMPI_ASYNCHRONOUS :: recvbuf @@ -3750,7 +3745,6 @@ end subroutine ompi_ineighbor_allgatherv_f subroutine ompi_neighbor_allgatherv_init_f(sendbuf,sendcount,sendtype,recvbuf,recvcounts,displs, & recvtype,comm,info,request,ierror) & BIND(C, name="ompi_neighbor_allgatherv_init_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Request implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf @@ -3766,7 +3760,6 @@ end subroutine ompi_neighbor_allgatherv_init_f subroutine ompi_neighbor_alltoall_f(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype, & comm,ierror) & BIND(C, name="ompi_neighbor_alltoall_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf @@ -3779,7 +3772,6 @@ end subroutine ompi_neighbor_alltoall_f subroutine ompi_ineighbor_alltoall_f(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype, & comm,request,ierror) & BIND(C, name="ompi_ineighbor_alltoall_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Request implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) OMPI_ASYNCHRONOUS :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE OMPI_ASYNCHRONOUS :: recvbuf @@ -3793,7 +3785,6 @@ end subroutine ompi_ineighbor_alltoall_f subroutine ompi_neighbor_alltoall_init_f(sendbuf,sendcount,sendtype,recvbuf,recvcount,recvtype, & comm,info,request,ierror) & BIND(C, name="ompi_neighbor_alltoall_init_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Request implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf @@ -3808,7 +3799,6 @@ end subroutine ompi_neighbor_alltoall_init_f subroutine ompi_neighbor_alltoallv_f(sendbuf,sendcounts,sdispls,sendtype,recvbuf,recvcounts, & rdispls,recvtype,comm,ierror) & BIND(C, name="ompi_neighbor_alltoallv_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf @@ -3821,7 +3811,6 @@ end subroutine ompi_neighbor_alltoallv_f subroutine ompi_ineighbor_alltoallv_f(sendbuf,sendcounts,sdispls,sendtype,recvbuf,recvcounts, & rdispls,recvtype,comm,request,ierror) & BIND(C, name="ompi_ineighbor_alltoallv_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Request implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) OMPI_ASYNCHRONOUS :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE OMPI_ASYNCHRONOUS :: recvbuf @@ -3835,7 +3824,6 @@ end subroutine ompi_ineighbor_alltoallv_f subroutine ompi_neighbor_alltoallv_init_f(sendbuf,sendcounts,sdispls,sendtype,recvbuf,recvcounts, & rdispls,recvtype,comm,info,request,ierror) & BIND(C, name="ompi_neighbor_alltoallv_init_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Request implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf @@ -3850,7 +3838,7 @@ end subroutine ompi_neighbor_alltoallv_init_f subroutine ompi_neighbor_alltoallw_f(sendbuf,sendcounts,sdispls,sendtypes,recvbuf,recvcounts, & rdispls,recvtypes,comm,ierror) & BIND(C, name="ompi_neighbor_alltoallw_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_ADDRESS_KIND + use :: mpi_f08_types, only : MPI_ADDRESS_KIND implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf @@ -3864,7 +3852,7 @@ end subroutine ompi_neighbor_alltoallw_f subroutine ompi_ineighbor_alltoallw_f(sendbuf,sendcounts,sdispls,sendtypes,recvbuf,recvcounts, & rdispls,recvtypes,comm,request,ierror) & BIND(C, name="ompi_ineighbor_alltoallw_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Request, MPI_ADDRESS_KIND + use :: mpi_f08_types, only : MPI_ADDRESS_KIND implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) OMPI_ASYNCHRONOUS :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE OMPI_ASYNCHRONOUS :: recvbuf @@ -3879,7 +3867,7 @@ end subroutine ompi_ineighbor_alltoallw_f subroutine ompi_neighbor_alltoallw_init_f(sendbuf,sendcounts,sdispls,sendtypes,recvbuf,recvcounts, & rdispls,recvtypes,comm,info,request,ierror) & BIND(C, name="ompi_neighbor_alltoallw_init_f") - use :: mpi_f08_types, only : MPI_Datatype, MPI_Comm, MPI_Request, MPI_ADDRESS_KIND + use :: mpi_f08_types, only : MPI_ADDRESS_KIND implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE, INTENT(IN) :: sendbuf OMPI_FORTRAN_IGNORE_TKR_TYPE :: recvbuf From 9f8b450ccafc10e9bbd04fa8e6a3c2abf16e905a Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 6 Jan 2022 14:09:46 -0800 Subject: [PATCH 07/10] use-mpi-f08: remove superflous imports Signed-off-by: Jeff Squyres --- ompi/mpi/fortran/use-mpi-f08/comm_get_name_f08.F90 | 2 +- ompi/mpi/fortran/use-mpi-f08/topo_test_f08.F90 | 2 +- ompi/mpi/fortran/use-mpi-f08/type_get_envelope_f08.F90 | 2 +- ompi/mpi/fortran/use-mpi-f08/type_get_extent_x_f08.F90 | 2 +- ompi/mpi/fortran/use-mpi-f08/type_get_name_f08.F90 | 2 +- ompi/mpi/fortran/use-mpi-f08/type_get_true_extent_x_f08.F90 | 2 +- ompi/mpi/fortran/use-mpi-f08/type_indexed_f08.F90 | 2 +- ompi/mpi/fortran/use-mpi-f08/type_size_f08.F90 | 2 +- ompi/mpi/fortran/use-mpi-f08/win_detach_f08.F90 | 2 +- ompi/mpi/fortran/use-mpi-f08/win_get_name_f08.F90 | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ompi/mpi/fortran/use-mpi-f08/comm_get_name_f08.F90 b/ompi/mpi/fortran/use-mpi-f08/comm_get_name_f08.F90 index 3b7dad61b75..dc6e0b98af6 100644 --- a/ompi/mpi/fortran/use-mpi-f08/comm_get_name_f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/comm_get_name_f08.F90 @@ -10,7 +10,7 @@ #include "mpi-f08-rename.h" subroutine MPI_Comm_get_name_f08(comm,comm_name,resultlen,ierror) - use :: mpi_f08_types, only : MPI_Comm, MPI_MAX_OBJECT_NAME + use :: mpi_f08_types, only : MPI_Comm use :: ompi_mpifh_bindings, only : ompi_comm_get_name_f implicit none TYPE(MPI_Comm), INTENT(IN) :: comm diff --git a/ompi/mpi/fortran/use-mpi-f08/topo_test_f08.F90 b/ompi/mpi/fortran/use-mpi-f08/topo_test_f08.F90 index 954fa8feea4..d5cfb18e4e0 100644 --- a/ompi/mpi/fortran/use-mpi-f08/topo_test_f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/topo_test_f08.F90 @@ -10,7 +10,7 @@ #include "mpi-f08-rename.h" subroutine MPI_Topo_test_f08(comm,status,ierror) - use :: mpi_f08_types, only : MPI_Comm, MPI_Status + use :: mpi_f08_types, only : MPI_Comm use :: ompi_mpifh_bindings, only : ompi_topo_test_f implicit none TYPE(MPI_Comm), INTENT(IN) :: comm diff --git a/ompi/mpi/fortran/use-mpi-f08/type_get_envelope_f08.F90 b/ompi/mpi/fortran/use-mpi-f08/type_get_envelope_f08.F90 index 9d805a4ba7c..54c5f20b978 100644 --- a/ompi/mpi/fortran/use-mpi-f08/type_get_envelope_f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/type_get_envelope_f08.F90 @@ -11,7 +11,7 @@ subroutine MPI_Type_get_envelope_f08(datatype,num_integers,num_addresses, & num_datatypes,combiner,ierror) - use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND + use :: mpi_f08_types, only : MPI_Datatype use :: ompi_mpifh_bindings, only : ompi_type_get_envelope_f implicit none TYPE(MPI_Datatype), INTENT(IN) :: datatype diff --git a/ompi/mpi/fortran/use-mpi-f08/type_get_extent_x_f08.F90 b/ompi/mpi/fortran/use-mpi-f08/type_get_extent_x_f08.F90 index aa497219c5f..6d2bcd78aec 100644 --- a/ompi/mpi/fortran/use-mpi-f08/type_get_extent_x_f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/type_get_extent_x_f08.F90 @@ -10,7 +10,7 @@ #include "mpi-f08-rename.h" subroutine MPI_Type_get_extent_x_f08(datatype,lb,extent,ierror) - use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND, MPI_COUNT_KIND + use :: mpi_f08_types, only : MPI_Datatype, MPI_COUNT_KIND use :: ompi_mpifh_bindings, only : ompi_type_get_extent_x_f implicit none TYPE(MPI_Datatype), INTENT(IN) :: datatype diff --git a/ompi/mpi/fortran/use-mpi-f08/type_get_name_f08.F90 b/ompi/mpi/fortran/use-mpi-f08/type_get_name_f08.F90 index 5828adca60a..903e30c7f77 100644 --- a/ompi/mpi/fortran/use-mpi-f08/type_get_name_f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/type_get_name_f08.F90 @@ -10,7 +10,7 @@ #include "mpi-f08-rename.h" subroutine MPI_Type_get_name_f08(datatype,type_name,resultlen,ierror) - use :: mpi_f08_types, only : MPI_Datatype, MPI_MAX_OBJECT_NAME + use :: mpi_f08_types, only : MPI_Datatype use :: ompi_mpifh_bindings, only : ompi_type_get_name_f implicit none TYPE(MPI_Datatype), INTENT(IN) :: datatype diff --git a/ompi/mpi/fortran/use-mpi-f08/type_get_true_extent_x_f08.F90 b/ompi/mpi/fortran/use-mpi-f08/type_get_true_extent_x_f08.F90 index aa00a66d652..b61e85c134a 100644 --- a/ompi/mpi/fortran/use-mpi-f08/type_get_true_extent_x_f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/type_get_true_extent_x_f08.F90 @@ -10,7 +10,7 @@ #include "mpi-f08-rename.h" subroutine MPI_Type_get_true_extent_x_f08(datatype,true_lb,true_extent,ierror) - use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND, MPI_COUNT_KIND + use :: mpi_f08_types, only : MPI_Datatype, MPI_COUNT_KIND use :: ompi_mpifh_bindings, only : ompi_type_get_true_extent_x_f implicit none TYPE(MPI_Datatype), INTENT(IN) :: datatype diff --git a/ompi/mpi/fortran/use-mpi-f08/type_indexed_f08.F90 b/ompi/mpi/fortran/use-mpi-f08/type_indexed_f08.F90 index 813665ce6c1..baab0f9dedf 100644 --- a/ompi/mpi/fortran/use-mpi-f08/type_indexed_f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/type_indexed_f08.F90 @@ -11,7 +11,7 @@ subroutine MPI_Type_indexed_f08(count,array_of_blocklengths, & array_of_displacements,oldtype,newtype,ierror) - use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND + use :: mpi_f08_types, only : MPI_Datatype use :: ompi_mpifh_bindings, only : ompi_type_indexed_f implicit none INTEGER, INTENT(IN) :: count diff --git a/ompi/mpi/fortran/use-mpi-f08/type_size_f08.F90 b/ompi/mpi/fortran/use-mpi-f08/type_size_f08.F90 index 244a6e2378b..912c377856a 100644 --- a/ompi/mpi/fortran/use-mpi-f08/type_size_f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/type_size_f08.F90 @@ -10,7 +10,7 @@ #include "mpi-f08-rename.h" subroutine MPI_Type_size_f08(datatype,size,ierror) - use :: mpi_f08_types, only : MPI_Datatype, MPI_ADDRESS_KIND + use :: mpi_f08_types, only : MPI_Datatype use :: ompi_mpifh_bindings, only : ompi_type_size_f implicit none TYPE(MPI_Datatype), INTENT(IN) :: datatype diff --git a/ompi/mpi/fortran/use-mpi-f08/win_detach_f08.F90 b/ompi/mpi/fortran/use-mpi-f08/win_detach_f08.F90 index a85f5b62523..96ea7a2d0f6 100644 --- a/ompi/mpi/fortran/use-mpi-f08/win_detach_f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/win_detach_f08.F90 @@ -10,7 +10,7 @@ #include "mpi-f08-rename.h" subroutine MPI_Win_detach_f08(win,base,ierror) - use :: mpi_f08_types, only : MPI_Win, MPI_ADDRESS_KIND + use :: mpi_f08_types, only : MPI_Win use :: ompi_mpifh_bindings, only : ompi_win_detach_f implicit none OMPI_FORTRAN_IGNORE_TKR_TYPE OMPI_ASYNCHRONOUS :: base diff --git a/ompi/mpi/fortran/use-mpi-f08/win_get_name_f08.F90 b/ompi/mpi/fortran/use-mpi-f08/win_get_name_f08.F90 index 99088f8b277..0733e400acb 100644 --- a/ompi/mpi/fortran/use-mpi-f08/win_get_name_f08.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/win_get_name_f08.F90 @@ -11,7 +11,7 @@ subroutine MPI_Win_get_name_f08(win,win_name,resultlen,ierror) use, intrinsic :: ISO_C_BINDING, only : C_CHAR - use :: mpi_f08_types, only : MPI_Win, MPI_MAX_OBJECT_NAME + use :: mpi_f08_types, only : MPI_Win use :: ompi_mpifh_bindings, only : ompi_win_get_name_f implicit none TYPE(MPI_Win), INTENT(IN) :: win From 71075118919c79d60ca2ae830eb91ec5a6a8b05a Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 6 Jan 2022 14:11:17 -0800 Subject: [PATCH 08/10] use-mpi-f08: Wtick/Wtime + sentinel updates Two changes that are related to each other: 1. Since Wtick/Wtime are simple interfaces (not wrappers) to the back-end C MPI_Wtick/MPI_Wtime functions, just declare them as bind(C) in the mpi module and then have the mpi_f08 module use just those 2 symbols in the mpi_f08 module (ditto for the PMPI versions). 2. Similar for the special "sentinel" values (e.g., MPI_BOTTOM). No longer generate them via gen-mpi-mangling.pl; just BIND(C) them in the mpi module and then "use" them in the mpi_f08 module. Signed-off-by: Jeff Squyres --- .gitignore | 1 - ompi/mpi/fortran/base/gen-mpi-mangling.pl | 23 ------------------- .../fortran/mpiext-use-mpi-f08/Makefile.am | 1 + .../use-mpi-f08/mod/mpi-f08-interfaces.F90 | 22 ++---------------- .../fortran/use-mpi-f08/mod/mpi-f08-types.F90 | 7 +++--- .../use-mpi-f08/mod/pmpi-f08-interfaces.F90 | 22 ++---------------- 6 files changed, 8 insertions(+), 68 deletions(-) diff --git a/.gitignore b/.gitignore index 089d60d9614..565c3299987 100644 --- a/.gitignore +++ b/.gitignore @@ -190,7 +190,6 @@ ompi/include/mpif-c-constants.h ompi/include/mpif-common.h ompi/include/mpi-ext.h ompi/include/mpif-ext.h -ompi/include/mpif-f08-types.h ompi/include/mpif-handles.h ompi/include/mpif-io-constants.h ompi/include/mpif-constants.h diff --git a/ompi/mpi/fortran/base/gen-mpi-mangling.pl b/ompi/mpi/fortran/base/gen-mpi-mangling.pl index 9795ba77c4a..a359e332c65 100755 --- a/ompi/mpi/fortran/base/gen-mpi-mangling.pl +++ b/ompi/mpi/fortran/base/gen-mpi-mangling.pl @@ -159,30 +159,7 @@ sub gen_c_constants { close (OUT); } -sub gen_f08_types { - open(OUT, ">$file_f08_types") || - die "Can't write to $file_f08_types"; - - print OUT "! WARNING: This is a generated file! Edits will be lost! */ -! -! Copyright (c) 2015 Research Organization for Information Science -! and Technology (RIST). All rights reserved. -! Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. -! \$COPYRIGHT\$ -! -! This file was generated by gen-mpi-mangling.pl -!\n\n"; - - foreach my $key (sort(keys(%{$fortran}))) { - my $f = $fortran->{$key}; - print OUT "$f->{f_type}, bind(C, name=\"".mangle($f->{c_name})."\") :: $f->{f_name}\n"; - } - - close (OUT); -} - gen_c_constants_decl(); gen_c_constants(); -gen_f08_types(); exit(0); diff --git a/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am b/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am index 5e5312f6e2d..98a3e92da76 100644 --- a/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am +++ b/ompi/mpi/fortran/mpiext-use-mpi-f08/Makefile.am @@ -29,6 +29,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 \ + $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/$(OMPI_FORTRAN_USEMPI_DIR) \ $(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) -I$(top_builddir) $(FCFLAGS_f90) diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.F90 b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.F90 index 2bbd07eb5f9..a356c7551ec 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-interfaces.F90 @@ -21,26 +21,8 @@ module mpi_f08_interfaces -#include "mpi-f08-interfaces.h" - -! MPI_Wtick is not a wrapper function -! -interface MPI_Wtick -function MPI_Wtick_f08( ) BIND(C,name="MPI_Wtick") - use, intrinsic :: ISO_C_BINDING - implicit none - DOUBLE PRECISION :: MPI_Wtick_f08 -end function MPI_Wtick_f08 -end interface MPI_Wtick + use :: mpi, only : MPI_Wtick, MPI_Wtime -! MPI_Wtime is not a wrapper function -! -interface MPI_Wtime -function MPI_Wtime_f08( ) BIND(C,name="MPI_Wtime") - use, intrinsic :: ISO_C_BINDING - implicit none - DOUBLE PRECISION :: MPI_Wtime_f08 -end function MPI_Wtime_f08 -end interface MPI_Wtime +#include "mpi-f08-interfaces.h" end module mpi_f08_interfaces diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-types.F90 b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-types.F90 index f5fe9394716..7f92d67093f 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-types.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/mod/mpi-f08-types.F90 @@ -28,6 +28,9 @@ module mpi_f08_types use, intrinsic :: ISO_C_BINDING use mpi_types + ! Use the same constants that are BIND(C)'ed in the mpi module + use :: mpi, only : MPI_ARGV_NULL, MPI_ARGVS_NULL, MPI_BOTTOM, MPI_ERRCODES_IGNORE, MPI_IN_PLACE, MPI_STATUS_IGNORE, MPI_STATUS_IGNORE, MPI_STATUSES_IGNORE, MPI_UNWEIGHTED, MPI_WEIGHTS_EMPTY + include "mpif-config.h" include "mpif-constants.h" include "mpif-io-constants.h" @@ -163,8 +166,4 @@ module mpi_f08_types type(MPI_Datatype), parameter :: MPI_OFFSET = MPI_Datatype(OMPI_MPI_OFFSET) type(MPI_Datatype), parameter :: MPI_COMPLEX4 = MPI_Datatype(OMPI_MPI_COMPLEX4) -!... Special sentinel constants -!------------------------------ -#include "mpif-f08-types.h" - end module mpi_f08_types diff --git a/ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90 b/ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90 index ddd81d17f74..8cc4ac52235 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/mod/pmpi-f08-interfaces.F90 @@ -25,26 +25,8 @@ module pmpi_f08_interfaces -#include "mpi-f08-interfaces.h" - -! MPI_Wtick is not a wrapper function -! -interface PMPI_Wtick -function PMPI_Wtick_f08( ) BIND(C,name="PMPI_Wtick") - use, intrinsic :: ISO_C_BINDING - implicit none - DOUBLE PRECISION :: PMPI_Wtick_f08 -end function PMPI_Wtick_f08 -end interface PMPI_Wtick + use :: mpi, only : PMPI_Wtick, PMPI_Wtime -! MPI_Wtime is not a wrapper function -! -interface PMPI_Wtime -function PMPI_Wtime_f08( ) BIND(C,name="PMPI_Wtime") - use, intrinsic :: ISO_C_BINDING - implicit none - DOUBLE PRECISION :: PMPI_Wtime_f08 -end function PMPI_Wtime_f08 -end interface PMPI_Wtime +#include "mpi-f08-interfaces.h" end module pmpi_f08_interfaces From ae8a549a38a6cdfb67ddca53abd6f40e57a5e23f Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 6 Jan 2022 15:17:26 -0800 Subject: [PATCH 09/10] mpiext/*/use-mpi-f08: include location of mpi module Since mpi_f08 now references the mpi module, we need to provide the compiler flag to find the mpi module in the build tree. Signed-off-by: Jeff Squyres --- ompi/mpiext/example/use-mpi-f08/Makefile.am | 4 +++- ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ompi/mpiext/example/use-mpi-f08/Makefile.am b/ompi/mpiext/example/use-mpi-f08/Makefile.am index 6cdeee1a214..cf1f6165d3a 100644 --- a/ompi/mpiext/example/use-mpi-f08/Makefile.am +++ b/ompi/mpiext/example/use-mpi-f08/Makefile.am @@ -21,7 +21,9 @@ AM_CPPFLAGS = # We must set these #defines and include paths so that the inner OMPI # MPI prototype header files do the Right Thing. -AM_FCFLAGS = $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi-f08/mod \ +AM_FCFLAGS = \ + $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/$(OMPI_FORTRAN_USEMPI_DIR) \ + $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi-f08/mod \ -I$(top_srcdir) $(FCFLAGS_f90) # Note that the mpi_f08-based bindings are optional -- they can only diff --git a/ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am b/ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am index 80b746a44cc..aed4f34e537 100644 --- a/ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am +++ b/ompi/mpiext/ftmpi/use-mpi-f08/Makefile.am @@ -26,6 +26,7 @@ AM_CPPFLAGS = # We must set these #defines and include paths so that the inner OMPI # MPI prototype header files do the Right Thing. AM_FCFLAGS = $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi \ + $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/$(OMPI_FORTRAN_USEMPI_DIR) \ $(OMPI_FC_MODULE_FLAG)$(top_builddir)/ompi/mpi/fortran/use-mpi-f08/mod \ -I$(top_builddir) -I$(top_srcdir) $(FCFLAGS_f90) From 4de6c2a3830907a2447db774c29c93d68870ff0d Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Thu, 6 Jan 2022 15:18:42 -0800 Subject: [PATCH 10/10] gen-mpi-sizeof: distinguish between mpi and mpi_f08 versions The mpi and mpi_f08 versions of MPI_Sizeof have a critical difference: ierr is required in the mpi subroutines, but optional in mpi_f08 subroutines. Make sure these specific subroutines therefore have different names. For the mpi_f08 version, add "_opt" in the specific subroutine name. Signed-off-by: Jeff Squyres --- ompi/mpi/fortran/base/gen-mpi-sizeof.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ompi/mpi/fortran/base/gen-mpi-sizeof.pl b/ompi/mpi/fortran/base/gen-mpi-sizeof.pl index 30b1d3446c1..aa11f4e88f0 100755 --- a/ompi/mpi/fortran/base/gen-mpi-sizeof.pl +++ b/ompi/mpi/fortran/base/gen-mpi-sizeof.pl @@ -72,9 +72,11 @@ ############################################################################# +my $optional_name_modifier; my $optional_ierror_param; my $optional_ierror_statement; if (lc($ierror_arg) eq "optional") { + $optional_name_modifier = "_opt"; $optional_ierror_param = ", OPTIONAL"; $optional_ierror_statement = "IF (present(ierror)) "; } @@ -89,7 +91,7 @@ sub queue_sub { my ($f_type, $suffix, $import_type) = @_; # Leave off the MPI/PMI prefix; we'll add that when outputting - my $sub_name = "Sizeof_$suffix"; + my $sub_name = "Sizeof_$suffix$optional_name_modifier"; # Make a hash for this subroutine my $subr;