From 06ee9cba3055ae4cc744c9bae09b2e41afa4a3e3 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Mon, 27 Jul 2015 15:26:21 +0900 Subject: [PATCH 1/3] f08: misc Makefile fixes (cherry picked from commit open-mpi/ompi@7af52385955f097e4dca3616b4b5b8dfe785ebeb) --- ompi/mpi/fortran/use-mpi-f08-desc/Makefile.am | 12 +++++++++++- ompi/mpi/fortran/use-mpi-f08/Makefile.am | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/ompi/mpi/fortran/use-mpi-f08-desc/Makefile.am b/ompi/mpi/fortran/use-mpi-f08-desc/Makefile.am index f9f48f4db5e..8a08bded7fd 100644 --- a/ompi/mpi/fortran/use-mpi-f08-desc/Makefile.am +++ b/ompi/mpi/fortran/use-mpi-f08-desc/Makefile.am @@ -1,6 +1,8 @@ # -*- makefile -*- # # Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2015 Research Organization for Information Science +# and Technology (RIST). All rights reserved. # # $COPYRIGHT$ # @@ -60,7 +62,15 @@ mpi-f08-types.lo: mpi-f08-types.f90 mpi-f08-interfaces.lo: mpi-f08-interfaces.F90 mpi-f08-types.lo OMPI_Fortran_binding.lo: OMPI_Fortran_binding.f90 mpi-f08-types.lo -$(mpi_api_files): mpi-f08.lo + +# +# Automake doesn't do Fortran dependency analysis, so must list them +# manually here. Bummer! +# + +mpi_api_lo_files = $(mpi_api_files:.f90=.lo) + +$(mpi_api_lo_files): mpi-f08.lo mpi-f08.lo: mpi-f08-types.lo mpi-f08.lo: OMPI_Fortran_binding.lo diff --git a/ompi/mpi/fortran/use-mpi-f08/Makefile.am b/ompi/mpi/fortran/use-mpi-f08/Makefile.am index 029330350fc..42072dc9132 100644 --- a/ompi/mpi/fortran/use-mpi-f08/Makefile.am +++ b/ompi/mpi/fortran/use-mpi-f08/Makefile.am @@ -103,7 +103,6 @@ mpi_api_files = \ bcast_f08.F90 \ bsend_f08.F90 \ bsend_init_f08.F90 \ - buffer_detach.c \ buffer_attach_f08.F90 \ buffer_detach_f08.F90 \ cancel_f08.F90 \ @@ -795,6 +794,7 @@ libmpi_usempif08_la_SOURCES = \ mpi-f08.F90 \ mpi-f-interfaces-bind.h pmpi-f-interfaces-bind.h \ attr-fn-f08-callback-interfaces.h \ + buffer_detach.c \ conversion-fn-null-f08-interface.h \ constants.h \ constants.c From 3f4fd58c2c6afca03b9c7533f47c9ac2e8535a98 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Fri, 24 Jul 2015 09:51:21 +0900 Subject: [PATCH 2/3] fortran: fix f08 bindings only define the unique fortran symbol depending on - CAPS - PLAIN - SINGLE_UNDERSCORE - DOUBLE_UNDERSCORE and bind the f08 symbol to the uniquely defined C symbol. Use real data structures to make the code simpler. (perl script written by Jeff) (back-ported from commit open-mpi/ompi@9c77c6b66d48871d1ac0da843ff8c4e9dd39c75b) --- .gitignore | 3 + config/ompi_setup_mpi_fortran.m4 | 14 +- ompi/include/Makefile.am | 26 ++- ompi/mpi/fortran/base/Makefile.am | 7 +- ompi/mpi/fortran/base/constants.h | 170 +-------------- ompi/mpi/fortran/base/gen-mpi-mangling.pl | 206 ++++++++++++++++++ .../use-mpi-f08-desc/mpi-f08-types.f90 | 5 +- .../mpi/fortran/use-mpi-f08/mpi-f08-types.F90 | 12 +- ompi/runtime/ompi_mpi_init.c | 27 +-- oshmem/runtime/oshmem_shmem_init.c | 1 + 10 files changed, 263 insertions(+), 208 deletions(-) create mode 100755 ompi/mpi/fortran/base/gen-mpi-mangling.pl diff --git a/.gitignore b/.gitignore index 10da50d4a86..7e923b9c443 100644 --- a/.gitignore +++ b/.gitignore @@ -140,9 +140,12 @@ ompi/debuggers/predefined_pad_test ompi/include/mpi.h ompi/include/mpif-config.h ompi/include/mpif.h +ompi/include/mpif-c-constants-decl.h +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/config/ompi_setup_mpi_fortran.m4 b/config/ompi_setup_mpi_fortran.m4 index 2f8150e241a..c1f195b46bc 100644 --- a/config/ompi_setup_mpi_fortran.m4 +++ b/config/ompi_setup_mpi_fortran.m4 @@ -101,17 +101,25 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[ # AC_DEFINE these results, even in the --disable-mpi-fortran case, # for ompi_info. AC_DEFINE_UNQUOTED([OMPI_FORTRAN_DOUBLE_UNDERSCORE], - [$ompi_fortran_double_underscore], + [$ompi_fortran_double_underscore], [Whether fortran symbols have a trailing double underscore or not]) - AC_DEFINE_UNQUOTED([OMPI_FORTRAN_SINGLE_UNDERSCORE], + OMPI_FORTRAN_DOUBLE_UNDERSCORE=$ompi_fortran_double_underscore + AC_SUBST(OMPI_FORTRAN_DOUBLE_UNDERSCORE) + AC_DEFINE_UNQUOTED([OMPI_FORTRAN_SINGLE_UNDERSCORE], [$ompi_fortran_single_underscore], [Whether fortran symbols have a trailing underscore or not]) + OMPI_FORTRAN_SINGLE_UNDERSCORE=$ompi_fortran_single_underscore + AC_SUBST(OMPI_FORTRAN_SINGLE_UNDERSCORE) AC_DEFINE_UNQUOTED([OMPI_FORTRAN_CAPS], [$ompi_fortran_caps], [Whether fortran symbols are all caps or not]) - AC_DEFINE_UNQUOTED([OMPI_FORTRAN_PLAIN], + OMPI_FORTRAN_CAPS=$ompi_fortran_caps + AC_SUBST(OMPI_FORTRAN_CAPS) + AC_DEFINE_UNQUOTED([OMPI_FORTRAN_PLAIN], [$ompi_fortran_plain], [Whether fortran symbols have no trailing underscore or not]) + OMPI_FORTRAN_PLAIN=$ompi_fortran_plain + AC_SUBST(OMPI_FORTRAN_PLAIN) # Check to see if any of the MPI Fortran bindings were # specifically requested. If so, and we weren't able to setup the diff --git a/ompi/include/Makefile.am b/ompi/include/Makefile.am index 62768eccc35..d80c5c75bc0 100644 --- a/ompi/include/Makefile.am +++ b/ompi/include/Makefile.am @@ -53,7 +53,8 @@ nodist_include_HEADERS = \ mpif.h \ mpif-ext.h \ mpif-sizeof.h \ - mpi_portable_platform.h + mpif-c-constants-decl.h \ + mpi_portable_platform.h if OMPI_BUILD_FORTRAN_MPIFH_BINDINGS nodist_include_HEADERS += \ @@ -62,8 +63,8 @@ endif include ompi/Makefile.am -# This is complicated, but mpif-values.pl generates -# several mpif-*.h files in this directory (during autogen.pl). +# This is complicated, but mpif-values.pl generates several +# mpif-*.h files in this directory (during autogen.pl). # Hence, if any of those files change, it's safer to just force the # user to re-autogen. #mpif.h: mpif-constants.h mpif-handles.h mpif-io-constants.h mpif-io-handles.h @@ -88,6 +89,21 @@ mpif-sizeof.h: --real16=$(OMPI_HAVE_FORTRAN_REAL16) \ --complex32=$(OMPI_HAVE_FORTRAN_COMPLEX32) +# +# mpif-c-constants-decl.h, among other files, is generated based on some +# results from configure tests. +# + +mpif_mangling_pl=$(top_srcdir)/ompi/mpi/fortran/base/gen-mpi-mangling.pl +mpif-c-constants-decl.h: $(top_builddir)/config.status +mpif-c-constants-decl.h: $(mpif_mangling_pl) +mpif-c-constants-decl.h: + $(OMPI_V_GEN) $(mpif_mangling_pl) \ + --caps $(OMPI_FORTRAN_CAPS) \ + --plain $(OMPI_FORTRAN_PLAIN) \ + --single $(OMPI_FORTRAN_SINGLE_UNDERSCORE) \ + --double $(OMPI_FORTRAN_DOUBLE_UNDERSCORE) + if WANT_INSTALL_HEADERS ompidir = $(ompiincludedir) nobase_dist_ompi_HEADERS = $(headers) @@ -103,7 +119,9 @@ CLEANFILES = mpif-sizeof.f90 # Remove the auto-generated files (they are generated by configure) # Since there is no mpi-ext.h.in, autogen does not know to cleanup this file. distclean-local: - rm -f mpi-ext.h mpif-ext.h mpi_portable_platform.h mpif-sizeof.h + 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 mpi_portable_platform.h: $(top_srcdir)/opal/include/opal/opal_portable_platform.h -@rm -f mpi_portable_platform.h diff --git a/ompi/mpi/fortran/base/Makefile.am b/ompi/mpi/fortran/base/Makefile.am index bb7a9c233c9..6eb1987bd04 100644 --- a/ompi/mpi/fortran/base/Makefile.am +++ b/ompi/mpi/fortran/base/Makefile.am @@ -9,7 +9,9 @@ # University of Stuttgart. All rights reserved. # Copyright (c) 2004-2005 The Regents of the University of California. # All rights reserved. -# Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2015 Research Organization for Information Science +# and Technology (RIST). All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow @@ -22,7 +24,8 @@ noinst_LTLIBRARIES = EXTRA_DIST = \ attr-fn-int-callback-interfaces.h \ conversion-fn-null-int-interface.h \ - gen-mpi-sizeof.pl + gen-mpi-sizeof.pl \ + gen-mpi-mangling.pl #----------------------------------------------------------------------------- diff --git a/ompi/mpi/fortran/base/constants.h b/ompi/mpi/fortran/base/constants.h index 914c63d8b3e..984ebcadebc 100644 --- a/ompi/mpi/fortran/base/constants.h +++ b/ompi/mpi/fortran/base/constants.h @@ -9,9 +9,11 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2011-2013 Inria. All rights reserved. * Copyright (c) 2011-2012 Universite Bordeaux 1 + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -24,6 +26,7 @@ #include "ompi_config.h" +#if OMPI_BUILD_FORTRAN_BINDINGS /* * Several variables are used to link against MPI F77 constants which * correspond to addresses, e.g. MPI_BOTTOM, and are implemented via @@ -85,168 +88,7 @@ * file. */ -#define DECL(type, upper_case, lower_case, single_u, double_u) \ -OMPI_DECLSPEC extern type upper_case; \ -OMPI_DECLSPEC extern type lower_case; \ -OMPI_DECLSPEC extern type single_u; \ -OMPI_DECLSPEC extern type double_u - -/* 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 - without also changing ompi/runtime/ompi_mpi_init.c and - ompi/include/mpif-common.h. */ - -DECL(int, MPI_FORTRAN_BOTTOM, mpi_fortran_bottom, - mpi_fortran_bottom_, mpi_fortran_bottom__); -DECL(int, MPI_FORTRAN_IN_PLACE, mpi_fortran_in_place, - mpi_fortran_in_place_, mpi_fortran_in_place__); -DECL(int, MPI_FORTRAN_UNWEIGHTED, mpi_fortran_unweighted, - mpi_fortran_unweighted_, mpi_fortran_unweighted__); -DECL(int, MPI_FORTRAN_WEIGHTS_EMPTY, mpi_fortran_weights_empty, - mpi_fortran_weights_empty_, mpi_fortran_weights_empty__); -DECL(char *, MPI_FORTRAN_ARGV_NULL, mpi_fortran_argv_null, - mpi_fortran_argv_null_, mpi_fortran_argv_null__); -DECL(char *, MPI_FORTRAN_ARGVS_NULL, mpi_fortran_argvs_null, - mpi_fortran_argvs_null_, mpi_fortran_argvs_null__); -DECL(int *, MPI_FORTRAN_ERRCODES_IGNORE, mpi_fortran_errcodes_ignore, - mpi_fortran_errcodes_ignore_, mpi_fortran_errcodes_ignore__); -DECL(int *, MPI_FORTRAN_STATUS_IGNORE, mpi_fortran_status_ignore, - mpi_fortran_status_ignore_, mpi_fortran_status_ignore__); -DECL(int *, MPI_FORTRAN_STATUSES_IGNORE, mpi_fortran_statuses_ignore, - mpi_fortran_statuses_ignore_, mpi_fortran_statuses_ignore__); - -/* - * Create macros to do the checking. Only check for all 4 if we have - * weak symbols. Otherwise, just check for the one relevant symbol. - */ -#if OPAL_HAVE_WEAK_SYMBOLS -#define OMPI_IS_FORTRAN_BOTTOM(addr) \ - (addr == (void*) &MPI_FORTRAN_BOTTOM || \ - addr == (void*) &mpi_fortran_bottom || \ - addr == (void*) &mpi_fortran_bottom_ || \ - addr == (void*) &mpi_fortran_bottom__) -#define OMPI_IS_FORTRAN_IN_PLACE(addr) \ - (addr == (void*) &MPI_FORTRAN_IN_PLACE || \ - addr == (void*) &mpi_fortran_in_place || \ - addr == (void*) &mpi_fortran_in_place_ || \ - addr == (void*) &mpi_fortran_in_place__) -#define OMPI_IS_FORTRAN_UNWEIGHTED(addr) \ - (addr == (void*) &MPI_FORTRAN_UNWEIGHTED || \ - addr == (void*) &mpi_fortran_unweighted || \ - addr == (void*) &mpi_fortran_unweighted_ || \ - addr == (void*) &mpi_fortran_unweighted__) -#define OMPI_IS_FORTRAN_WEIGHTS_EMPTY(addr) \ - (addr == (void*) &MPI_FORTRAN_WEIGHTS_EMPTY || \ - addr == (void*) &mpi_fortran_weights_empty || \ - addr == (void*) &mpi_fortran_weights_empty_ || \ - addr == (void*) &mpi_fortran_weights_empty__) -#define OMPI_IS_FORTRAN_ARGV_NULL(addr) \ - (addr == (void*) &MPI_FORTRAN_ARGV_NULL || \ - addr == (void*) &mpi_fortran_argv_null || \ - addr == (void*) &mpi_fortran_argv_null_ || \ - addr == (void*) &mpi_fortran_argv_null__) -#define OMPI_IS_FORTRAN_ARGVS_NULL(addr) \ - (addr == (void*) &MPI_FORTRAN_ARGVS_NULL || \ - addr == (void*) &mpi_fortran_argvs_null || \ - addr == (void*) &mpi_fortran_argvs_null_ || \ - addr == (void*) &mpi_fortran_argvs_null__) -#define OMPI_IS_FORTRAN_ERRCODES_IGNORE(addr) \ - (addr == (void*) &MPI_FORTRAN_ERRCODES_IGNORE || \ - addr == (void*) &mpi_fortran_errcodes_ignore || \ - addr == (void*) &mpi_fortran_errcodes_ignore_ || \ - addr == (void*) &mpi_fortran_errcodes_ignore__) -#define OMPI_IS_FORTRAN_STATUS_IGNORE(addr) \ - (addr == (void*) &MPI_FORTRAN_STATUS_IGNORE || \ - addr == (void*) &mpi_fortran_status_ignore || \ - addr == (void*) &mpi_fortran_status_ignore_ || \ - addr == (void*) &mpi_fortran_status_ignore__) -#define OMPI_IS_FORTRAN_STATUSES_IGNORE(addr) \ - (addr == (void*) &MPI_FORTRAN_STATUSES_IGNORE || \ - addr == (void*) &mpi_fortran_statuses_ignore || \ - addr == (void*) &mpi_fortran_statuses_ignore_ || \ - addr == (void*) &mpi_fortran_statuses_ignore__) - -#elif OMPI_FORTRAN_CAPS -#define OMPI_IS_FORTRAN_BOTTOM(addr) \ - (addr == (void*) &MPI_FORTRAN_BOTTOM) -#define OMPI_IS_FORTRAN_IN_PLACE(addr) \ - (addr == (void*) &MPI_FORTRAN_IN_PLACE) -#define OMPI_IS_FORTRAN_UNWEIGHTED(addr) \ - (addr == (void*) &MPI_FORTRAN_UNWEIGHTED) -#define OMPI_IS_FORTRAN_WEIGHTS_EMPTY(addr) \ - (addr == (void*) &MPI_FORTRAN_WEIGHTS_EMPTY) -#define OMPI_IS_FORTRAN_ARGV_NULL(addr) \ - (addr == (void*) &MPI_FORTRAN_ARGV_NULL) -#define OMPI_IS_FORTRAN_ARGVS_NULL(addr) \ - (addr == (void*) &MPI_FORTRAN_ARGVS_NULL) -#define OMPI_IS_FORTRAN_ERRCODES_IGNORE(addr) \ - (addr == (void*) &MPI_FORTRAN_ERRCODES_IGNORE) -#define OMPI_IS_FORTRAN_STATUS_IGNORE(addr) \ - (addr == (void*) &MPI_FORTRAN_STATUS_IGNORE) -#define OMPI_IS_FORTRAN_STATUSES_IGNORE(addr) \ - (addr == (void*) &MPI_FORTRAN_STATUSES_IGNORE) - -#elif OMPI_FORTRAN_PLAIN -#define OMPI_IS_FORTRAN_BOTTOM(addr) \ - (addr == (void*) &mpi_fortran_bottom) -#define OMPI_IS_FORTRAN_IN_PLACE(addr) \ - (addr == (void*) &mpi_fortran_in_place) -#define OMPI_IS_FORTRAN_UNWEIGHTED(addr) \ - (addr == (void*) &mpi_fortran_unweighted) -#define OMPI_IS_FORTRAN_WEIGHTS_EMPTY(addr) \ - (addr == (void*) &mpi_fortran_weights_empty) -#define OMPI_IS_FORTRAN_ARGV_NULL(addr) \ - (addr == (void*) &mpi_fortran_argv_null) -#define OMPI_IS_FORTRAN_ARGVS_NULL(addr) \ - (addr == (void*) &mpi_fortran_argvs_null) -#define OMPI_IS_FORTRAN_ERRCODES_IGNORE(addr) \ - (addr == (void*) &mpi_fortran_errcodes_ignore) -#define OMPI_IS_FORTRAN_STATUS_IGNORE(addr) \ - (addr == (void*) &mpi_fortran_status_ignore) -#define OMPI_IS_FORTRAN_STATUSES_IGNORE(addr) \ - (addr == (void*) &mpi_fortran_statuses_ignore) - -#elif OMPI_FORTRAN_SINGLE_UNDERSCORE -#define OMPI_IS_FORTRAN_BOTTOM(addr) \ - (addr == (void*) &mpi_fortran_bottom_) -#define OMPI_IS_FORTRAN_IN_PLACE(addr) \ - (addr == (void*) &mpi_fortran_in_place_) -#define OMPI_IS_FORTRAN_UNWEIGHTED(addr) \ - (addr == (void*) &mpi_fortran_unweighted_) -#define OMPI_IS_FORTRAN_WEIGHTS_EMPTY(addr) \ - (addr == (void*) &mpi_fortran_weights_empty_) -#define OMPI_IS_FORTRAN_ARGV_NULL(addr) \ - (addr == (void*) &mpi_fortran_argv_null_) -#define OMPI_IS_FORTRAN_ARGVS_NULL(addr) \ - (addr == (void*) &mpi_fortran_argvs_null_) -#define OMPI_IS_FORTRAN_ERRCODES_IGNORE(addr) \ - (addr == (void*) &mpi_fortran_errcodes_ignore_) -#define OMPI_IS_FORTRAN_STATUS_IGNORE(addr) \ - (addr == (void*) &mpi_fortran_status_ignore_) -#define OMPI_IS_FORTRAN_STATUSES_IGNORE(addr) \ - (addr == (void*) &mpi_fortran_statuses_ignore_) - -#else -#define OMPI_IS_FORTRAN_BOTTOM(addr) \ - (addr == (void*) &mpi_fortran_bottom__) -#define OMPI_IS_FORTRAN_IN_PLACE(addr) \ - (addr == (void*) &mpi_fortran_in_place__) -#define OMPI_IS_FORTRAN_UNWEIGHTED(addr) \ - (addr == (void*) &mpi_fortran_unweighted__) -#define OMPI_IS_FORTRAN_WEIGHTS_EMPTY(addr) \ - (addr == (void*) &mpi_fortran_weights_empty__) -#define OMPI_IS_FORTRAN_ARGV_NULL(addr) \ - (addr == (void*) &mpi_fortran_argv_null__) -#define OMPI_IS_FORTRAN_ARGVS_NULL(addr) \ - (addr == (void*) &mpi_fortran_argvs_null__) -#define OMPI_IS_FORTRAN_ERRCODES_IGNORE(addr) \ - (addr == (void*) &mpi_fortran_errcodes_ignore__) -#define OMPI_IS_FORTRAN_STATUS_IGNORE(addr) \ - (addr == (void*) &mpi_fortran_status_ignore__) -#define OMPI_IS_FORTRAN_STATUSES_IGNORE(addr) \ - (addr == (void*) &mpi_fortran_statuses_ignore__) - -#endif /* weak / specific symbol type */ +#include "mpif-c-constants-decl.h" /* Convert between Fortran and C MPI_BOTTOM */ #define OMPI_F2C_BOTTOM(addr) (OMPI_IS_FORTRAN_BOTTOM(addr) ? MPI_BOTTOM : (addr)) @@ -254,4 +96,6 @@ DECL(int *, MPI_FORTRAN_STATUSES_IGNORE, mpi_fortran_statuses_ignore, #define OMPI_F2C_UNWEIGHTED(addr) (OMPI_IS_FORTRAN_UNWEIGHTED(addr) ? MPI_UNWEIGHTED : (addr)) #define OMPI_F2C_WEIGHTS_EMPTY(addr) (OMPI_IS_FORTRAN_WEIGHTS_EMPTY(addr) ? MPI_WEIGHTS_EMPTY : (addr)) +#endif /* OMPI_BUILD_FORTRAN_BINDINGS */ + #endif /* OMPI_FORTRAN_BASE_CONSTANTS_H */ diff --git a/ompi/mpi/fortran/base/gen-mpi-mangling.pl b/ompi/mpi/fortran/base/gen-mpi-mangling.pl new file mode 100755 index 00000000000..d061eed89dc --- /dev/null +++ b/ompi/mpi/fortran/base/gen-mpi-mangling.pl @@ -0,0 +1,206 @@ +#!/usr/bin/env perl +# +# Copyright (c) 2015 Research Organization for Information Science +# and Technology (RIST). All rights reserved. +# Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. +# $COPYRIGHT$ +# +# Subroutine to generate a bunch of Fortran declarations and symbols +# + +use strict; + +use Getopt::Long; + +my $caps_arg; +my $plain_arg; +my $single_underscore_arg; +my $double_underscore_arg; +my $help_arg = 0; + +&Getopt::Long::Configure("bundling"); +my $ok = Getopt::Long::GetOptions("caps=i" => \$caps_arg, + "plain=i" => \$plain_arg, + "single=i" => \$single_underscore_arg, + "double=i" => \$double_underscore_arg, + "help|h" => \$help_arg); + +if ($help_arg || !$ok) { + print "Usage: $0 [--caps|--plain|--single|--double] [--help]\n"; + exit(1 - $ok); +} + +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); +} + +############################################################### + +# Declare a hash of all the Fortran sentinel values + +my $fortran; + +$fortran->{bottom} = { + c_type => "int", + c_name => "mpi_fortran_bottom", + f_type => "integer", + f_name => "MPI_BOTTOM", +}; +$fortran->{in_place} = { + c_type => "int", + c_name => "mpi_fortran_in_place", + f_type => "integer", + f_name => "MPI_IN_PLACE", +}; +$fortran->{unweighted} = { + c_type => "int", + c_name => "mpi_fortran_unweighted", + f_type => "integer", + f_name => "MPI_UNWEIGHTED", +}; +$fortran->{weights_empty} = { + c_type => "int", + c_name => "mpi_fortran_weights_empty", + f_type => "integer", + f_name => "MPI_WEIGHTS_EMPTY", +}; + +$fortran->{argv_null} = { + c_type => "char *", + c_name => "mpi_fortran_argv_null", + f_type => "integer", + f_name => "MPI_ARGV_NULL", +}; +$fortran->{argvs_null} = { + c_type => "char *", + c_name => "mpi_fortran_argvs_null", + f_type => "integer", + f_name => "MPI_ARGVS_NULL", +}; + +$fortran->{errcodes_ignore} = { + c_type => "int *", + c_name => "mpi_fortran_errcodes_ignore", + f_type => "integer", + f_name => "MPI_ERRCODES_IGNORE", +}; +$fortran->{status_ignore} = { + c_type => "int *", + c_name => "mpi_fortran_status_ignore", + f_type => "type(MPI_STATUS)", + f_name => "MPI_STATUS_IGNORE", +}; +$fortran->{statuses_ignore} = { + c_type => "int *", + c_name => "mpi_fortran_statuses_ignore", + f_type => "type(MPI_STATUS)", + f_name => "MPI_STATUSES_IGNORE(1)", +}; + +############################################################### + +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"; + + 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 + */ + +/* 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 + without also changing ompi/runtime/ompi_mpi_init.c and + ompi/include/mpif-common.h. */\n\n"; + + foreach my $key (sort(keys(%{$fortran}))) { + my $f = $fortran->{$key}; + my $m = mangle($f->{c_name}); + print OUT "extern $f->{c_type} $m; +#define OMPI_IS_FORTRAN_" . uc($key) . "(addr) \\ + (addr == (void*) &$m)\n\n"; + } + + close(OUT); +} + +sub gen_c_constants { + open(OUT, ">$file_c_constants") || + die "Can't write to $file_c_constants"; + + 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}; + my $m = mangle($f->{c_name}); + print OUT "$f->{c_type} $m;\n"; + } + + 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/use-mpi-f08-desc/mpi-f08-types.f90 b/ompi/mpi/fortran/use-mpi-f08-desc/mpi-f08-types.f90 index dbfcc16b9bb..ec6fbf2ca31 100644 --- a/ompi/mpi/fortran/use-mpi-f08-desc/mpi-f08-types.f90 +++ b/ompi/mpi/fortran/use-mpi-f08-desc/mpi-f08-types.f90 @@ -3,6 +3,8 @@ ! Copyright (c) 2009 Cisco Systems, Inc. All rights reserved. ! Copyright (c) 2009-2012 Los Alamos National Security, LLC. ! All rights reserved. +! Copyright (c) 2015 Research Organization for Information Science +! and Technology (RIST). All rights reserved. ! ! This file creates mappings between MPI C types (e.g., MPI_Comm) and ! variables (e.g., MPI_COMM_WORLD) and corresponding Fortran names @@ -151,7 +153,6 @@ module mpi_f08_types ! ! STATUS/STATUSES_IGNORE ! - type(MPI_STATUS), bind(C, name="mpi_fortran_status_ignore") :: MPI_STATUS_IGNORE - type(MPI_STATUS), bind(C, name="mpi_fortran_statuses_ignore") :: MPI_STATUSES_IGNORE(1) +#include "mpif-f08-types.h" end module mpi_f08_types diff --git a/ompi/mpi/fortran/use-mpi-f08/mpi-f08-types.F90 b/ompi/mpi/fortran/use-mpi-f08/mpi-f08-types.F90 index 43fcf5301e8..40049aaf53e 100644 --- a/ompi/mpi/fortran/use-mpi-f08/mpi-f08-types.F90 +++ b/ompi/mpi/fortran/use-mpi-f08/mpi-f08-types.F90 @@ -3,6 +3,8 @@ ! Copyright (c) 2009-2014 Cisco Systems, Inc. All rights reserved. ! Copyright (c) 2009-2012 Los Alamos National Security, LLC. ! All rights reserved. +! Copyright (c) 2015 Research Organization for Information Science +! and Technology (RIST). All rights reserved. ! $COPYRIGHT$ ! ! This file creates mappings between MPI C types (e.g., MPI_Comm) and @@ -164,15 +166,7 @@ module mpi_f08_types !... Special sentinel constants !------------------------------ - type(MPI_STATUS), bind(C, name="mpi_fortran_status_ignore") :: MPI_STATUS_IGNORE - type(MPI_STATUS), bind(C, name="mpi_fortran_statuses_ignore") :: MPI_STATUSES_IGNORE(1) - integer, bind(C, name="mpi_fortran_bottom") :: MPI_BOTTOM - integer, bind(C, name="mpi_fortran_in_place") :: MPI_IN_PLACE - integer, bind(C, name="mpi_fortran_argv_null") :: MPI_ARGV_NULL - integer, bind(C, name="mpi_fortran_argvs_null") :: MPI_ARGVS_NULL - integer, bind(C, name="mpi_fortran_errcodes_ignore") :: MPI_ERRCODES_IGNORE - integer, bind(C, name="mpi_fortran_unweighted") :: MPI_UNWEIGHTED - integer, bind(C, name="mpi_fortran_weights_empty") :: MPI_WEIGHTS_EMPTY +#include "mpif-f08-types.h" !... Interfaces for operators with handles !----------------------------------------- diff --git a/ompi/runtime/ompi_mpi_init.c b/ompi/runtime/ompi_mpi_init.c index 596449ded3a..7edd98dc5ff 100644 --- a/ompi/runtime/ompi_mpi_init.c +++ b/ompi/runtime/ompi_mpi_init.c @@ -10,7 +10,7 @@ * University of Stuttgart. All rights reserved. * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. - * Copyright (c) 2006-2014 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2006-2015 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2006-2015 Los Alamos National Security, LLC. All rights * reserved. * Copyright (c) 2006-2009 University of Houston. All rights reserved. @@ -257,30 +257,7 @@ MPI_Fint *MPI_F_STATUSES_IGNORE = NULL; ompi/include/mpif-common.h. */ -#define INST(type, value, upper_case, lower_case, single_u, double_u) \ -type lower_case = value; \ -type upper_case = value; \ -type single_u = value; \ -type double_u = value - -INST(int, -1, MPI_FORTRAN_BOTTOM, mpi_fortran_bottom, - mpi_fortran_bottom_, mpi_fortran_bottom__); -INST(int, -1, MPI_FORTRAN_IN_PLACE, mpi_fortran_in_place, - mpi_fortran_in_place_, mpi_fortran_in_place__); -INST(int, -1, MPI_FORTRAN_UNWEIGHTED, mpi_fortran_unweighted, - mpi_fortran_unweighted_, mpi_fortran_unweighted__); -INST(int, -1, MPI_FORTRAN_WEIGHTS_EMPTY, mpi_fortran_weights_empty, - mpi_fortran_weights_empty_, mpi_fortran_weights_empty__); -INST(char *, NULL, MPI_FORTRAN_ARGV_NULL, mpi_fortran_argv_null, - mpi_fortran_argv_null_, mpi_fortran_argv_null__); -INST(char *, NULL, MPI_FORTRAN_ARGVS_NULL, mpi_fortran_argvs_null, - mpi_fortran_argvs_null_, mpi_fortran_argvs_null__); -INST(int *, NULL, MPI_FORTRAN_ERRCODES_IGNORE, mpi_fortran_errcodes_ignore, - mpi_fortran_errcodes_ignore_, mpi_fortran_errcodes_ignore__); -INST(int *, NULL, MPI_FORTRAN_STATUS_IGNORE, mpi_fortran_status_ignore, - mpi_fortran_status_ignore_, mpi_fortran_status_ignore__); -INST(int *, NULL, MPI_FORTRAN_STATUSES_IGNORE, mpi_fortran_statuses_ignore, - mpi_fortran_statuses_ignore_, mpi_fortran_statuses_ignore__); +#include "mpif-c-constants.h" /* * Hash tables for MPI_Type_create_f90* functions diff --git a/oshmem/runtime/oshmem_shmem_init.c b/oshmem/runtime/oshmem_shmem_init.c index 2fada1a6035..9a8de5760d0 100644 --- a/oshmem/runtime/oshmem_shmem_init.c +++ b/oshmem/runtime/oshmem_shmem_init.c @@ -4,6 +4,7 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * + * Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow From 8d58e5847f6854a4dd6c8d9dd4fe76bec5ba2a82 Mon Sep 17 00:00:00 2001 From: Gilles Gouaillardet Date: Wed, 29 Jul 2015 10:00:27 +0900 Subject: [PATCH 3/3] fortran: optimize testall and waitall when MPI_STATUSES_IGNORE is used (back-ported from commit open-mpi/ompi@83375bcc5c69121ebad7c1df67211ac08729c570) --- ompi/mpi/fortran/mpif-h/testall_f.c | 7 ++++--- ompi/mpi/fortran/mpif-h/waitall_f.c | 15 ++++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ompi/mpi/fortran/mpif-h/testall_f.c b/ompi/mpi/fortran/mpif-h/testall_f.c index bfb698ec2a2..fd946c35633 100644 --- a/ompi/mpi/fortran/mpif-h/testall_f.c +++ b/ompi/mpi/fortran/mpif-h/testall_f.c @@ -10,6 +10,8 @@ * Copyright (c) 2004-2005 The Regents of the University of California. * All rights reserved. * Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -107,11 +109,10 @@ void ompi_testall_f(MPI_Fint *count, MPI_Fint *array_of_requests, ompi_fortran_l /* All Fortran Compilers have FALSE == 0, so just check for any nonzero value (because TRUE is not always == 1) */ - if (MPI_SUCCESS == c_ierr && *flag) { + if (MPI_SUCCESS == c_ierr && !OMPI_IS_FORTRAN_STATUSES_IGNORE(array_of_statuses) && *flag) { for (i = 0; i < OMPI_FINT_2_INT(*count); ++i) { array_of_requests[i] = c_req[i]->req_f_to_c_index; - if (!OMPI_IS_FORTRAN_STATUSES_IGNORE(array_of_statuses) && - !OMPI_IS_FORTRAN_STATUS_IGNORE(&array_of_statuses[i])) { + if (!OMPI_IS_FORTRAN_STATUS_IGNORE(&array_of_statuses[i])) { MPI_Status_c2f(&c_status[i], &array_of_statuses[i * (sizeof(MPI_Status) / sizeof(int))]); } } diff --git a/ompi/mpi/fortran/mpif-h/waitall_f.c b/ompi/mpi/fortran/mpif-h/waitall_f.c index 5cabd6274e4..8428245ea1f 100644 --- a/ompi/mpi/fortran/mpif-h/waitall_f.c +++ b/ompi/mpi/fortran/mpif-h/waitall_f.c @@ -5,15 +5,17 @@ * 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, + * 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) 2011-2012 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. * $COPYRIGHT$ - * + * * Additional copyrights may follow - * + * * $HEADER$ */ @@ -102,12 +104,11 @@ void ompi_waitall_f(MPI_Fint *count, MPI_Fint *array_of_requests, c_ierr = MPI_Waitall(OMPI_FINT_2_INT(*count), c_req, c_status); if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr); - if (MPI_SUCCESS == c_ierr) { + if (MPI_SUCCESS == c_ierr && !OMPI_IS_FORTRAN_STATUSES_IGNORE(array_of_statuses)) { for (i = 0; i < OMPI_FINT_2_INT(*count); ++i) { array_of_requests[i] = c_req[i]->req_f_to_c_index; - if (!OMPI_IS_FORTRAN_STATUSES_IGNORE(array_of_statuses) && - !OMPI_IS_FORTRAN_STATUS_IGNORE(&array_of_statuses[i])) { - MPI_Status_c2f( &c_status[i], &array_of_statuses[i * (sizeof(MPI_Status) / sizeof(int))]); + if (!OMPI_IS_FORTRAN_STATUS_IGNORE(&array_of_statuses[i])) { + MPI_Status_c2f( &c_status[i], &array_of_statuses[i * (sizeof(MPI_Status) / sizeof(int))]); } } }