1
1

Fixes trac:4205: ensure sizeof(MPI_Count) <= sizeof(size_t)

- Move the ptrdiff_t tests up higher in configure.ac to be with the
  rest of the type tests.
- Create new OMPI_FIND_MPI_AINT_COUNT_OFFSET for finding the
  corresponding types of MPI_Aint, MPI_Count, and MPI_Offset.
  Consolidate all the old C and Fortran tests into this new macro (and
  .m4 file).
- Fix Fortran MPI_*_KIND tests that incorrectly keyed off assumed
  types (e.g., int64_t) rather than whatever the corresponding C
  MPI_Aint, MPI_Count, MPI_Offset types turned out to be.
- Add new logic to ensure that sizeof(MPI_Count) <= sizeof(size_t),
  because our entire PML, BTL, and convertor infrastructure requires
  this.  As a side effect, just like MPI_Offset the same type of
  MPI_Count (because MPI_Count has to be able to hold an MPI_Offset,
  so we can't let MPI_Offset be larger than a MPI_Count).

This commit was SVN r30776.

The following Trac tickets were found above:
  Ticket 4205 --> https://svn.open-mpi.org/trac/ompi/ticket/4205
Этот коммит содержится в:
Jeff Squyres 2014-02-19 23:04:34 +00:00
родитель 5e9fbdde9b
Коммит bda840df49
3 изменённых файлов: 33 добавлений и 132 удалений

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

@ -245,46 +245,6 @@ AC_DEFUN([OMPI_SETUP_MPI_FORTRAN],[
OMPI_FORTRAN_GET_KIND_VALUE([C_INT32_T], 9, [OMPI_FORTRAN_C_INT32_T_KIND])
OMPI_FORTRAN_GET_KIND_VALUE([C_INT64_T], 18, [OMPI_FORTRAN_C_INT64_T_KIND])
# Get the kind value for Fortran MPI_INTEGER_KIND (corresponding
# to whatever is the same size as a F77 INTEGER -- for the
# most-likely-will-never-occur case where F77 INTEGER is smaller
# than an F90 INTEGER; see MPI-2 4.12.6.5. As with OMPI
# FORTRAN_CHECK, use the official BIND(C) KIND names (see comment
# in fortran_check.m4).
if test $OMPI_SIZEOF_FORTRAN_INTEGER -eq 2; then
OMPI_MPI_INTEGER_KIND=$OMPI_FORTRAN_C_INT16_T_KIND
elif test $OMPI_SIZEOF_FORTRAN_INTEGER -eq 4; then
OMPI_MPI_INTEGER_KIND=$OMPI_FORTRAN_C_INT32_T_KIND
elif test $OMPI_SIZEOF_FORTRAN_INTEGER -eq 8; then
OMPI_MPI_INTEGER_KIND=$OMPI_FORTRAN_C_INT64_T_KIND
elif test $OMPI_SIZEOF_FORTRAN_INTEGER -eq 16; then
AC_MSG_ERROR([Cannot support Fortran MPI_INTEGER_KIND!])
fi
AC_SUBST(OMPI_MPI_INTEGER_KIND)
# Get the kind value for Fortran MPI_ADDRESS_KIND (corresponding
# to whatever is big enough to hold (void*)).
if test $ac_cv_sizeof_void_p = 2 ; then
OMPI_MPI_ADDRESS_KIND=$OMPI_FORTRAN_C_INT16_T_KIND
elif test $ac_cv_sizeof_void_p = 4 ; then
OMPI_MPI_ADDRESS_KIND=$OMPI_FORTRAN_C_INT32_T_KIND
elif test $ac_cv_sizeof_void_p = 8 ; then
OMPI_MPI_ADDRESS_KIND=$OMPI_FORTRAN_C_INT64_T_KIND
elif test $ac_cv_sizeof_void_p = 16 ; then
AC_MSG_ERROR([Cannot support Fortran MPI_ADDRESS_KIND!])
fi
AC_SUBST(OMPI_MPI_ADDRESS_KIND)
# Get the kind value for Fortran MPI_OFFSET_KIND (corresponding to
# INTEGER*8).
OMPI_MPI_OFFSET_KIND=$OMPI_FORTRAN_C_INT64_T_KIND
AC_SUBST(OMPI_MPI_OFFSET_KIND)
# Get the kind value for Fortran MPI_COUNT_KIND (corresponding to
# INTEGER*8)
OMPI_MPI_COUNT_KIND=$OMPI_FORTRAN_C_INT64_T_KIND
AC_SUBST(OMPI_MPI_COUNT_KIND)
#--------------------------------------------------------
# This is all we need for the Fortran mpif.h MPI bindings
#--------------------------------------------------------

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

@ -793,6 +793,33 @@ AC_INCLUDES_DEFAULT
#endif
])
#
# Check for ptrdiff type. Yes, there are platforms where
# sizeof(void*) != sizeof(long) (64 bit Windows, apparently).
#
AC_MSG_CHECKING([for pointer diff type])
if test $ac_cv_type_ptrdiff_t = yes ; then
opal_ptrdiff_t="ptrdiff_t"
opal_ptrdiff_size=$ac_cv_sizeof_ptrdiff_t
elif test $ac_cv_sizeof_void_p -eq $ac_cv_sizeof_long ; then
opal_ptrdiff_t="long"
opal_ptrdiff_size=$ac_cv_sizeof_long
elif test $ac_cv_type_long_long = yes -a $ac_cv_sizeof_void_p -eq $ac_cv_sizeof_long_long ; then
opal_ptrdiff_t="long long"
opal_ptrdiff_size=$ac_cv_sizeof_long_long
else
AC_MSG_ERROR([Could not find datatype to emulate ptrdiff_t. Cannot continue])
fi
AC_DEFINE_UNQUOTED([OPAL_PTRDIFF_TYPE], [$opal_ptrdiff_t],
[type to use for ptrdiff_t])
AC_MSG_RESULT([$opal_ptrdiff_t (size: $opal_ptrdiff_size)])
#
# Find corresponding types for MPI_Aint, MPI_Count, and MPI_Offset.
# And if relevant, find the corresponding MPI_ADDRESS_KIND,
# MPI_COUNT_KIND, and MPI_OFFSET_KIND.
#
m4_ifdef([project_ompi], [OMPI_FIND_MPI_AINT_COUNT_OFFSET])
# checkpoint results
AC_CACHE_SAVE
@ -879,95 +906,6 @@ AC_CACHE_SAVE
ompi_show_title "System-specific tests"
#
# Test to determine types of MPI_Offset and MPI_Count. This is searched in the
# following order int64_t, long long, long, int. If none of these are 8 bytes,
# then we should search for int32_t, long long, long, int. MPI_Count needs to
# be at least as large as MPI_Offset and MPI_Aint.
#
MPI_OFFSET_TYPE="not found"
MPI_OFFSET_DATATYPE="not found"
AC_MSG_CHECKING([checking for type of MPI_Offset])
if test $ac_cv_type_long_long = yes -a $ac_cv_sizeof_long_long = 8; then
MPI_OFFSET_TYPE="long long"
MPI_OFFSET_DATATYPE=MPI_LONG_LONG
MPI_OFFSET_SIZE=8
MPI_COUNT_TYPE="long long"
MPI_COUNT_SIZE=8
elif test $ac_cv_type_long = yes -a $ac_cv_sizeof_long = 8; then
MPI_OFFSET_TYPE="long"
MPI_OFFSET_DATATYPE=MPI_LONG
MPI_OFFSET_SIZE=8
MPI_COUNT_TYPE="long"
MPI_COUNT_SIZE=8
elif test $ac_cv_sizeof_int = 8; then
MPI_OFFSET_TYPE="int"
MPI_OFFSET_DATATYPE=MPI_INT
MPI_OFFSET_SIZE=8
MPI_COUNT_TYPE="int"
MPI_COUNT_SIZE=8
elif test $ac_cv_type_long_long = yes -a $ac_cv_sizeof_long_long = 4; then
MPI_OFFSET_TYPE="long long"
MPI_OFFSET_DATATYPE=MPI_LONG_LONG
MPI_OFFSET_SIZE=4
MPI_COUNT_TYPE="long long"
MPI_COUNT_SIZE=4
elif test $ac_cv_type_long = yes -a $ac_cv_sizeof_long = 4; then
MPI_OFFSET_TYPE="long"
MPI_OFFSET_DATATYPE=MPI_LONG
MPI_OFFSET_SIZE=4
MPI_COUNT_TYPE="long"
MPI_COUNT_SIZE=8
elif test $ac_cv_sizeof_int = 4; then
MPI_OFFSET_TYPE="int"
MPI_OFFSET_DATATYPE=MPI_INT
MPI_OFFSET_SIZE=4
MPI_COUNT_TYPE="int"
MPI_COUNT_SIZE=8
fi
AC_MSG_RESULT([$MPI_OFFSET_TYPE])
if test "$MPI_OFFSET_TYPE" = "not found"; then
AC_MSG_WARN([*** Unable to find the right definition for MPI_Offset and MPI_Count])
AC_MSG_ERROR([Cannot continue])
fi
AC_MSG_CHECKING([checking for an MPI datatype for MPI_Offset])
AC_MSG_RESULT([$MPI_OFFSET_DATATYPE])
# this should never happens
if test "$MPI_OFFSET_DATATYPE" = "not found"; then
AC_MSG_WARN([*** Unable to find an MPI datatype corresponding to MPI_Offset])
AC_MSG_ERROR([Cannot continue])
fi
AC_DEFINE_UNQUOTED(OMPI_MPI_OFFSET_TYPE, $MPI_OFFSET_TYPE, [Type of MPI_Offset -- has to be defined here and typedef'ed later because mpi.h does not get AC SUBST's])
AC_DEFINE_UNQUOTED(OMPI_MPI_OFFSET_SIZE, $MPI_OFFSET_SIZE, [Size of the MPI_Offset])
AC_DEFINE_UNQUOTED(OMPI_OFFSET_DATATYPE, $MPI_OFFSET_DATATYPE, [MPI datatype corresponding to MPI_Offset])
if test $MPI_COUNT_SIZE -eq 8 ; then
MPI_COUNT_MAX="0x7fffffffffffffffll"
elif test $MPI_COUNT_SIZE -eq 4 ; then
MPI_COUNT_MAX="0x7fffffffl"
fi
AC_DEFINE_UNQUOTED(OMPI_MPI_COUNT_SIZE, $MPI_COUNT_SIZE, [Size of the MPI_Count datatype])
AC_DEFINE_UNQUOTED(OMPI_MPI_COUNT_TYPE, $MPI_COUNT_TYPE, [Type of the MPI_Count datatype])
AC_DEFINE_UNQUOTED(MPI_COUNT_MAX, $MPI_COUNT_MAX, [Maximum value for an MPI_Count])
#
# Check for MPI_Aint type. Yes, there are platforms where
# sizeof(void*) != sizeof(long) (64 bit Windows, apparently).
#
if test $ac_cv_type_ptrdiff_t = yes ; then
opal_ptrdiff_t="ptrdiff_t"
elif test $ac_cv_sizeof_void_p -eq $ac_cv_sizeof_long ; then
opal_ptrdiff_t="long"
elif test $ac_cv_type_long_long = yes -a $ac_cv_sizeof_void_p -eq $ac_cv_sizeof_long_long ; then
opal_ptrdiff_t="long long"
else
AC_MSG_ERROR([Could not find datatype to emulate ptrdiff_t. Cannot continue])
fi
AC_DEFINE_UNQUOTED([OPAL_PTRDIFF_TYPE], [$opal_ptrdiff_t],
[type to use for ptrdiff_t])
# Do we have _SC_NPROCESSORS_ONLN? (only going to pass if we also have
# <unistd.h> and sysconf(), which is ok) OS X 10.4 has <unistd.h> and
# sysconf(), but does not have _SC_NPROCESSORS_ONLN. Doh!

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

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007-2013 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2007-2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008-2009 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2009-2012 Oak Rigde National Laboratory. All rights reserved.
* Copyright (c) 2011 Sandia National Laboratories. All rights reserved.
@ -137,7 +137,10 @@
/* Whether we have long double _Complex or not */
#undef HAVE_LONG_DOUBLE__COMPLEX
/* Type of MPI_Offset -- has to be defined here and typedef'ed later because mpi.h does not get AC SUBST's */
/* Type of MPI_Aint */
#undef OMPI_MPI_AINT_TYPE
/* Type of MPI_Offset */
#undef OMPI_MPI_OFFSET_TYPE
/* MPI datatype corresponding to MPI_Offset */
@ -317,7 +320,7 @@ extern "C" {
* Typedefs
*/
typedef OPAL_PTRDIFF_TYPE MPI_Aint;
typedef OMPI_MPI_AINT_TYPE MPI_Aint;
typedef OMPI_MPI_OFFSET_TYPE MPI_Offset;
typedef OMPI_MPI_COUNT_TYPE MPI_Count;
typedef struct ompi_communicator_t *MPI_Comm;