Skip to content

Commit

Permalink
Merge pull request #3 from jsquyres/topic/fortran-sizeof-fixes
Browse files Browse the repository at this point in the history
fortran: fix the MPI_SIZEOF problems in the Fortran interfaces
RM-approved
  • Loading branch information
rhc54 committed Oct 7, 2014
2 parents cfc2d64 + e7a268e commit aad74f5
Show file tree
Hide file tree
Showing 24 changed files with 834 additions and 1,978 deletions.
8 changes: 8 additions & 0 deletions .gitignore_global → .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ ompi/include/mpif-constants.h
ompi/include/mpif-io-handles.h
ompi/include/mpif-handles.h
ompi/include/mpif-io-constants.h
ompi/include/mpif-sizeof.h
ompi/include/mpi_portable_platform.h
ompi/include/ompi/version.h
ompi/include/ompi/frameworks.h
Expand Down Expand Up @@ -379,10 +380,17 @@ ompi/mpi/fortran/base/*.mod
ompi/mpi/fortran/mpiext/mpi-ext-module.F90
ompi/mpi/fortran/mpiext/mpi-f08-ext-module.F90
ompi/mpi/fortran/mpiext/*.mod
ompi/mpi/fortran/mpif-h/sizeof_f.f90
ompi/mpi/fortran/mpif-h/profile/p*.c
ompi/mpi/fortran/mpif-h/profile/psizeof_f.f90
ompi/mpi/fortran/use-mpi-f08/constants.h
ompi/mpi/fortran/use-mpi-f08/*.mod
ompi/mpi/fortran/use-mpi-f08/sizeof_f08.f90
ompi/mpi/fortran/use-mpi-f08/sizeof_f08.h
ompi/mpi/fortran/use-mpi-f08/profile/psizeof_f08.f90
ompi/mpi/fortran/use-mpi-f08-desc/*.mod
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-sizeof.f90
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-sizeof.h
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-interfaces.h
ompi/mpi/fortran/use-mpi-ignore-tkr/mpi-ignore-tkr-file-interfaces.h
ompi/mpi/fortran/use-mpi-ignore-tkr/*.mod
Expand Down
11 changes: 10 additions & 1 deletion Makefile.man-page-rules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- makefile -*-
# Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2008-2014 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
# $COPYRIGHT$
#
Expand Down Expand Up @@ -28,3 +28,12 @@
-e 's/#PACKAGE_VERSION#/@PACKAGE_VERSION@/g' \
-e 's/#OMPI_DATE#/@OMPI_RELEASE_DATE@/g' \
> $@ < $<

# A little verbosity magic; "make" will show the terse output. "make
# V=1" will show the actual commands used (just like the other
# Automake-generated compilation/linker rules).
V=0

OMPI_V_GEN = $(ompi__v_GEN_$V)
ompi__v_GEN_ = $(ompi__v_GEN_$AM_DEFAULT_VERBOSITY)
ompi__v_GEN_0 = @echo " GENERATE" $@;
15 changes: 14 additions & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ Compiler Notes

The following notes apply to the above-listed Fortran bindings:

- All Fortran compilers support the mpif.h/shmem.fh-based bindings.
- All Fortran compilers support the mpif.h/shmem.fh-based bindings,
with one exception: the MPI_SIZEOF interfaces will only be present
when Open MPI is built with a Fortran compiler that support the
INTERFACE keyword and ISO_FORTRAN_ENV. Most notably, this
excludes the GNU Fortran compiler suite before version 4.9.

- The level of support provided by the mpi module is based on your
Fortran compiler.
Expand All @@ -381,6 +385,9 @@ Compiler Notes
parameter type checking at run-time (e.g., MPI_INIT,
MPI_COMM_RANK, etc.).

Similar to the mpif.h interface, MPI_SIZEOF is only supported on
Fortran compilers that support INTERFACE and ISO_FORTRAN_ENV.

- The mpi_f08 module is new and has been tested with the Intel
Fortran compiler and gfortran >= v4.9. Other modern Fortran
compilers may also work (but are, as yet, only lightly tested).
Expand All @@ -390,6 +397,12 @@ Compiler Notes
features to support the mpi_f08 module. For example, gfortran <
v4.9 does provide enough support for the mpi_f08 module.

You can examine the output of the following command to see all
the Fortran features that are/are not enabled in your Open MPI
installation:

shell$ ompi_info | grep -i fort


General Run-Time Support Notes
------------------------------
Expand Down
51 changes: 51 additions & 0 deletions config/ompi_fortran_check_interface.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl

# Check whether or not the Fortran compiler supports the "interface"
# keyword or not.

# OMPI_FORTRAN_CHECK_INTERFACE([action if found],
# [action if not found])
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_INTERFACE],[
AS_VAR_PUSHDEF([interface_var], [ompi_cv_fortran_interface])

AC_CACHE_CHECK([if Fortran compiler supports INTERFACE], interface_var,
[AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[MODULE my_module
INTERFACE MPI_Foo
SUBROUTINE inky(a)
DOUBLE PRECISION A
END SUBROUTINE inky
SUBROUTINE blinky(a)
INTEGER A
END SUBROUTINE blinky
END INTERFACE MPI_Foo
END MODULE my_module]])],
[AS_VAR_SET(interface_var, yes)],
[AS_VAR_SET(interface_var, no)])
touch conftest_foo.mod
rm -rf *.mod 2>/dev/null
AC_LANG_POP([Fortran])
])

AS_VAR_IF(interface_var, [yes], [$1], [$2])
AS_VAR_POPDEF([interface_var])dnl
])
42 changes: 42 additions & 0 deletions config/ompi_fortran_check_iso_fortran_env.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl

# Check whether or not the Fortran compiler supports iso_fortran_env or not
#
# OMPI_FORTRAN_CHECK_ISO_FORTRAN_ENV([action if found], [action if not found])
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_ISO_FORTRAN_ENV],[
AS_VAR_PUSHDEF([iso_fortran_env_var], [ompi_cv_fortran_have_iso_fortran_env])

AC_CACHE_CHECK([if Fortran compiler supports ISO_FORTRAN_ENV], iso_fortran_env_var,
[AC_LANG_PUSH([Fortran])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[program check_for_iso_fortran_env
use, intrinsic :: iso_fortran_env
real(real32) :: var
var = 12.34
end program]])],
[AS_VAR_SET(iso_fortran_env_var, yes)],
[AS_VAR_SET(iso_fortran_env_var, no)])
AC_LANG_POP([Fortran])
])

AS_VAR_IF(iso_fortran_env_var, [yes], [$1], [$2])
AS_VAR_POPDEF([iso_fortran_env_var])
])
69 changes: 69 additions & 0 deletions config/ompi_fortran_check_max_array_rank.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl

# Check the max array rank that the Fortran compiler supports.
#
# OMPI_FORTRAN_CHECK_MAX_ARRAY_RANK
#
# Sets $OMPI_FORTRAN_MAX_ARRAY_RANK, AC_SUBSTs it, and AC_DEFINEs
# OMPI_FORTRAN_MAX_ARRAY_RANK.
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_MAX_ARRAY_RANK],[
AS_VAR_PUSHDEF([max_array_rank_var], [ompi_cv_fortran_max_array_rank])

OPAL_VAR_SCOPE_PUSH([f_max_rank f_fail f_rank f_i f_dim])
AC_CACHE_CHECK([max supported Fortran array rank], max_array_rank_var,
[AC_LANG_PUSH([Fortran])
f_max_rank=0
f_fail=0

# Realistically, this will only be 7 or 15. But what the heck
# -- try them all. Note that we don't test above 15, because
# that's the max value from the F2008 spec (and some compilers
# will let you go above rank=16, e.g., Intel ifort).
for f_rank in 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
if test $f_fail -eq 0; then
f_i=1
f_dim=2
while test `expr $f_i + 1` -le $f_rank; do
f_dim="$f_dim,2"
f_i=`expr $f_i + 1`
done
OPAL_LOG_MSG([testing Fortran dimension $f_rank / $f_dim])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[PROGRAM test_program
INTEGER, DIMENSION($f_dim) :: var
var($f_dim) = 3
END PROGRAM test_program]])],
[f_max_rank=$f_rank], [f_fail=1])
fi
done
AS_VAR_SET(max_array_rank_var, $f_max_rank)
AC_LANG_POP([Fortran])
])

AS_VAR_COPY([OMPI_FORTRAN_MAX_ARRAY_RANK], [max_array_rank_var])
AC_SUBST(OMPI_FORTRAN_MAX_ARRAY_RANK)
AC_DEFINE_UNQUOTED([OMPI_FORTRAN_MAX_ARRAY_RANK],
[$OMPI_FORTRAN_MAX_ARRAY_RANK],
[Max dimension rank of Fortran arrays])

OPAL_VAR_SCOPE_POP
AS_VAR_POPDEF([max_array_rank_var])dnl
])
106 changes: 106 additions & 0 deletions config/ompi_fortran_check_storage_size.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2010-2014 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl

# Check whether or not the Fortran compiler supports storage_size()
# for all relevant types or not. E.g., gfortran 4.8 supports
# storage_size() on some types, not but all.
#
# OMPI_FORTRAN_CHECK_STORAGE_SIZE([action if found], [action if not found])
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_STORAGE_SIZE],[
AS_VAR_PUSHDEF([fortran_storage_size_var], [ompi_cv_fortran_have_storage_size])

AC_CACHE_CHECK([if Fortran compiler supports STORAGE_SIZE for relevant types],
fortran_storage_size_var,
[AC_LANG_PUSH([Fortran])
AC_LINK_IFELSE([AC_LANG_SOURCE([[program check_for_storage_size
USE, INTRINSIC :: iso_fortran_env, ONLY: REAL32, INT32
integer size
complex(real32) :: c32
complex(real32), dimension(5) :: c32_array
real(real32) :: r32
real(real32), dimension(5) :: r32_array
integer(int32) :: i32
integer(int32), dimension(5) :: i32_array

call storage_size_complex32_scalar(c32, size)
call storage_size_complex32_r1(c32_array, size)
call storage_size_int32_scalar(i32, size)
call storage_size_int32_r1(i32_array, size)
call storage_size_real32_scalar(r32, size)
call storage_size_real32_r1(r32_array, size)
end program

SUBROUTINE storage_size_complex32_scalar(x, size)
USE, INTRINSIC :: iso_fortran_env, ONLY: REAL32
COMPLEX(REAL32) ::x
INTEGER, INTENT(OUT) :: size

size = storage_size(x) / 8
END SUBROUTINE storage_size_complex32_scalar

SUBROUTINE storage_size_complex32_r1(x, size)
USE, INTRINSIC :: iso_fortran_env, ONLY: REAL32
COMPLEX(REAL32), DIMENSION(*)::x
INTEGER, INTENT(OUT) :: size

size = storage_size(x) / 8
END SUBROUTINE storage_size_complex32_r1

SUBROUTINE storage_size_int32_scalar(x, size)
USE, INTRINSIC :: iso_fortran_env, ONLY: INT32
INTEGER(INT32) ::x
INTEGER, INTENT(OUT) :: size

size = storage_size(x) / 8
END SUBROUTINE storage_size_int32_scalar

SUBROUTINE storage_size_int32_r1(x, size)
USE, INTRINSIC :: iso_fortran_env, ONLY: INT32
INTEGER(INT32), DIMENSION(*)::x
INTEGER, INTENT(OUT) :: size

size = storage_size(x) / 8
END SUBROUTINE storage_size_int32_r1

SUBROUTINE storage_size_real32_scalar(x, size)
USE, INTRINSIC :: iso_fortran_env, ONLY: REAL32
REAL(REAL32) ::x
INTEGER, INTENT(OUT) :: size

size = storage_size(x) / 8
END SUBROUTINE storage_size_real32_scalar

SUBROUTINE storage_size_real32_r1(x, size)
USE, INTRINSIC :: iso_fortran_env, ONLY: REAL32
REAL(REAL32), DIMENSION(*)::x
INTEGER, INTENT(OUT) :: size

size = storage_size(x) / 8
END SUBROUTINE storage_size_real32_r1
]])],
[AS_VAR_SET(fortran_storage_size_var, yes)],
[AS_VAR_SET(fortran_storage_size_var, no)])
AC_LANG_POP([Fortran])
])

AS_VAR_IF(fortran_storage_size_var, [yes], [$1], [$2])
AS_VAR_POPDEF([fortran_storage_size_var])
])
Loading

0 comments on commit aad74f5

Please sign in to comment.