Commit 0970b584 authored by Junchao Zhang's avatar Junchao Zhang
Browse files

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: Kenneth Raffenetti's avatarKen Raffenetti <raffenet@mcs.anl.gov>
parent b6b638af
......@@ -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} );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment