1
1

Clean up the Fortran MPI sentinel values per problem reported on the

users mailing list:

  http://www.open-mpi.org/community/lists/users/2006/07/1680.php

Warning: this log message is not for the weak.  Read at your own
risk.

The problem was that we had several variables in Fortran common blocks
of various types, but their C counterparts were all of a type
equivalent to a fortran double complex.  This didn't seem to matter
for the compilers that we tested, but we never tested static builds
(which is where this problem seems to occur, at least with the Intel
compiler: the linker compilains that the variable in the common block
in the user's .o file was of one size/alignment but the one in the C
library was a different size/alignment).

So this patch fixes the sizes/types of the Fortran common block
variables and their corresponding C instantiations to be of the same
sizes/types. 

But wait, there's more.

We recently introduced a fix for the OSX linker where some C versions
of the fortran common block variables (e.g.,
_ompi_fortran_status_ignore) were not being found when linking
ompi_info (!).  Further research shows that the code path for
ompi_info to require ompi_fortran_status_ignore is, unfortunately,
necessary (a quirk of how various components pull in different
portions of the code base -- nothing in ompi_info itself requires
fortran or MPI knowledge, of course).

Hence, the real problem was that there was no code path from ompi_info
to the portion of the code base where the C globals corresponding to
the Fortran common block variables were instantiated.  This is because
the OSX linker does not automatically pull in .o files that only
contain unintialized global variables; the OSX linker typically only
pulls in a .o file from a library if it either has a function that is
used or have a global variable that is initialized (that's the short
version; lots of details and corner cases omitted).  Hence, we changed
the global C variables corresponding to the fortran common blocks to
be initialized, thereby causing the OSX linker to pull them in
automatically -- problem solved.  At the same time, we moved the
constants to another .c file with a function, just for good measure.

However, this didn't really solve the problem:

1. The function in the file with the C versions of the fortran common
   block variables (ompi/mpi/f77/test_constants_f.c) did not have a
   code path that was reachable from ompi_info, so the only reason
   that the constants were found (on OSX) was because they were
   initialized in the global scope (i.e., causing the OSX compiler to
   pull in that .o file).

2. Initializing these variable in the global scope causes problems for
   some linkers where -- once all the size/type problems mentioned
   above were fixed -- the alignments of fortran common blocks and C
   global variables do not match (even though the types of the Fortran
   and C variables match -- wow!).  Hence, initializing the C
   variables would not necessarily match the alignment of what Fortran
   expected, and the linker would issue a warning (i.e., the alignment
   warnings referenced in the original post).

The solution is two-fold:

1. Move the Fortran variables from test_constants_f.c to
   ompi/mpi/runtime/ompi_mpi_init.c where there are other global
   constants that *are* initialized (that had nothing to do with
   fortran, so the alignment issues described above are not a factor),
   and therefore all linkers (including the OSX linker) will pull in
   this .o file and find all the symbols that it needs.

2. Do not initialize the C variables corresponding to the Fortran
   common blocks in the global scope.  Indeed, never initialize them
   at all (because we never need their *values* - we only check for
   their *locations*).  Since nothing is ever written to these
   variables (particularly in the global scope), the linker does not
   see any alignment differences during initialization, but does make
   both the C and Fortran variables have the same addresses (this
   method has been working in LAM/MPI for over a decade).

There were some comments here in the OMPI code base and in the LAM
code base that stated/implied that C variables corresponding to
Fortran common blocks had to have the same alignment as the Fortran
common blocks (i.e., 16).  There were attempts in both code bases to
ensure that this was true.  However, the attempts were wrong (in both
code bases), and I have now read enough Fortran compiler documentation
to convince myself that matching alignments is not required (indeed,
it's beyond our control).  As long as C variables corresponding to
Fortran common blocks are not initialized in the global scope, the
linker will "figure it out" and adjust the alignment to whatever is
required (i.e., the greater of the alignments).  Specifically (to
counter comments that no longer exist in the OMPI code base but still
exist in the LAM code base):

- there is no need to make attempts to specially align C variables
  corresponding to Fortran common blocks
- the types and sizes of C variables corresponding to Fortran common
  blocks should match, but do not need to be on any particular
  alignment 

Finally, as a side effect of this effort, I found a bunch of
inconsistencies with the intent of status/array_of_statuses
parameters.  For all the functions that I modified they should be
"out" (not inout).

This commit was SVN r11057.
Этот коммит содержится в:
Jeff Squyres 2006-07-31 15:07:09 +00:00
родитель c9e0eda190
Коммит 520147f209
10 изменённых файлов: 232 добавлений и 262 удалений

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

@ -162,27 +162,44 @@
parameter (MPI_MODE_SEQUENTIAL=256)
parameter (MPI_DISPLACEMENT_CURRENT=-54278278)
!
! global variables
!
double complex MPI_BOTTOM, MPI_IN_PLACE
! MPI sentinel values
!
! Several of these types were chosen with care to match specific
! overloaded functions in the F90 bindings. They should also match
! the types of their corresponding C variables. Do not arbitrarily
! change their types without also updating the F90 bindings and
! their corresponding types in ompi/mpi/f77/constants.h and
! ompi/mpi/runtime/ompi_init.c!
!
! MPI_BOTTOM is only used where choice buffers can be used (meaning
! that we already have overloaded F90 bindings for all available
! types), so any type is fine.
integer MPI_BOTTOM
! MPI_IN_PLACE has the same rationale as MPI_BOTTOM.
integer MPI_IN_PLACE
! Making MPI_ARGV_NULL be the same type as the parameter that is
! exepected in the F90 binding for MPI_COMM_SPAWN means that we
! don't need another binding for MPI_COMM_SPAWN.
character MPI_ARGV_NULL(1)
! MPI_ARGVS_NULL must not be a character array so that we can match
! an appropriate F90 MPI bindings interface function; see comments
! in mpi-f90-interfaces.h for a full explanation. It's an analogous
! situation for MPI_STATUSES_IGNORE -- we make it of a type that no
! one should ever try to pass to (for example) MPI_WAITSOME so that
! we get the desired type matching (i.e., we wouldn't want to make
! MPI_STATUSED_IGNORE an integer array size of MPI_STATUS_SIZE
! because someone may accidentally pass in a 1D integer array of
! size MPI_STATUS_SIZE [vs. an array of integer arrays, like they're
! supposed to] -- and that's the type of mistake that these
! strong-typing bindings are supposed to catch :-) ).
integer MPI_ARGVS_NULL
double complex MPI_STATUSES_IGNORE
! These must be integer arrays so that we can match the proper
! prototypes in the F90 MPI bindings.
! The array_of_argv parameter in the F90 bindings for
! MPI_COMM_SPAWN_MULTIPLE takes a variable number of dimensions
! (specified by the "count" parameter), so it's not possible to have
! a single variable match all possible values. Hence, make it an
! entirely different type (one that would never likely be used by a
! correct program, e.g., double) and have a separate F90 binding for
! matching just this type.
double precision MPI_ARGVS_NULL
! MPI_ERRCODES_IGNORE has similar rationale to MPI_ARGV_NULL. The
! F77 functions are all smart enough to check that the errcodes
! parameter is not ERRCODES_IGNORE before assigning values into it
! (hence, the fact that this is an array of only 1 element does not
! matter -- we'll never overrun it because we never assign values
! into it).
integer MPI_ERRCODES_IGNORE(1)
! MPI_STATUS_IGNORE has similar rationale to MPI_ERRCODES_IGNORE.
integer MPI_STATUS_IGNORE(MPI_STATUS_SIZE)
! MPI_STATUSES_IGNORE has similar rationale to MPI_ARGVS_NULL.
double precision MPI_STATUSES_IGNORE
common/mpi_fortran_bottom/MPI_BOTTOM
common/mpi_fortran_in_place/MPI_IN_PLACE

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

@ -20,35 +20,32 @@
#ifndef OMPI_F77_CONSTANTS_H
#define OMPI_F77_CONSTANTS_H
/*
* Several variables are used to link against MPI F77 constants which
* correspond to addresses, e.g. MPI_BOTTOM, and are implemented via
* common blocks. They must have the same size and alignment
* constraints as the corresponding F77 common blocks.
* common blocks.
*
* We use common blocks so that in the C wrapper functions, we can
* compare the address that comes in against known addresses (e.g., if
* the "status" argument in MPI_RECV is the address of the common
* block for the fortran equivalent of MPI_STATUS_IGNORE, then we know
* to pass the C MPI_STATUS_IGNORE to the C MPI_Recv function.
* to pass the C MPI_STATUS_IGNORE to the C MPI_Recv function). As
* such, we never look at the *value* of these variables (indeed,
* they're never actually initialized), but instead only ever look at
* the *address* of these variables.
*
* This mojo makes a type that will be aligned on 16 bytes (same as
* common blocks -- at least it seems to work with all the fortran
* compilers that we care about... haven't found one yet that doesn't
* work...)
*/
#if defined(HAVE_LONG_DOUBLE) && OMPI_ALIGNMENT_LONG_DOUBLE == 16
typedef struct { long double bogus[1]; } ompi_fortran_common_t;
#define OMPI_FORTRAN_COMMON_INIT {{ 0 }}
#else
typedef struct { double bogus[2]; } ompi_fortran_common_t;
#define OMPI_FORTRAN_COMMON_INIT {{ 0, 0 }}
#endif
/*
* This part sucks. :-(
* As such, it is not strictly necessary that the size and type of our
* C variables matches that of the common Fortran block variables.
* However, good programming form says that we should match, so we do.
*
* Note, however, that the alignments of the Fortran common block and
* the C variable may not match (e.g., Intel 9.0 compilers on 64 bit
* platforms will put the alignment of a double on 4 bytes, but put
* the alignment of all common blocks on 16 bytes). This only matters
* (to some compilers!), however, if you initialize the C variable in
* the global scope. If the C global instantiation is not
* initialized, the compiler/linker seems to "figure it all out" and
* make the alignments match.
*
* Since we made the fundamental decision to support all 4 common
* fortran compiler symbol conventions within the same library for
@ -63,7 +60,7 @@ typedef struct { double bogus[2]; } ompi_fortran_common_t;
*
* We do this by having a "common" block in mpif.h:
*
* DOUBLE PRECISION MPI_STATUS_IGNORE
* INTEGER MPI_STATUS_IGNORE(MPI_STATUS_SIZE)
* common /mpi_fortran_status_ignore/ MPI_STATUS_IGNORE
*
* This makes the fortran variable MPI_STATUS_IGNORE effectively be an
@ -84,25 +81,30 @@ typedef struct { double bogus[2]; } ompi_fortran_common_t;
* file.
*/
#define DECL(upper_case, lower_case, single_u, double_u) \
OMPI_DECLSPEC extern ompi_fortran_common_t upper_case; \
OMPI_DECLSPEC extern ompi_fortran_common_t lower_case; \
OMPI_DECLSPEC extern ompi_fortran_common_t single_u; \
OMPI_DECLSPEC extern ompi_fortran_common_t double_u
#define DECL(type, upper_case, lower_case, single_u, double_u) \
OMPI_DECLSPEC extern type upper_case; \
OMPI_DECLSPEC extern type lower_case; \
OMPI_DECLSPEC extern type single_u; \
OMPI_DECLSPEC extern type double_u
DECL(MPI_FORTRAN_BOTTOM, mpi_fortran_bottom,
/* Note that the rationale for the types of each of these variables is
discussed in ompi/include/mpif-common.h. Do not change the types
without also changing ompi/mpi/runtime/ompi_mpi_init.c and
ompi/include/mpif-common.h. */
DECL(int, MPI_FORTRAN_BOTTOM, mpi_fortran_bottom,
mpi_fortran_bottom_, mpi_fortran_bottom__);
DECL(MPI_FORTRAN_IN_PLACE, mpi_fortran_in_place,
DECL(int, MPI_FORTRAN_IN_PLACE, mpi_fortran_in_place,
mpi_fortran_in_place_, mpi_fortran_in_place__);
DECL(MPI_FORTRAN_ARGV_NULL, mpi_fortran_argv_null,
DECL(char *, MPI_FORTRAN_ARGV_NULL, mpi_fortran_argv_null,
mpi_fortran_argv_null_, mpi_fortran_argv_null__);
DECL(MPI_FORTRAN_ARGVS_NULL, mpi_fortran_argvs_null,
DECL(double, MPI_FORTRAN_ARGVS_NULL, mpi_fortran_argvs_null,
mpi_fortran_argvs_null_, mpi_fortran_argvs_null__);
DECL(MPI_FORTRAN_ERRCODES_IGNORE, mpi_fortran_errcodes_ignore,
DECL(int *, MPI_FORTRAN_ERRCODES_IGNORE, mpi_fortran_errcodes_ignore,
mpi_fortran_errcodes_ignore_, mpi_fortran_errcodes_ignore__);
DECL(MPI_FORTRAN_STATUS_IGNORE, mpi_fortran_status_ignore,
DECL(int *, MPI_FORTRAN_STATUS_IGNORE, mpi_fortran_status_ignore,
mpi_fortran_status_ignore_, mpi_fortran_status_ignore__);
DECL(MPI_FORTRAN_STATUSES_IGNORE, mpi_fortran_statuses_ignore,
DECL(double, MPI_FORTRAN_STATUSES_IGNORE, mpi_fortran_statuses_ignore,
mpi_fortran_statuses_ignore_, mpi_fortran_statuses_ignore__);
/*

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

@ -22,48 +22,6 @@
#include "ompi/mpi/f77/bindings.h"
#include "ompi/mpi/f77/constants.h"
/**
* This file contains two parts:
*
* 1. Various constants used in the Fortran bindings.
* 2. A special, internal OMPI function used for testing constant
* values (i.e., not an MPI API function)
*
* The constants in #1 are in this file because certain linkers (e.g.,
* OSX) need to have object files with functions in them or they won't
* pull in global variables from that file. Specifically, the
* constants in #1 used to be in a .c file by themselves (with no
* functions), which led to certain cases where the OSX linker
* wouldn't "see" them because there were no functions in the
* resulting .o file that would cause the constants to be pulled for
* run-time/link-time resolution.
*/
/* Constants for the Fortran layer. These values are referred to via
common blocks in the Fortran equivalents. See
ompi/mpi/f77/constants.h for a more detailed explanation. */
#define INST(upper_case, lower_case, single_u, double_u) \
ompi_fortran_common_t lower_case = OMPI_FORTRAN_COMMON_INIT; \
ompi_fortran_common_t upper_case = OMPI_FORTRAN_COMMON_INIT; \
ompi_fortran_common_t single_u = OMPI_FORTRAN_COMMON_INIT; \
ompi_fortran_common_t double_u = OMPI_FORTRAN_COMMON_INIT
INST(MPI_FORTRAN_BOTTOM, mpi_fortran_bottom,
mpi_fortran_bottom_, mpi_fortran_bottom__);
INST(MPI_FORTRAN_IN_PLACE, mpi_fortran_in_place,
mpi_fortran_in_place_, mpi_fortran_in_place__);
INST(MPI_FORTRAN_ARGV_NULL, mpi_fortran_argv_null,
mpi_fortran_argv_null_, mpi_fortran_argv_null__);
INST(MPI_FORTRAN_ARGVS_NULL, mpi_fortran_argvs_null,
mpi_fortran_argvs_null_, mpi_fortran_argvs_null__);
INST(MPI_FORTRAN_ERRCODES_IGNORE, mpi_fortran_errcodes_ignore,
mpi_fortran_errcodes_ignore_, mpi_fortran_errcodes_ignore__);
INST(MPI_FORTRAN_STATUS_IGNORE, mpi_fortran_status_ignore,
mpi_fortran_status_ignore_, mpi_fortran_status_ignore__);
INST (MPI_FORTRAN_STATUSES_IGNORE, mpi_fortran_statuses_ignore,
mpi_fortran_statuses_ignore_, mpi_fortran_statuses_ignore__);
/* This is an internal test function for Open MPI; it does not have a
profiled equivalent. */

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

@ -5598,7 +5598,7 @@ subroutine ${procedure}(source, tag, comm, flag, status&
integer, intent(in) :: tag
integer, intent(in) :: comm
logical, intent(out) :: flag
integer, dimension(MPI_STATUS_SIZE), intent(inout) :: status
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierr
end subroutine ${procedure}
@ -6161,7 +6161,7 @@ subroutine ${procedure}(source, tag, comm, status, ierr)
integer, intent(in) :: source
integer, intent(in) :: tag
integer, intent(in) :: comm
integer, dimension(MPI_STATUS_SIZE), intent(inout) :: status
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierr
end subroutine ${procedure}
@ -6276,7 +6276,7 @@ subroutine ${proc}(buf, count, datatype, source, tag, &
integer, intent(in) :: source
integer, intent(in) :: tag
integer, intent(in) :: comm
integer, dimension(MPI_STATUS_SIZE), intent(inout) :: status
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierr
end subroutine ${proc}
@ -6549,7 +6549,7 @@ subroutine ${procedure}(request, flag, status, ierr)
include 'mpif-config.h'
integer, intent(in) :: request
logical, intent(out) :: flag
integer, dimension(MPI_STATUS_SIZE), intent(inout) :: status
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierr
end subroutine ${procedure}
@ -6993,7 +6993,7 @@ subroutine ${proc}(sendbuf, sendcount, sendtype, dest, sendtag, &
integer, intent(in) :: source
integer, intent(in) :: recvtag
integer, intent(in) :: comm
integer, dimension(MPI_STATUS_SIZE), intent(inout) :: status
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierr
end subroutine ${proc}
@ -7054,7 +7054,7 @@ subroutine ${proc}(buf, count, datatype, dest, sendtag, &
integer, intent(in) :: source
integer, intent(in) :: recvtag
integer, intent(in) :: comm
integer, dimension(MPI_STATUS_SIZE), intent(inout) :: status
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierr
end subroutine ${proc}
@ -7366,7 +7366,7 @@ subroutine ${procedure}(request, flag, status, ierr)
include 'mpif-config.h'
integer, intent(inout) :: request
logical, intent(out) :: flag
integer, dimension(MPI_STATUS_SIZE), intent(inout) :: status
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierr
end subroutine ${procedure}
@ -7408,31 +7408,25 @@ output_206() {
return 0
fi
procedure=$1
suffix=$1
status_type=$2
cat <<EOF
subroutine ${procedure}_normal(count, array_of_requests, flag, array_of_statuses, ierr)
subroutine MPI_Testall${suffix}(count, array_of_requests, flag, array_of_statuses, ierr)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
logical, intent(out) :: flag
integer, dimension(count, MPI_STATUS_SIZE), intent(inout) :: array_of_statuses
$status_type, intent(out) :: array_of_statuses
integer, intent(out) :: ierr
end subroutine ${procedure}_normal
subroutine ${procedure}_ignore(count, array_of_requests, flag, array_of_statuses, ierr)
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
logical, intent(out) :: flag
double complex, intent(in) :: array_of_statuses
integer, intent(out) :: ierr
end subroutine ${procedure}_ignore
end subroutine MPI_Testall${suffix}
EOF
}
start MPI_Testall small
output_206 MPI_Testall
output_206 S "integer, dimension(count, MPI_STATUS_SIZE)"
output_206 I "double precision"
end MPI_Testall
#------------------------------------------------------------------------
@ -7452,7 +7446,7 @@ subroutine ${procedure}(count, array_of_requests, index, flag, status&
integer, dimension(count), intent(inout) :: array_of_requests
integer, intent(out) :: index
logical, intent(out) :: flag
integer, dimension(MPI_STATUS_SIZE), intent(inout) :: status
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierr
end subroutine ${procedure}
@ -7470,35 +7464,27 @@ output_208() {
return 0
fi
procedure=$1
suffix=$1
status_type=$2
cat <<EOF
subroutine ${procedure}_normal(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
subroutine MPI_Testsome${suffix}(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
, ierr)
include 'mpif-config.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
integer, dimension(incount, MPI_STATUS_SIZE), intent(inout) :: array_of_statuses
$status_type, intent(out) :: array_of_statuses
integer, intent(out) :: ierr
end subroutine ${procedure}_normal
subroutine ${procedure}_ignore(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
, ierr)
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
double complex, intent(in) :: array_of_statuses
integer, intent(out) :: ierr
end subroutine ${procedure}_ignore
end subroutine MPI_Testsome${suffix}
EOF
}
start MPI_Testsome small
output_208 MPI_Testsome
output_208 S "integer, dimension(incount, MPI_STATUS_SIZE)"
output_208 I "double precision"
end MPI_Testsome
#------------------------------------------------------------------------
@ -8540,7 +8526,7 @@ output_247() {
subroutine ${procedure}(request, status, ierr)
include 'mpif-config.h'
integer, intent(inout) :: request
integer, dimension(MPI_STATUS_SIZE), intent(inout) :: status
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierr
end subroutine ${procedure}
@ -8558,29 +8544,24 @@ output_248() {
return 0
fi
procedure=$1
suffix=$1
status_type=$2
cat <<EOF
subroutine ${procedure}_normal(count, array_of_requests, array_of_statuses, ierr)
subroutine MPI_Waitall${suffix}(count, array_of_requests, array_of_statuses, ierr)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, dimension(count, MPI_STATUS_SIZE), intent(inout) :: array_of_statuses
$status_type, intent(out) :: array_of_statuses
integer, intent(out) :: ierr
end subroutine ${procedure}_normal
subroutine ${procedure}_ignore(count, array_of_requests, array_of_statuses, ierr)
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
double complex, intent(in) :: array_of_statuses
integer, intent(out) :: ierr
end subroutine ${procedure}_ignore
end subroutine MPI_Waitall${suffix}
EOF
}
start MPI_Waitall small
output_248 MPI_Waitall
output_248 S "integer, dimension(count, MPI_STATUS_SIZE)"
output_248 I "double precision"
end MPI_Waitall
#------------------------------------------------------------------------
@ -8598,7 +8579,7 @@ subroutine ${procedure}(count, array_of_requests, index, status, ierr)
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, intent(out) :: index
integer, dimension(MPI_STATUS_SIZE), intent(inout) :: status
integer, dimension(MPI_STATUS_SIZE), intent(out) :: status
integer, intent(out) :: ierr
end subroutine ${procedure}
@ -8616,35 +8597,27 @@ output_250() {
return 0
fi
procedure=$1
suffix=$1
status_type=$2
cat <<EOF
subroutine ${procedure}_normal(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
subroutine MPI_Waitsome${suffix}(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
, ierr)
include 'mpif-config.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
integer, dimension(incount, MPI_STATUS_SIZE), intent(inout) :: array_of_statuses
$status_type, intent(out) :: array_of_statuses
integer, intent(out) :: ierr
end subroutine ${procedure}_normal
subroutine ${procedure}_ignore(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
, ierr)
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
double complex, intent(in) :: array_of_statuses
integer, intent(out) :: ierr
end subroutine ${procedure}_ignore
end subroutine MPI_Waitsome${suffix}
EOF
}
start MPI_Waitsome small
output_250 MPI_Waitsome
output_250 S "integer, dimension(incount, MPI_STATUS_SIZE)"
output_250 I "double precision"
end MPI_Waitsome
#------------------------------------------------------------------------
@ -9472,13 +9445,14 @@ output_284() {
fi
procedure=$1
argv_type=$2
cat <<EOF
subroutine ${procedure}(count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, &
root, comm, intercomm, array_of_errcodes, ierr)
integer, intent(in) :: count
character(len=*), dimension(*), intent(in) :: array_of_commands
character(len=*), dimension(count,*), intent(in) :: array_of_argv
$argv_type, intent(in) :: array_of_argv
integer, dimension(*), intent(in) :: array_of_maxprocs
integer, dimension(*), intent(in) :: array_of_info
integer, intent(in) :: root
@ -9492,36 +9466,6 @@ EOF
}
start MPI_Comm_spawn_multiple small
output_284 MPI_Comm_spawn_multipleN
end MPI_Comm_spawn_multiple
#------------------------------------------------------------------------
output_285() {
if test "$output" = "0"; then
return 0
fi
procedure=$1
cat <<EOF
subroutine ${procedure}(count, array_of_commands, array_of_argv, array_of_maxprocs, array_of_info, &
root, comm, intercomm, array_of_errcodes, ierr)
integer, intent(in) :: count
character(len=*), dimension(*), intent(in) :: array_of_commands
integer, intent(in) :: array_of_argv
integer, dimension(*), intent(in) :: array_of_maxprocs
integer, dimension(*), intent(in) :: array_of_info
integer, intent(in) :: root
integer, intent(in) :: comm
integer, intent(out) :: intercomm
integer, dimension(*), intent(out) :: array_of_errcodes
integer, intent(out) :: ierr
end subroutine ${procedure}
EOF
}
start MPI_Comm_spawn_multiple small
output_285 MPI_Comm_spawn_multipleAN
output_284 MPI_Comm_spawn_multipleA "character(len=*), dimension(count,*)"
output_284 MPI_Comm_spawn_multipleN "double precision"
end MPI_Comm_spawn_multiple

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

@ -38,7 +38,7 @@ fi
output() {
procedure=$1
proc="$1$2"
type=$3
argv_type=$3
cat <<EOF
subroutine ${proc}(count, array_of_commands, array_of_argv, &
@ -47,7 +47,7 @@ subroutine ${proc}(count, array_of_commands, array_of_argv, &
include 'mpif-config.h'
integer, intent(in) :: count
character(len=*), dimension(*), intent(in) :: array_of_commands
$type, intent(in) :: array_of_argv
$argv_type, intent(in) :: array_of_argv
integer, dimension(*), intent(in) :: array_of_maxprocs
integer, dimension(*), intent(in) :: array_of_info
integer, intent(in) :: root
@ -64,5 +64,7 @@ end subroutine ${proc}
EOF
}
output MPI_Comm_spawn_multiple N "character(len=*), dimension(count,*)"
output MPI_Comm_spawn_multiple AN integer
# A = real argv, N = ARGV_NULL
output MPI_Comm_spawn_multiple A "character(len=*), dimension(count,*)"
output MPI_Comm_spawn_multiple N "double precision"

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

@ -30,28 +30,27 @@ fi
# Ok, we should continue.
cat <<EOF
output() {
suffix=$1
status_type=$2
subroutine MPI_Testall_normal(count, array_of_requests, flag, array_of_statuses, ierr)
cat <<EOF
subroutine MPI_Testall${suffix}(count, array_of_requests, flag, array_of_statuses, ierr)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
logical, intent(out) :: flag
integer, dimension(count, MPI_STATUS_SIZE), intent(inout) :: array_of_statuses
$status_type, intent(out) :: array_of_statuses
integer, intent(out) :: ierr
call MPI_TESTALL(count, array_of_requests, flag, array_of_statuses, ierr)
end subroutine MPI_Testall_normal
subroutine MPI_Testall_ignore(count, array_of_requests, flag, array_of_statuses, ierr)
! Note that we need mpif-common.h (not mpif-config.h) because we need
! the global common variable MPI_STATUSES_IGNORE
include 'mpif-common.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
logical, intent(out) :: flag
double complex, intent(in) :: array_of_statuses
integer, intent(out) :: ierr
call MPI_TESTALL(count, array_of_requests, flag, MPI_STATUSES_IGNORE, ierr)
end subroutine MPI_Testall_ignore
call MPI_Testall(count, array_of_requests, flag, array_of_statuses, ierr)
end subroutine MPI_Testall${suffix}
EOF
}
# S = array of statuses, I = STATUSES_IGNORE
output S "integer, dimension(count, MPI_STATUS_SIZE)"
output I "double precision"

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

@ -30,32 +30,29 @@ fi
# Ok, we should continue.
cat <<EOF
output() {
suffix=$1
status_type=$2
subroutine MPI_Testsome_normal(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
cat <<EOF
subroutine MPI_Testsome${suffix}(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
, ierr)
include 'mpif-config.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
integer, dimension(incount, MPI_STATUS_SIZE), intent(inout) :: array_of_statuses
$status_type, intent(out) :: array_of_statuses
integer, intent(out) :: ierr
call MPI_Testsome(incount, array_of_requests, outcount, array_of_indices, array_of_statuses, ierr)
end subroutine MPI_Testsome_normal
subroutine MPI_Testsome_ignore(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
, ierr)
! Note that we need mpif-common.h (not mpif-config.h) because we need
! the global common variable MPI_STATUSES_IGNORE
include 'mpif-common.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
double complex, intent(in) :: array_of_statuses
integer, intent(out) :: ierr
call MPI_Testsome(incount, array_of_requests, outcount, array_of_indices, MPI_STATUSES_IGNORE, ierr)
end subroutine MPI_Testsome_ignore
call MPI_Testsome(incount, array_of_requests, outcount, array_of_indices, array_of_statuses, ierr)
end subroutine MPI_Testsome${suffix}
EOF
}
# S = array of statuses, I = STATUSES_IGNORE
output S "integer, dimension(incount, MPI_STATUS_SIZE)"
output I "double precision"

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

@ -30,26 +30,25 @@ fi
# Ok, we should continue.
cat <<EOF
output() {
suffix=$1
status_type=$2
subroutine MPI_Waitall_normal(count, array_of_requests, array_of_statuses, ierr)
cat <<EOF
subroutine MPI_Waitall${suffix}(count, array_of_requests, array_of_statuses, ierr)
include 'mpif-config.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
integer, dimension(count, MPI_STATUS_SIZE), intent(inout) :: array_of_statuses
$status_type, intent(out) :: array_of_statuses
integer, intent(out) :: ierr
call MPI_Waitall(count, array_of_requests, array_of_statuses, ierr)
end subroutine MPI_Waitall_normal
subroutine MPI_Waitall_ignore(count, array_of_requests, array_of_statuses, ierr)
! Note that we need mpif-common.h (not mpif-config.h) because we need
! the global common variable MPI_STATUSES_IGNORE
include 'mpif-common.h'
integer, intent(in) :: count
integer, dimension(count), intent(inout) :: array_of_requests
double complex, intent(in) :: array_of_statuses
integer, intent(out) :: ierr
call MPI_Waitall(count, array_of_requests, MPI_STATUSES_IGNORE, ierr)
end subroutine MPI_Waitall_ignore
end subroutine MPI_Waitall${suffix}
EOF
}
# S = array of statuses, I = STATUSES_IGNORE
output S "integer, dimension(count, MPI_STATUS_SIZE)"
output I "double precision"

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

@ -30,32 +30,29 @@ fi
# Ok, we should continue.
cat <<EOF
output() {
suffix=$1
status_type=$2
subroutine MPI_Waitsome_normal(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
cat <<EOF
subroutine MPI_Waitsome${suffix}(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
, ierr)
include 'mpif-config.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
integer, dimension(incount, MPI_STATUS_SIZE), intent(inout) :: array_of_statuses
$status_type, intent(out) :: array_of_statuses
integer, intent(out) :: ierr
call MPI_Waitsome(incount, array_of_requests, outcount, array_of_indices, array_of_statuses, ierr)
end subroutine MPI_Waitsome_normal
subroutine MPI_Waitsome_ignore(incount, array_of_requests, outcount, array_of_indices, array_of_statuses&
, ierr)
! Note that we need mpif-common.h (not mpif-config.h) because we need
! the global common variable MPI_STATUSES_IGNORE
include 'mpif-common.h'
integer, intent(in) :: incount
integer, dimension(incount), intent(inout) :: array_of_requests
integer, intent(out) :: outcount
integer, dimension(*), intent(out) :: array_of_indices
double complex, intent(in) :: array_of_statuses
integer, intent(out) :: ierr
call MPI_Waitsome(incount, array_of_requests, outcount, array_of_indices, MPI_STATUSES_IGNORE, ierr)
end subroutine MPI_Waitsome_ignore
call MPI_Waitsome(incount, array_of_requests, outcount, array_of_indices, array_of_statuses, ierr)
end subroutine MPI_Waitsome${suffix}
EOF
}
# S = array of statuses, I = STATUSES_IGNORE
output S "integer, dimension(incount, MPI_STATUS_SIZE)"
output I "double precision"

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

@ -100,6 +100,14 @@ bool ompi_mpi_maffinity_setup = false;
* rather than make a new .c file with the constants and a
* corresponding dummy function that is invoked from this function).
*
* Additionally, there can be/are strange linking paths such that
* ompi_info needs symbols symbols such as ompi_fortran_status_ignore,
* which, if they weren't here with a collection of other global
* symbols that are initialized (which seems to force this .o file to
* be pulled into the resolution process, because ompi_info certainly
* does not call ompi_mpi_init()), would not be able to be found by
* the OSX linker.
*
* NOTE: See the big comment in ompi/mpi/f77/constants.h about why we
* have four symbols for each of the common blocks (e.g., the Fortran
* equivalent(s) of MPI_STATUS_IGNORE). Here, we can only have *one*
@ -140,6 +148,53 @@ MPI_Fint *MPI_F_STATUSES_IGNORE = NULL;
#endif /* OMPI_WANT_F77_BINDINGS */
/* Constants for the Fortran layer. These values are referred to via
common blocks in the Fortran equivalents. See
ompi/mpi/f77/constants.h for a more detailed explanation.
The values are *NOT* initialized. We do not use the values of
these constants; only their addresses (because they're always
passed by reference by Fortran).
Initializing upon instantiation these can reveal size and/or
alignment differences between Fortran and C (!) which can cause
warnings or errors upon linking (e.g., making static libraries with
the intel 9.0 compilers on 64 bit platforms shows alignment
differences between libmpi.a and the user's application, resulting
in a linker warning). FWIW, if you initialize these variables in
functions (i.e., not at the instantiation in the global scope), the
linker somehow "figures it all out" (w.r.t. different alignments
between fortan common blocks and the corresponding C variables) and
no linker warnings occur.
Note that the rationale for the types of each of these variables is
discussed in ompi/include/mpif-common.h. Do not change the types
without also modifying ompi/mpi/f77/constants.h and
ompi/include/mpif-common.h.
*/
#define INST(type, upper_case, lower_case, single_u, double_u) \
type lower_case; \
type upper_case; \
type single_u; \
type double_u
INST(int, MPI_FORTRAN_BOTTOM, mpi_fortran_bottom,
mpi_fortran_bottom_, mpi_fortran_bottom__);
INST(int, MPI_FORTRAN_IN_PLACE, mpi_fortran_in_place,
mpi_fortran_in_place_, mpi_fortran_in_place__);
INST(char *, MPI_FORTRAN_ARGV_NULL, mpi_fortran_argv_null,
mpi_fortran_argv_null_, mpi_fortran_argv_null__);
INST(double, MPI_FORTRAN_ARGVS_NULL, mpi_fortran_argvs_null,
mpi_fortran_argvs_null_, mpi_fortran_argvs_null__);
INST(int *, MPI_FORTRAN_ERRCODES_IGNORE, mpi_fortran_errcodes_ignore,
mpi_fortran_errcodes_ignore_, mpi_fortran_errcodes_ignore__);
INST(int *, MPI_FORTRAN_STATUS_IGNORE, mpi_fortran_status_ignore,
mpi_fortran_status_ignore_, mpi_fortran_status_ignore__);
INST (double, MPI_FORTRAN_STATUSES_IGNORE, mpi_fortran_statuses_ignore,
mpi_fortran_statuses_ignore_, mpi_fortran_statuses_ignore__);
int ompi_mpi_init(int argc, char **argv, int requested, int *provided)
{
int ret;