Open MPI logo

MPI_Grequest_start(3) man page (version 5.0.0rc2)

  |   Home   |   Support   |   FAQ   |  

« Return to documentation listing

Table of Contents

Name

C]MPI_Grequest_startR] - Starts a generalized request and returns a handle to it in C]requestR].

Syntax

C Syntax



C]#include <mpi.h>int MPI_Grequest_start(MPI_Grequest_query_function *query_fn, MPI_Grequest_free_function *free_fn, MPI_Grequest_cancel_function *cancel_fn, void *extra_state, MPI_Request *request)R]Fortran Syntax (See Fortran 77 Notes)



C]USE MPI! or the older form: INCLUDE [aq]mpif.h[aq]MPI_GREQUEST_START(QUERY_FN, FREE_FN, CANCEL_FN, EXTRA_STATE, REQUEST, IERROR) INTEGER REQUEST, IERROR EXTERNAL QUERY_FN, FREE_FN, CANCEL_FN INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATER]Fortran 2008 Syntax



C]USE mpi_f08MPI_Grequest_start(query_fn, free_fn, cancel_fn, extra_state, request, ierror) PROCEDURE(MPI_Grequest_query_function) :: query_fn PROCEDURE(MPI_Grequest_free_function) :: free_fn PROCEDURE(MPI_Grequest_cancel_function) :: cancel_fn INTEGER(KIND=MPI_ADDRESS_KIND), INTENT(IN) :: extra_state TYPE(MPI_Request), INTENT(OUT) :: request INTEGER, OPTIONAL, INTENT(OUT) :: ierrorR]Input Parameters

[bu]
C]query_fnR] : Callback function invoked when request status is queried (function).
[bu]
C]free_fnR] : Callback function invoked when request is freed (function).
[bu]
C]cancel_fnR] : Callback function invoked when request is canceled (function).
[bu]
C]extra_stateR] : Extra state.

Output Parameters

[bu]
C]requestR] : Generalized request (handle).
[bu]
C]IERRORR] : Fortran only: Error status (integer).

Description

C]MPI_Grequest_startR] starts a generalized C]requestR] and returns a handle to it in C]requestR].

The syntax and meaning of the callback functions are listed below. All callback functions are passed the C]extra_stateR] argument that was associated with the C]requestR] by the starting call C]MPI_Grequest_startR]. This can be used to maintain user-defined state for the C]requestR]. In C, the query function is


C]typedef int MPI_Grequest_query_function(void *extra_state, MPI_Status *status);R]In Fortran, it is


C]SUBROUTINE GREQUEST_QUERY_FUNCTION(EXTRA_STATE, STATUS, IERROR) INTEGER STATUS(MPI_STATUS_SIZE), IERROR INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATER]The C]query_fnR] function computes the status that should be
returned for the generalized request. The status also includes information about successful/unsuccessful cancellation of the request (result to be returned by C]MPI_Test_cancelledR]).

The C]query_fnR] function is invoked by the C]MPI_{Wait|Test}{any|some|all}R] call that completed the generalized request associated with this callback. The callback function is also invoked by calls to C]MPI_Request_get_statusR] if the request is complete when the call occurs. In both cases, the callback is passed a reference to the corresponding status variable passed by the user to the MPI call. If the user provided C]MPI_STATUS_IGNORER] or C]MPI_STATUSES_IGNORER] to the MPI function that causes C]query_fnR] to be called, then MPI will pass a valid status object to C]query_fnR], and this status will be ignored upon return of the callback function. Note that C]query_fnR] is invoked only after C]MPI_Grequest_completeR] is called on the request; it may be invoked several times for the same generalized request. Note also that a call to C]MPI_{Wait|Test}{some|all}R] may cause multiple invocations of C]query_fnR] callback functions, one for each generalized request that is completed by the MPI call. The order of these invocations is not specified by MPI.

In C, the free function is


C]typedef int MPI_Grequest_free_function(void *extra_state);R]And in Fortran, it is


C]SUBROUTINE GREQUEST_FREE_FUNCTION(EXTRA_STATE, IERROR) INTEGER IERROR INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATER]The C]free_fnR] callback function is invoked to clean up
user-allocated resources when the generalized request is freed.

The C]free_fnR] function is invoked by the C]MPI_{Wait|Test}{any|some|all}R] call that completed the generalized request associated with this callback. C]free_fnR] is invoked after the call to C]query_fnR] for the same request. However, if the MPI call completed multiple generalized requests, the order in which C]free_fnR] callback functions are invoked is not specified by MPI.

The C]free_fnR] callback is also invoked for generalized requests that are freed by a call to C]MPI_Request_freeR] (no call to C]MPI_{Wait|Test}{any|some|all}R] will occur for such a request). In this case, the callback function will be called either in the MPI call C]MPI_Request_free(request)R] or in the MPI call C]MPI_Grequest_complete(request)R], whichever happens last. In other words, in this case the actual freeing code is executed as soon as both calls (C]MPI_Request_freeR] and C]MPI_Grequest_completeR]) have occurred. The C]requestR] is not deallocated until after C]free_fnR] completes. Note that C]free_fnR] will be invoked only once per request by a correct program.

In C, the cancel function is


C]typedef int MPI_Grequest_cancel_function(void *extra_state, int complete);R]In Fortran, the cancel function is


C]SUBROUTINE GREQUEST_CANCEL_FUNCTION(EXTRA_STATE, COMPLETE, IERROR) INTEGER IERROR INTEGER(KIND=MPI_ADDRESS_KIND) EXTRA_STATE LOGICAL COMPLETER]The C]cancel_fnR] function is invoked to start the cancellation of
a generalized request. It is called by C]MPI_Request_cancel(request)R]. MPI passes to the callback function complete=true if C]MPI_Grequest_completeR] has already been called on the request, and complete=false otherwise.

Fortran 77 Notes

The MPI standard prescribes portable Fortran syntax for the C]EXTRA_STATER] argument only for Fortran 90. FORTRAN 77 users may use the non-portable syntax


C]INTEGER*MPI_ADDRESS_KIND EXTRA_STATER]where C]MPI_ADDRESS_KINDR] is a constant defined in mpif.h and
gives the length of the declared integer in bytes.

Errors

Almost all MPI routines return an error value; C routines as the value of the function and Fortran routines in the last argument.

Before the error value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job, except for I/O function errors. The error handler may be changed with C]MPI_Comm_set_errhandlerR]; the predefined error handler C]MPI_ERRORS_RETURNR] may be used to cause error values to be returned. Note that MPI does not guarantee that an MPI program can continue past an error.

All callback functions return an error code. The code is passed back and dealt with as appropriate for the error code by the MPI function that invoked the callback function. For example, if error codes are returned, then the error code returned by the callback function will be returned by the MPI function that invoked the callback function. In the case of a C]MPI_{Wait|Test}anyR] call that invokes both C]query_fnR] and C]free_fnR], the MPI call will return the error code returned by the last callback, namely C]free_fnR]. If one or more of the C]requestR]s in a call to C]MPI_{Wait|Test}{some|allR]} has failed, then the MPI call will return C]MPI_ERR_IN_STATUSR]. In such a case, if the MPI call was passed an array of statuses, then MPI will return in each of the statuses that correspond to a completed generalized C]requestR] the error code returned by the corresponding invocation of its C]free_fnR] callback function. However, if the MPI function was passed C]MPI_STATUSES_IGNORER], then the individual error codes returned by each callback function will be lost.

See the MPI man page for a full list of MPI error codes.


Table of Contents

« Return to documentation listing