Skip to content

Commit

Permalink
Merge pull request open-mpi#434 from ggouaillardet/topic/v2.x/f08_bin…
Browse files Browse the repository at this point in the history
…dings_and_makefiles

Topic/v2.x/f08 bindings and makefiles
  • Loading branch information
jsquyres committed Jul 31, 2015
2 parents d21acb2 + 8d58e58 commit fb6b1fe
Show file tree
Hide file tree
Showing 14 changed files with 287 additions and 220 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions config/ompi_setup_mpi_fortran.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 22 additions & 4 deletions ompi/include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 += \
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down
7 changes: 5 additions & 2 deletions ompi/mpi/fortran/base/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

#-----------------------------------------------------------------------------

Expand Down
170 changes: 7 additions & 163 deletions ompi/mpi/fortran/base/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -85,173 +88,14 @@
* 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))
#define OMPI_F2C_IN_PLACE(addr) (OMPI_IS_FORTRAN_IN_PLACE(addr) ? MPI_IN_PLACE : (addr))
#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 */
Loading

0 comments on commit fb6b1fe

Please sign in to comment.