[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.2b2-44-gfd32dce
Service Account
noreply at mpich.org
Fri May 22 15:59:02 CDT 2015
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".
The branch, master has been updated
via fd32dce74ddaa62ae537dc7a88e43a02a9db11a0 (commit)
via 0970b5849e2900595330ccac81956748d41753e4 (commit)
from b6b638afede62b245d307d7dfa7dab67364ee8f7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/fd32dce74ddaa62ae537dc7a88e43a02a9db11a0
commit fd32dce74ddaa62ae537dc7a88e43a02a9db11a0
Author: Junchao Zhang <jczhang at mcs.anl.gov>
Date: Fri May 22 14:36:37 2015 -0500
Add a test for MPI_BOTTOM and absolute datatypes in C/Fortran mixed code
Refs #1877
Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>
diff --git a/test/mpi/.gitignore b/test/mpi/.gitignore
index 6cfaa34..1b35005 100644
--- a/test/mpi/.gitignore
+++ b/test/mpi/.gitignore
@@ -5,6 +5,8 @@
/f90/datatype/Makefile.am
/f90/datatype/hindex1f90.f90
/f90/datatype/hindexed_blockf90.f90
+/f90/datatype/bottomf90.f90
+/f90/datatype/bottomc.c
/f90/ext/Makefile.am
/f90/ext/stamp-Makefile.am
/f90/io/Makefile.am
@@ -801,6 +803,7 @@
/f77/datatype/typenamef
/f77/datatype/typesnamef
/f77/datatype/typesubf
+/f77/datatype/bottom
/f77/ext/c2fmult
/f77/ext/ctypesinf
/f77/info/infotest2f
diff --git a/test/mpi/f77/datatype/Makefile.am b/test/mpi/f77/datatype/Makefile.am
index 26eb033..33e597e 100644
--- a/test/mpi/f77/datatype/Makefile.am
+++ b/test/mpi/f77/datatype/Makefile.am
@@ -13,7 +13,9 @@ EXTRA_DIST = testlist
AM_DEFAULT_SOURCE_EXT = .f
noinst_PROGRAMS = typenamef typesnamef typecntsf typesubf typem2f gaddressf \
- packef allctypesf hindex1f hindexed_blockf typename3f
+ packef allctypesf hindex1f hindexed_blockf typename3f bottom
+
+bottom_SOURCES=bottomc.c bottomf.f
## typeaints.h will be distributed because it's listed in AC_CONFIG_FILES/AC_OUTPUT
diff --git a/test/mpi/f77/datatype/bottomc.c b/test/mpi/f77/datatype/bottomc.c
new file mode 100644
index 0000000..d94bd24
--- /dev/null
+++ b/test/mpi/f77/datatype/bottomc.c
@@ -0,0 +1,70 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2015 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include <stdio.h>
+#include <assert.h>
+#include "mpi.h"
+#include "../../include/mpitestconf.h"
+
+/*
+ Name mapping. All routines are created with names that are lower case
+ with a single trailing underscore. This matches many compilers.
+ We use #define to change the name for Fortran compilers that do
+ not use the lowercase/underscore pattern
+*/
+
+#ifdef F77_NAME_UPPER
+#define c_routine_ C_ROUTINE
+
+#elif defined(F77_NAME_LOWER) || defined(F77_NAME_MIXED)
+/* Mixed is ok because we use lowercase in all uses */
+#define c_routine_ c_routine
+
+#elif defined(F77_NAME_LOWER_2USCORE) || defined(F77_NAME_LOWER_USCORE) || \
+ defined(F77_NAME_MIXED_USCORE)
+/* Else leave name alone (routines have no underscore, so both
+ of these map to a lowercase, single underscore) */
+#else
+#error 'Unrecognized Fortran name mapping'
+#endif
+
+void c_routine_(MPI_Fint *ftype, int *errs)
+{
+ int count = 5;
+ int lens[2] = {1,1};
+ int buf[6];
+ int i, rank;
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ MPI_Aint displs[2];
+ MPI_Datatype types[2], newtype;
+ /* create an absolute datatype for buffer that consists */
+ /* of count, followed by R(5) */
+ MPI_Get_address(&count, &displs[0]);
+ displs[1] = 0;
+ types[0] = MPI_INT;
+ types[1] = MPI_Type_f2c(*ftype);
+ MPI_Type_create_struct(2, lens, displs, types, &newtype);
+ MPI_Type_commit(&newtype);
+
+ if (rank == 0) {
+ /* the message sent contains an int count of 5, followed
+ by the 5 MPI_INTEGER entries of the Fortran array R.
+ Here we assume MPI_INTEGER has the same size as MPI_INT
+ */
+ assert(sizeof(MPI_Fint) == sizeof(int));
+ MPI_Send(MPI_BOTTOM, 1, newtype, 1, 0, MPI_COMM_WORLD);
+ } else {
+ MPI_Recv(buf, 6, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+
+ if (buf[0] != 5) *errs++;
+ for (i=1; i < 6; i++) if (buf[i] != i) *errs++;
+ }
+
+ MPI_Type_free(&newtype);
+}
diff --git a/test/mpi/f77/datatype/bottomf.f b/test/mpi/f77/datatype/bottomf.f
new file mode 100644
index 0000000..8dc4114
--- /dev/null
+++ b/test/mpi/f77/datatype/bottomf.f
@@ -0,0 +1,35 @@
+C -*- Mode: Fortran; -*-
+C
+C (C) 2015 by Argonne National Laboratory.
+C See COPYRIGHT in top-level directory.
+C
+C
+C This test tests absolute datatypes and MPI_BOTTOM in mixed
+C Fortran and C code. MPI requires MPI_Get_address return
+C the same value in all languages.
+C See discussion on p.652 of MPI-3.0
+
+ program main
+ implicit none
+ include 'mpif.h'
+ integer :: R(5)
+ integer :: type, ierr, aoblen(1), aotype(1)
+ integer (kind=mpi_address_kind) :: aodisp(1)
+ integer errs
+
+ errs = 0
+ R = (/1, 2, 3, 4, 5/)
+
+ call mtest_init(ierr)
+
+ ! create an absolute datatype for array r
+ aoblen(1) = 5
+ call MPI_Get_address(R, aodisp(1), ierr)
+ aotype(1) = MPI_INTEGER
+ call MPI_Type_create_struct(1,aoblen,aodisp,aotype, type, ierr)
+ call c_routine(type, errs)
+
+ call MPI_Type_free(type, ierr);
+ call mtest_finalize(errs)
+ call MPI_Finalize(ierr)
+ end
diff --git a/test/mpi/f77/datatype/testlist b/test/mpi/f77/datatype/testlist
index 15b67c7..72fdc57 100644
--- a/test/mpi/f77/datatype/testlist
+++ b/test/mpi/f77/datatype/testlist
@@ -9,3 +9,4 @@ gaddressf 1
allctypesf 1
hindex1f 1
hindexed_blockf 1 mpiversion=3.0
+bottom 2
http://git.mpich.org/mpich.git/commitdiff/0970b5849e2900595330ccac81956748d41753e4
commit 0970b5849e2900595330ccac81956748d41753e4
Author: Junchao Zhang <jczhang at mcs.anl.gov>
Date: Thu May 21 15:30:38 2015 -0500
Adjust MPI_BOTTOM to zero in F77/90 bindings
Change the bindings to make it as if MPI_BOTTOM in Fortran is
at address zero as it in C. See discussion on p.652 of MPI-3.0
Fixes #1877
Signed-off-by: Ken Raffenetti <raffenet at mcs.anl.gov>
diff --git a/src/binding/fortran/mpif_h/buildiface b/src/binding/fortran/mpif_h/buildiface
index ba75a71..9f60cf2 100755
--- a/src/binding/fortran/mpif_h/buildiface
+++ b/src/binding/fortran/mpif_h/buildiface
@@ -4234,11 +4234,7 @@ sub build_specials {
*ierr = MPI_Address( v1, &a );\n";
&specialInitStatement( $OUTFD );
print $OUTFD "\
-#ifdef USE_POINTER_FOR_BOTTOM
b = a;
-#else
- b = a - (MPIR_Pint) MPIR_F_MPI_BOTTOM;
-#endif
*v2 = (MPI_Fint)( b );
#ifdef HAVE_AINT_LARGER_THAN_FINT
/* Check for truncation */
@@ -4273,9 +4269,6 @@ sub build_specials {
*ierr = MPI_Get_address( v1, &a );\n";
&specialInitStatement( $OUTFD );
print $OUTFD "\
-#ifndef USE_POINTER_FOR_BOTTOM
- a = a - (MPIR_Pint) MPIR_F_MPI_BOTTOM;
-#endif
*v2 = a;
}\n";
close ($OUTFD);
@@ -4782,6 +4775,31 @@ sub print_mpif_int {
print MPIFFD " PARAMETER ($key=$value)\n";
}
+# Change the non-zero addressed F77/90 MPI_BOTTOM to C's MPI_BOTTOM, which
+# in MPICH is (void*)0. Note that MPI_BOTTOM can only appear at choice
+# buffer positions. For simplicity, we treat all void * parameters as
+# possible choice buffers. It is a little bit overkilling, but never
+# hurts, since if in the user's Fortran source code MPI_BOTTOM is passed
+# to a non-choice buffer parameter, either the program is already wrong,
+# or the parameter is non-significant.
+#
+# To make this adjustment work, MPI_Get_Address, MPI_Address should return
+# address as if MPI_BOTTOM was at address zero.
+#
+# See discussion of the MPI_BOTTOM problem on p.652 of MPI-3.0
+
+sub adjust_mpi_bottom {
+ my $OUTFD = $_[0];
+ my @params = split(/\s*,\s*/, $_[1]);
+ my $count = 1;
+ foreach my $param (@params) {
+ if ($param =~ /void.*\*/) {
+ printf $OUTFD " if (v$count == MPIR_F_MPI_BOTTOM) v$count = MPI_BOTTOM;\n";
+ }
+ $count++;
+ }
+}
+
sub ReadAndProcessInterface {
my $prototype_file = $_[0];
my $protectMPIO = $_[1]; # Wrap MPI-IO routines in ifdefs MPI_MODE_RDONLY
@@ -4930,6 +4948,7 @@ sub ReadAndProcessInterface {
&printCallForFint( $routine_prefix, $routine_name, $args );
}
&print_special_decls( $routine_name );
+ &adjust_mpi_bottom($OUTFD, $args);
if (defined($ChangeCall{$routine_name})) {
my ($newName,$extraArgs) =
split(/:/,$ChangeCall{$routine_name} );
-----------------------------------------------------------------------
Summary of changes:
src/binding/fortran/mpif_h/buildiface | 33 ++++++++++++---
test/mpi/.gitignore | 3 +
test/mpi/f77/datatype/Makefile.am | 4 +-
test/mpi/f77/datatype/bottomc.c | 70 +++++++++++++++++++++++++++++++++
test/mpi/f77/datatype/bottomf.f | 35 ++++++++++++++++
test/mpi/f77/datatype/testlist | 1 +
6 files changed, 138 insertions(+), 8 deletions(-)
create mode 100644 test/mpi/f77/datatype/bottomc.c
create mode 100644 test/mpi/f77/datatype/bottomf.f
hooks/post-receive
--
MPICH primary repository
More information about the commits
mailing list