1
1

Fortran: put type(c_ptr) interfaces in a separate file in the TKR mpi module

Older gfortran compilers (e.g., the gfortran that ships in RHEL5) do
not support ISO_C_BINDING, and therefore do not support the
TYPE(C_PTR) type.  As such, they cannot support the overloaded
interfaces for MPI_WIN_ALLOCATE_SHARED and MPI_SHARED_QUERY that are
mandated in MPI-3.

So we separate those interfaces out into a separate .F90 file that is
#include'd in the tkr mpi.F90 file.  In this separate .F90 file, we
use an #if to determine whether the compiler supports ISO_C_BINDING or
not.

Also re-jiggered the order of testing in ompi_setup_mpi_fortran.m4: we
now need to test whether the compiler supports ISO_C_BINDING even when
we're only building the mpi module (not strictly when we're building
the mpi_f08 module).

Finally, tweaked the use-mpi-tkr/Makefile.am to:

* Add some proper dependencies for mpi.F90
* Allow the general AM compilation to be used instead of supplying a
  specific rule for compiling mpi.F90

cmr=v1.8.2:ticket=trac:4736

This commit was SVN r32204.

The following Trac tickets were found above:
  Ticket 4736 --> https://svn.open-mpi.org/trac/ompi/ticket/4736
Этот коммит содержится в:
Jeff Squyres 2014-07-10 19:10:03 +00:00
родитель a523dba41d
Коммит 0089ac20af
6 изменённых файлов: 114 добавлений и 66 удалений

Просмотреть файл

@ -284,6 +284,13 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
OMPI_FORTRAN_USEMPI_LIB=-lmpi_usempi])
])
OMPI_FORTRAN_HAVE_ISO_C_BINDING=0
AS_IF([test $OMPI_WANT_FORTRAN_USEMPI_BINDINGS -eq 1 && \
test $ompi_fortran_happy -eq 1],
[OMPI_FORTRAN_CHECK_ISO_C_BINDING(
[OMPI_FORTRAN_HAVE_ISO_C_BINDING=1],
[OMPI_FORTRAN_HAVE_ISO_C_BINDING=0])])
AC_MSG_CHECKING([if building Fortran 'use mpi' bindings])
AS_IF([test $OMPI_BUILD_FORTRAN_USEMPI_BINDINGS -eq 1],
[AC_MSG_RESULT([yes])],
@ -309,14 +316,11 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
# the necessary forms of BIND(C)
OMPI_FORTRAN_HAVE_BIND_C=0
OMPI_FORTRAN_HAVE_ISO_C_BINDING=0
AS_IF([test $OMPI_WANT_FORTRAN_USEMPIF08_BINDINGS -eq 1 -a \
$OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS -eq 1],
[ # If we don't have ISO C bindings, we won't build mpi_f08 at all
OMPI_FORTRAN_CHECK_ISO_C_BINDING(
[OMPI_FORTRAN_HAVE_ISO_C_BINDING=1],
[OMPI_FORTRAN_HAVE_ISO_C_BINDING=0
OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS=0])])
AS_IF([test "$OMPI_FORTRAN_HAVE_ISO_C_BINDING" -eq 0],
[OMPI_BUILD_FORTRAN_USEMPIF08_BINDINGS=0])])
OMPI_FORTRAN_HAVE_BIND_C_SUB=0
AS_IF([test $OMPI_WANT_FORTRAN_USEMPIF08_BINDINGS -eq 1 -a \
@ -628,6 +632,7 @@ end type test_mpi_handle],
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_BIND_C,
[$OMPI_FORTRAN_HAVE_BIND_C],
[For ompi_info: Whether the compiler supports all forms of BIND(C) that we need])
AC_SUBST(OMPI_FORTRAN_HAVE_ISO_C_BINDING)
AC_DEFINE_UNQUOTED(OMPI_FORTRAN_HAVE_ISO_C_BINDING,
[$OMPI_FORTRAN_HAVE_ISO_C_BINDING],
[For ompi_info: Whether the compiler supports ISO_C_BINDING or not])

Просмотреть файл

@ -35,6 +35,9 @@
! Whether we have ASYNCHRONOUS or not
#define OMPI_FORTRAN_HAVE_ASYNCHRONOUS @OMPI_FORTRAN_HAVE_ASYNCHRONOUS@
! Whether we have ISO C binding or not
#define OMPI_FORTRAN_HAVE_ISO_C_BINDING @OMPI_FORTRAN_HAVE_ISO_C_BINDING@
! Whether we are building the MPI F08 bindings with subarray support or not
#define OMPI_FORTRAN_SUBARRAYS_SUPPORTED @OMPI_FORTRAN_SUBARRAYS_SUPPORTED@

Просмотреть файл

@ -30,8 +30,12 @@ if OMPI_BUILD_FORTRAN_USEMPI_TKR_BINDINGS
########################################################################
# Note the "-I." in the flags below. This is because mpi.F90 includes
# mpi-f90-interfaces.h, which will be in the build tree (i.e., the
# current directory) because it is generated.
AM_FCFLAGS = -I$(top_builddir)/ompi/include -I$(top_srcdir)/ompi/include \
$(OMPI_FC_MODULE_FLAG). -I$(srcdir) \
$(OMPI_FC_MODULE_FLAG). -I$(srcdir) -I. \
-I$(top_builddir)/ompi/mpi/fortran/use-mpi-tkr $(FCFLAGS_f90)
# Do different things if the top-level configure decided that we're
@ -48,12 +52,20 @@ lib_LTLIBRARIES += libmpi_usempi.la
# list this here (i.e., "mpi-f90-interfaces.h" is included in
# mpi.F90).
# Note the "-I." in the command below. This is because mpi.F90
# includes mpi-f90-interfaces.h, which will be in the build tree
# (i.e., the current directory) because it is generated.
mpi.lo: mpi.F90
mpi.lo: mpi-f90-interfaces.h
mpi.lo: $(top_builddir)/ompi/mpi/fortran/configure-fortran-output.h
mpi.lo: mpi-f90-cptr-interfaces.F90
mpi.o: mpi.F90 mpi-f90-interfaces.h
$(FCCOMPILE) -c -I. -o $@ $(FCFLAGS_f90) $<
# These files must be EXTRA_DIST'ed because they are included; they
# are not compiled directly (and we *can't* list the .F90 file in
# _SOURCES, because it would be compiled -- but it *must* have a .F90
# suffix so that the Fortran compiler will interpret the #if
# directives properly).
EXTRA_DIST = \
mpi-f90-interfaces.h \
mpi-f90-cptr-interfaces.F90
endif
@ -64,7 +76,6 @@ endif
libmpi_usempi_la_SOURCES = \
mpi.F90 \
mpi-f90-interfaces.h \
mpi_comm_spawn_multiple_f90.f90 \
mpi_sizeof.f90 \
mpi_testall_f90.f90 \

Просмотреть файл

@ -0,0 +1,77 @@
! -*- fortran -*-
!
! Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
! $COPYRIGHT$
!
! Additional copyrights may follow
!
! $HEADER$
!
! This file contains interfaces that use the ISO_C_BINDING module and
! the TYPE(C_PTR) type, which not all Fortran compilers support (e.g.,
! gfortran on RHEL 5 does not support this module/type). So we use a
! preprocessor macro to protect the problematic declarations.
!
! This file is included via a preprocessor include directorive in
! mpi.F90, which allows us to use the preprocessor "if" directive,
! below.
!
interface MPI_Win_allocate_shared
subroutine MPI_Win_allocate_shared(size, disp_unit, info, comm, &
baseptr, win, ierror)
include 'mpif-config.h'
integer(KIND=MPI_ADDRESS_KIND), intent(in) :: size
integer, intent(in) :: disp_unit
integer, intent(in) :: info
integer, intent(in) :: comm
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: baseptr
integer, intent(out) :: win
integer, intent(out) :: ierror
end subroutine MPI_Win_allocate_shared
! Only include the 2nd interface if we have ISO_C_BINDING / TYPE(C_PTR)
#if OMPI_FORTRAN_HAVE_ISO_C_BINDING
subroutine MPI_Win_allocate_shared_cptr(size, disp_unit, info, comm, &
baseptr, win, ierror)
use, intrinsic :: iso_c_binding, only : c_ptr
include 'mpif-config.h'
integer :: disp_unit, info, comm, win, ierror
integer(KIND=MPI_ADDRESS_KIND) :: size
type(C_PTR) :: baseptr
end subroutine MPI_Win_allocate_shared_cptr
#endif
end interface
interface MPI_Win_shared_query
subroutine MPI_Win_shared_query(win, rank, size, disp_unit, baseptr,&
ierror)
include 'mpif-config.h'
integer, intent(in) :: win
integer, intent(in) :: rank
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: size
integer, intent(out) :: disp_unit
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: baseptr
integer, intent(out) :: ierror
end subroutine MPI_Win_shared_query
! Only include the 2nd interface if we have ISO_C_BINDING / TYPE(C_PTR)
#if OMPI_FORTRAN_HAVE_ISO_C_BINDING
subroutine MPI_Win_shared_query_cptr(win, rank, size, disp_unit, baseptr,&
ierror)
use, intrinsic :: iso_c_binding, only : c_ptr
include 'mpif-config.h'
integer, intent(in) :: win
integer, intent(in) :: rank
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: size
integer, intent(out) :: disp_unit
type(C_PTR), intent(out) :: baseptr
integer, intent(out) :: ierror
end subroutine MPI_Win_shared_query_cptr
#endif
end interface

Просмотреть файл

@ -2881,32 +2881,6 @@ end subroutine MPI_Waitsome
end interface
interface MPI_Win_allocate_shared
subroutine MPI_Win_allocate_shared(size, disp_unit, info, comm, &
baseptr, win, ierror)
include 'mpif-config.h'
integer(KIND=MPI_ADDRESS_KIND), intent(in) :: size
integer, intent(in) :: disp_unit
integer, intent(in) :: info
integer, intent(in) :: comm
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: baseptr
integer, intent(out) :: win
integer, intent(out) :: ierror
end subroutine MPI_Win_allocate_shared
subroutine MPI_Win_allocate_shared_cptr(size, disp_unit, info, comm, &
baseptr, win, ierror)
use, intrinsic :: iso_c_binding, only : c_ptr
include 'mpif-config.h'
integer :: disp_unit, info, comm, win, ierror
integer(KIND=MPI_ADDRESS_KIND) :: size
type(C_PTR) :: baseptr
end subroutine MPI_Win_allocate_shared_cptr
end interface
interface MPI_Win_call_errhandler
subroutine MPI_Win_call_errhandler(win, errorcode, ierror)
@ -3103,34 +3077,6 @@ end subroutine MPI_Win_set_name
end interface
interface MPI_Win_shared_query
subroutine MPI_Win_shared_query(win, rank, size, disp_unit, baseptr,&
ierror)
include 'mpif-config.h'
integer, intent(in) :: win
integer, intent(in) :: rank
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: size
integer, intent(out) :: disp_unit
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: baseptr
integer, intent(out) :: ierror
end subroutine MPI_Win_shared_query
subroutine MPI_Win_shared_query_cptr(win, rank, size, disp_unit, baseptr,&
ierror)
use, intrinsic :: iso_c_binding, only : c_ptr
include 'mpif-config.h'
integer, intent(in) :: win
integer, intent(in) :: rank
integer(KIND=MPI_ADDRESS_KIND), intent(out) :: size
integer, intent(out) :: disp_unit
type(C_PTR), intent(out) :: baseptr
integer, intent(out) :: ierror
end subroutine MPI_Win_shared_query_cptr
end interface
interface MPI_Win_start
subroutine MPI_Win_start(group, assert, win, ierror)

Просмотреть файл

@ -39,6 +39,12 @@ module mpi
include "ompi/mpi/fortran/base/conversion-fn-null-int-interface.h"
! Functions that have overloaded interfaces with TYPE(C_PTR) (which
! this compiler may or may not support). We use an "if" preprocessor
! macro in this file, so we need to use the preprocessor include
! directive, not the Fortran include.
#include "mpi-f90-cptr-interfaces.F90"
! This file is generated, and is *huge*. Its size is directly related
! to the --with-f90-max-array-dim configure parameter.