253444c6d0
1. New mpifort wrapper compiler: you can utilize mpif.h, use mpi, and use mpi_f08 through this one wrapper compiler 1. mpif77 and mpif90 still exist, but are sym links to mpifort and may be removed in a future release 1. The mpi module has been re-implemented and is significantly "mo' bettah" 1. The mpi_f08 module offers many, many improvements over mpif.h and the mpi module This stuff is coming from a VERY long-lived mercurial branch (3 years!); it'll almost certainly take a few SVN commits and a bunch of testing before I get it correctly committed to the SVN trunk. == More details == Craig Rasmussen and I have been working with the MPI-3 Fortran WG and Fortran J3 committees for a long, long time to make a prototype MPI-3 Fortran bindings implementation. We think we're at a stable enough state to bring this stuff back to the trunk, with the goal of including it in OMPI v1.7. Special thanks go out to everyone who has been incredibly patient and helpful to us in this journey: * Rolf Rabenseifner/HLRS (mastermind/genius behind the entire MPI-3 Fortran effort) * The Fortran J3 committee * Tobias Burnus/gfortran * Tony !Goetz/Absoft * Terry !Donte/Oracle * ...and probably others whom I'm forgetting :-( There's still opportunities for optimization in the mpi_f08 implementation, but by and large, it is as far along as it can be until Fortran compilers start implementing the new F08 dimension(..) syntax. Note that gfortran is currently unsupported for the mpi_f08 module and the new mpi module. gfortran users will a) fall back to the same mpi module implementation that is in OMPI v1.5.x, and b) not get the new mpi_f08 module. The gfortran maintainers are actively working hard to add the necessary features to support both the new mpi_f08 module and the new mpi module implementations. This will take some time. As mentioned above, ompi/mpi/f77 and ompi/mpi/f90 no longer exist. All the fortran bindings implementations have been collated under ompi/mpi/fortran; each implementation has its own subdirectory: {{{ ompi/mpi/fortran/ base/ - glue code mpif-h/ - what used to be ompi/mpi/f77 use-mpi-tkr/ - what used to be ompi/mpi/f90 use-mpi-ignore-tkr/ - new mpi module implementation use-mpi-f08/ - new mpi_f08 module implementation }}} There's also a prototype 6-function-MPI implementation under use-mpi-f08-desc that emulates the new F08 dimension(..) syntax that isn't fully available in Fortran compilers yet. We did that to prove it to ourselves that it could be done once the compilers fully support it. This directory/implementation will likely eventually replace the use-mpi-f08 version. Other things that were done: * ompi_info grew a few new output fields to describe what level of Fortran support is included * Existing Fortran examples in examples/ were renamed; new mpi_f08 examples were added * The old Fortran MPI libraries were renamed: * libmpi_f77 -> libmpi_mpifh * libmpi_f90 -> libmpi_usempi * The configury for Fortran was consolidated and significantly slimmed down. Note that the F77 env variable is now IGNORED for configure; you should only use FC. Example: {{{ shell$ ./configure CC=icc CXX=icpc FC=ifort ... }}} All of this work was done in a Mercurial branch off the SVN trunk, and hosted at Bitbucket. This branch has got to be one of OMPI's longest-running branches. Its first commit was Tue Apr 07 23:01:46 2009 -0400 -- it's over 3 years old! :-) We think we've pulled in all relevant changes from the OMPI trunk (e.g., Fortran implementations of the new MPI-3 MPROBE stuff for mpif.h, use mpi, and use mpi_f08, and the recent Fujitsu Fortran patches). I anticipate some instability when we bring this stuff into the trunk, simply because it touches a LOT of code in the MPI layer in the OMPI code base. We'll try our best to make it as pain-free as possible, but please bear with us when it is committed. This commit was SVN r26283.
230 строки
7.9 KiB
C
230 строки
7.9 KiB
C
/*
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
* University Research and Technology
|
|
* Corporation. All rights reserved.
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
* of Tennessee Research Foundation. All rights
|
|
* reserved.
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
* University of Stuttgart. All rights reserved.
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
* All rights reserved.
|
|
* Copyright (c) 2006-2012 Cisco Systems, Inc. All rights reserved.
|
|
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*/
|
|
|
|
#include "ompi_config.h"
|
|
#include "ompi/communicator/communicator.h"
|
|
#include "ompi/request/grequest.h"
|
|
#include "ompi/mpi/fortran/base/fint_2_int.h"
|
|
|
|
|
|
/*
|
|
* See the comment in the grequest destructor for the weird semantics
|
|
* here. If the request has been marked complete via a call to
|
|
* MPI_GREQUEST_COMPLETE, actually release the object. OTherwise,
|
|
* just mark this object as "freed" so that a later call to
|
|
* MPI_GREQUEST_COMPLETE will release it (!).
|
|
*
|
|
* Note that TEST* and WAIT* will call this function when a request
|
|
* has been completed.
|
|
*/
|
|
static int ompi_grequest_free(ompi_request_t** req)
|
|
{
|
|
OBJ_RELEASE(*req);
|
|
*req = MPI_REQUEST_NULL;
|
|
return OMPI_SUCCESS;
|
|
}
|
|
|
|
static int ompi_grequest_cancel(ompi_request_t* req, int flag)
|
|
{
|
|
int rc = OMPI_SUCCESS;
|
|
MPI_Fint ierr;
|
|
ompi_fortran_logical_t fflag;
|
|
ompi_grequest_t* greq = (ompi_grequest_t*)req;
|
|
|
|
if (greq->greq_cancel.c_cancel != NULL) {
|
|
if (greq->greq_funcs_are_c) {
|
|
rc = greq->greq_cancel.c_cancel(greq->greq_state,
|
|
greq->greq_base.req_complete);
|
|
} else {
|
|
fflag = (ompi_fortran_logical_t) greq->greq_base.req_complete;
|
|
greq->greq_cancel.f_cancel((MPI_Aint*)greq->greq_state, &fflag, &ierr);
|
|
rc = OMPI_FINT_2_INT(ierr);
|
|
}
|
|
}
|
|
return rc;
|
|
}
|
|
|
|
static void ompi_grequest_construct(ompi_grequest_t* greq)
|
|
{
|
|
greq->greq_base.req_free = ompi_grequest_free;
|
|
greq->greq_base.req_cancel = ompi_grequest_cancel;
|
|
greq->greq_base.req_type = OMPI_REQUEST_GEN;
|
|
greq->greq_base.req_mpi_object.comm = &(ompi_mpi_comm_world.comm);
|
|
/* Set the function pointers to C here; the F77 MPI API will
|
|
override this value if the gen request was created from
|
|
Fortran */
|
|
greq->greq_funcs_are_c = true;
|
|
}
|
|
|
|
/*
|
|
* MPI has some weird semantics with respect to generalized requests
|
|
* -- different than all other MPI object types. So we move some
|
|
* cleanup stuff here to the destructor rather than in
|
|
* greqeust_request_free -- mainly because the cleanup may be required
|
|
* in two different places.
|
|
*
|
|
* Specifically, generalized requests can be completed (and therefore
|
|
* released) the following ways:
|
|
*
|
|
* 1. Call to MPI_GREQUEST_COMPLETE and then a corresponding call to
|
|
* some flavor of MPI_TEST* or MPI_WAIT*. This will both complete the
|
|
* requests and destroy the coresponding MPI generalized request
|
|
* object.
|
|
*
|
|
* 2. Call MPI_REQUEST_FREE and then (!) -- with some other
|
|
* still-valid copy of the handler -- call MPI_GREQUEST_COMPLETE.
|
|
*
|
|
* 3. Reverse the order of #2 -- call MPI_GREQUEST_COMPLETE and then
|
|
* MPI_REQUEST_FREE.
|
|
*
|
|
* So any one of these functions may actually be the one that
|
|
* de-allocates the back-end request object. Hence, this is perfect
|
|
* for our reference counting system -- so the call to the gen request
|
|
* free_fn() is back here in the destructor, whenever the object is
|
|
* actually freed.
|
|
*
|
|
* Hence, the following must occur before a grequest is freed:
|
|
*
|
|
* - ompi_grequest_complete() (i.e., GREQUEST_COMPLETE) is invoked
|
|
* - ompi_grequest_free() is invoked
|
|
*
|
|
* Remember that ompi_grequest_free() is invoked by MPI_TEST* and
|
|
* MPI_WAIT* when the request was previously marked as complete and
|
|
* TEST* / WAIT* notified the user as such, and this function is also
|
|
* invoked by REQUEST_FREE). Hence, these two functions will *always*
|
|
* be invoked, but the order in which they are invoked is up to the
|
|
* user. So this is a perfect opprotunity for the OBJ_* reference
|
|
* count system. When we create an ompi_grequest_t in
|
|
* ompi_grequest_start(), we both OBJ_NEW and OBJ_RETAIN it so that
|
|
* its reference count goes to 0. Then in ompi_grequest_complete()
|
|
* and ompi_grequest_free(), we OBJ_RELEASE it. Hence, when both of
|
|
* them have RELEASEd -- regardless of the order in which the
|
|
* functions were invoked, then the destructor is invoked and
|
|
* everything is cleaned up (and we invoked the grequest free_fn).
|
|
*/
|
|
static void ompi_grequest_destruct(ompi_grequest_t* greq)
|
|
{
|
|
MPI_Fint ierr;
|
|
|
|
if (greq->greq_free.c_free != NULL) {
|
|
if (greq->greq_funcs_are_c) {
|
|
greq->greq_free.c_free(greq->greq_state);
|
|
} else {
|
|
greq->greq_free.f_free((MPI_Aint*)greq->greq_state, &ierr);
|
|
}
|
|
}
|
|
|
|
OMPI_REQUEST_FINI(&greq->greq_base);
|
|
}
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(
|
|
ompi_grequest_t,
|
|
ompi_request_t,
|
|
ompi_grequest_construct,
|
|
ompi_grequest_destruct);
|
|
|
|
|
|
int ompi_grequest_start(
|
|
MPI_Grequest_query_function *gquery_fn,
|
|
MPI_Grequest_free_function *gfree_fn,
|
|
MPI_Grequest_cancel_function *gcancel_fn,
|
|
void* gstate,
|
|
ompi_request_t** request)
|
|
{
|
|
ompi_grequest_t *greq = OBJ_NEW(ompi_grequest_t);
|
|
if(greq == NULL) {
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
}
|
|
/* We call RETAIN here specifically to increase the refcount to 2.
|
|
See comment before the destructor for an explanation. */
|
|
OBJ_RETAIN(greq);
|
|
|
|
greq->greq_base.req_state = OMPI_REQUEST_ACTIVE;
|
|
greq->greq_state = gstate;
|
|
greq->greq_query.c_query = gquery_fn;
|
|
greq->greq_free.c_free = gfree_fn;
|
|
greq->greq_cancel.c_cancel = gcancel_fn;
|
|
greq->greq_base.req_status = ompi_status_empty;
|
|
|
|
*request = &greq->greq_base;
|
|
return OMPI_SUCCESS;
|
|
}
|
|
|
|
|
|
/*
|
|
* Beware the odd semantics listed in MPI-2:8.2... See the comment in
|
|
* the grequest destructor.
|
|
*
|
|
* First do the normal stuff to complete the request (i.e., call
|
|
* ompi_request_complete()). Then, if this request object was
|
|
* previously freed via MPI_REQUEST_FREE, release it.
|
|
*/
|
|
int ompi_grequest_complete(ompi_request_t *req)
|
|
{
|
|
int rc;
|
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
|
rc = ompi_request_complete(req, true);
|
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
|
OBJ_RELEASE(req);
|
|
return rc;
|
|
}
|
|
|
|
|
|
/*
|
|
* Grequest queries are invoked in two places:
|
|
*
|
|
* 1. MPI_TEST* / MPI_WAIT*, when requests have completed.
|
|
*
|
|
* 2. MPI_REQUEST_GET_STATUS, when requests may or may not have
|
|
* completed.
|
|
*
|
|
*/
|
|
int ompi_grequest_invoke_query(ompi_request_t *request,
|
|
ompi_status_public_t *status)
|
|
{
|
|
int rc = OMPI_SUCCESS;
|
|
ompi_grequest_t *g = (ompi_grequest_t*) request;
|
|
|
|
/* MPI-2:8.2 does not say what to do with the return value from
|
|
the query function (i.e., the int return value from the C
|
|
function or the ierr argument from the Fortran function).
|
|
Making the command decision here to ignore it. If the handler
|
|
wants to pass an error back, it should set it in the MPI_ERROR
|
|
field in the status (which is always kept, regardless if the
|
|
top-level function was invoked with MPI_STATUS[ES]_IGNORE or
|
|
not). */
|
|
if (NULL != g->greq_query.c_query) {
|
|
if (g->greq_funcs_are_c) {
|
|
rc = g->greq_query.c_query(g->greq_state, status);
|
|
} else {
|
|
MPI_Fint ierr;
|
|
MPI_Fint fstatus[sizeof(MPI_Status) / sizeof(int)];
|
|
g->greq_query.f_query((MPI_Aint*)g->greq_state, fstatus, &ierr);
|
|
MPI_Status_f2c(fstatus, status);
|
|
rc = OMPI_FINT_2_INT(ierr);
|
|
}
|
|
}
|
|
|
|
return rc;
|
|
}
|
|
|