Commit 31c61999 authored by David Goodell's avatar David Goodell
Browse files

[svn-r6906] add MPIR_Progress_wait_request

A small helper function to handle the common-ish case of running the
progress engine until a particular request is complete.

No reviewer.
parent d8197ef0
......@@ -2008,8 +2008,11 @@ int MPIR_Group_create( int, MPID_Group ** );
int MPIR_Group_release(MPID_Group *group_ptr);
int MPIR_dup_fn ( MPI_Comm, int, void *, void *, void *, int * );
/* marks a request as complete, extracting the status */
int MPIR_Request_complete(MPI_Request *, MPID_Request *, MPI_Status *, int *);
int MPIR_Request_get_error(MPID_Request *);
/* run the progress engine until the given request is complete */
int MPIR_Progress_wait_request(MPID_Request *req);
/* The following routines perform the callouts to the user routines registered
as part of a generalized request. They handle any language binding issues
......
......@@ -7,6 +7,44 @@
#include "mpiimpl.h"
#undef FUNCNAME
#define FUNCNAME MPIR_Progress_wait_request
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/*@
MPIR_Progress_wait_request
A helper routine that implements the very common case of running the progress
engine until the given request is complete.
@*/
int MPIR_Progress_wait_request(MPID_Request *req)
{
int mpi_errno = MPI_SUCCESS;
if ((*(req)->cc_ptr) != 0)
{
MPID_Progress_state progress_state;
MPID_Progress_start(&progress_state);
while ((*(req)->cc_ptr) != 0)
{
mpi_errno = MPID_Progress_wait(&progress_state);
if (mpi_errno != MPI_SUCCESS)
{
/* --BEGIN ERROR HANDLING-- */
MPID_Progress_end(&progress_state);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* --END ERROR HANDLING-- */
}
}
MPID_Progress_end(&progress_state);
}
fn_fail: /* no special err handling at this level */
fn_exit:
return mpi_errno;
}
#undef FUNCNAME
#define FUNCNAME MPIR_Request_complete
#undef FCNAME
......
......@@ -128,24 +128,8 @@ int MPI_Ssend(void *buf, int count, MPI_Datatype datatype, int dest, int tag,
/* If a request was returned, then we need to block until the request
is complete */
if ((*(request_ptr)->cc_ptr) != 0)
{
MPID_Progress_state progress_state;
MPID_Progress_start(&progress_state);
while((*(request_ptr)->cc_ptr) != 0)
{
mpi_errno = MPID_Progress_wait(&progress_state);
if (mpi_errno != MPI_SUCCESS)
{
/* --BEGIN ERROR HANDLING-- */
MPID_Progress_end(&progress_state);
goto fn_fail;
/* --END ERROR HANDLING-- */
}
}
MPID_Progress_end(&progress_state);
}
mpi_errno = MPIR_Progress_wait_request(request_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
mpi_errno = request_ptr->status.MPI_ERROR;
MPID_Request_release(request_ptr);
......
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