2004-10-12 19:50:01 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2006-03-16 01:53:41 +03:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-10-12 19:50:01 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/constants.h"
|
|
|
|
#include "ompi/request/request.h"
|
2004-10-12 19:50:01 +04:00
|
|
|
|
2006-03-02 03:39:07 +03:00
|
|
|
int ompi_request_wait(
|
|
|
|
ompi_request_t ** req_ptr,
|
|
|
|
ompi_status_public_t * status)
|
|
|
|
{
|
|
|
|
ompi_request_t *req = *req_ptr;
|
2006-07-19 01:28:45 +04:00
|
|
|
int rc;
|
2006-03-16 01:53:41 +03:00
|
|
|
|
2006-03-02 03:39:07 +03:00
|
|
|
if(req->req_complete == false) {
|
2006-03-16 01:53:41 +03:00
|
|
|
|
2006-03-02 03:39:07 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
/* poll for completion */
|
|
|
|
if(opal_progress_spin(&req->req_complete))
|
|
|
|
goto finished;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* give up and sleep until completion */
|
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
|
|
|
ompi_request_waiting++;
|
|
|
|
while (req->req_complete == false) {
|
|
|
|
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
|
|
}
|
|
|
|
ompi_request_waiting--;
|
|
|
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
|
2006-03-02 03:39:07 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
finished:
|
|
|
|
#endif
|
2006-03-16 01:53:41 +03:00
|
|
|
|
2006-03-02 03:39:07 +03:00
|
|
|
/* return status */
|
2006-03-16 01:53:41 +03:00
|
|
|
if( MPI_STATUS_IGNORE != status ) {
|
2006-07-25 19:29:37 +04:00
|
|
|
/* See MPI-1.2, sec 3.2.5, p.22 */
|
2006-09-18 22:00:16 +04:00
|
|
|
status->MPI_TAG = req->req_status.MPI_TAG;
|
|
|
|
status->MPI_SOURCE = req->req_status.MPI_SOURCE;
|
|
|
|
status->_count = req->req_status._count;
|
|
|
|
status->_cancelled = req->req_status._cancelled;
|
2006-03-02 03:39:07 +03:00
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
if( req->req_persistent ) {
|
2006-10-17 08:27:00 +04:00
|
|
|
if( req->req_state == OMPI_REQUEST_INACTIVE ) {
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
req->req_state = OMPI_REQUEST_INACTIVE;
|
2006-07-19 01:28:45 +04:00
|
|
|
return req->req_status.MPI_ERROR;
|
2006-03-16 01:53:41 +03:00
|
|
|
}
|
|
|
|
|
2006-03-02 03:39:07 +03:00
|
|
|
/* return request to pool */
|
2006-07-19 01:28:45 +04:00
|
|
|
rc = req->req_status.MPI_ERROR;
|
|
|
|
if (OMPI_SUCCESS != ompi_request_free(req_ptr)) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
return rc;
|
2006-03-02 03:39:07 +03:00
|
|
|
}
|
|
|
|
|
2004-10-12 19:50:01 +04:00
|
|
|
|
2004-10-12 22:01:39 +04:00
|
|
|
int ompi_request_wait_any(
|
2004-10-12 19:50:01 +04:00
|
|
|
size_t count,
|
|
|
|
ompi_request_t ** requests,
|
2005-12-13 11:58:00 +03:00
|
|
|
int *index,
|
2004-10-12 19:50:01 +04:00
|
|
|
ompi_status_public_t * status)
|
|
|
|
{
|
2005-02-16 20:42:07 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
2004-10-12 19:50:01 +04:00
|
|
|
int c;
|
|
|
|
#endif
|
2004-12-06 05:15:34 +03:00
|
|
|
size_t i=0, num_requests_null_inactive=0;
|
2004-10-21 01:41:48 +04:00
|
|
|
int rc = OMPI_SUCCESS;
|
2004-10-20 18:56:52 +04:00
|
|
|
int completed = -1;
|
2004-12-06 05:15:34 +03:00
|
|
|
ompi_request_t **rptr=NULL;
|
|
|
|
ompi_request_t *request=NULL;
|
2004-10-12 19:50:01 +04:00
|
|
|
|
2005-02-16 20:42:07 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
2004-10-12 19:50:01 +04:00
|
|
|
/* poll for completion */
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_ADD32(&opal_progress_thread_count,1);
|
|
|
|
for (c = 0; completed < 0 && c < opal_progress_spin_count; c++) {
|
2004-10-12 19:50:01 +04:00
|
|
|
rptr = requests;
|
2004-10-27 02:09:26 +04:00
|
|
|
num_requests_null_inactive = 0;
|
2004-10-21 01:41:48 +04:00
|
|
|
for (i = 0; i < count; i++, rptr++) {
|
2004-10-12 19:50:01 +04:00
|
|
|
request = *rptr;
|
2005-12-13 11:58:00 +03:00
|
|
|
/*
|
|
|
|
* Check for null or completed persistent request.
|
|
|
|
* For MPI_REQUEST_NULL, the req_state is always OMPI_REQUEST_INACTIVE
|
|
|
|
*/
|
2006-01-20 00:46:53 +03:00
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
|
2006-01-20 20:17:13 +03:00
|
|
|
num_requests_null_inactive++;
|
2004-10-12 22:01:39 +04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (true == request->req_complete) {
|
2004-10-12 19:50:01 +04:00
|
|
|
completed = i;
|
2006-03-10 00:37:56 +03:00
|
|
|
OPAL_THREAD_ADD32(&opal_progress_thread_count,-1);
|
2004-10-12 22:01:39 +04:00
|
|
|
goto finished;
|
2005-12-13 11:58:00 +03:00
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
2006-03-02 03:39:07 +03:00
|
|
|
if( num_requests_null_inactive == count ) {
|
|
|
|
OPAL_THREAD_ADD32(&opal_progress_thread_count,-1);
|
2006-01-20 20:17:13 +03:00
|
|
|
goto finished;
|
2006-03-02 03:39:07 +03:00
|
|
|
}
|
|
|
|
opal_progress();
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
2006-03-02 03:39:07 +03:00
|
|
|
OPAL_THREAD_ADD32(&opal_progress_thread_count,-1);
|
2004-10-12 19:50:01 +04:00
|
|
|
#endif
|
|
|
|
|
2004-10-12 22:01:39 +04:00
|
|
|
/* give up and sleep until completion */
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
2005-03-26 21:49:16 +03:00
|
|
|
ompi_request_waiting++;
|
2006-01-14 01:02:40 +03:00
|
|
|
do {
|
2004-10-12 22:01:39 +04:00
|
|
|
rptr = requests;
|
2004-10-27 02:09:26 +04:00
|
|
|
num_requests_null_inactive = 0;
|
2004-10-21 01:41:48 +04:00
|
|
|
for (i = 0; i < count; i++, rptr++) {
|
2004-10-12 22:01:39 +04:00
|
|
|
request = *rptr;
|
2005-12-13 11:58:00 +03:00
|
|
|
/*
|
|
|
|
* Check for null or completed persistent request.
|
2006-01-20 20:17:13 +03:00
|
|
|
* For MPI_REQUEST_NULL, the req_state is always OMPI_REQUEST_INACTIVE.
|
2005-12-13 11:58:00 +03:00
|
|
|
*/
|
2006-01-20 00:46:53 +03:00
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
|
2004-10-27 02:09:26 +04:00
|
|
|
num_requests_null_inactive++;
|
2004-10-12 22:01:39 +04:00
|
|
|
continue;
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
2004-10-12 22:01:39 +04:00
|
|
|
if (request->req_complete == true) {
|
|
|
|
completed = i;
|
|
|
|
break;
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
2004-10-12 22:01:39 +04:00
|
|
|
}
|
2004-10-27 02:09:26 +04:00
|
|
|
if(num_requests_null_inactive == count)
|
2004-10-12 22:01:39 +04:00
|
|
|
break;
|
2006-01-14 01:02:40 +03:00
|
|
|
if (completed < 0) {
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
2004-10-12 22:01:39 +04:00
|
|
|
}
|
2006-01-14 01:02:40 +03:00
|
|
|
} while (completed < 0);
|
2004-10-12 22:01:39 +04:00
|
|
|
ompi_request_waiting--;
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
2004-10-12 19:50:01 +04:00
|
|
|
|
2005-02-16 20:42:07 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
2004-10-12 22:01:39 +04:00
|
|
|
finished:
|
2005-02-16 20:42:07 +03:00
|
|
|
#endif /* OMPI_ENABLE_PROGRESS_THREADS */
|
|
|
|
|
2004-10-27 02:09:26 +04:00
|
|
|
if(num_requests_null_inactive == count) {
|
2004-10-12 22:01:39 +04:00
|
|
|
*index = MPI_UNDEFINED;
|
2004-10-27 02:09:26 +04:00
|
|
|
if (MPI_STATUS_IGNORE != status) {
|
|
|
|
*status = ompi_status_empty;
|
|
|
|
}
|
2004-10-12 22:01:39 +04:00
|
|
|
} else {
|
2006-03-16 01:53:41 +03:00
|
|
|
assert( true == request->req_complete );
|
2004-10-12 22:01:39 +04:00
|
|
|
/* return status */
|
|
|
|
if (MPI_STATUS_IGNORE != status) {
|
2006-07-25 19:29:37 +04:00
|
|
|
/* See MPI-1.2, sec 3.2.5, p.22 */
|
|
|
|
int old_error = status->MPI_ERROR;
|
2004-10-12 22:01:39 +04:00
|
|
|
*status = request->req_status;
|
2006-07-25 19:29:37 +04:00
|
|
|
status->MPI_ERROR = old_error;
|
2004-10-12 22:01:39 +04:00
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
2006-07-19 01:28:45 +04:00
|
|
|
rc = request->req_status.MPI_ERROR;
|
2006-03-16 01:53:41 +03:00
|
|
|
} else {
|
2006-07-19 01:28:45 +04:00
|
|
|
int tmp;
|
|
|
|
|
2006-03-16 01:53:41 +03:00
|
|
|
/* return request to pool */
|
2006-07-19 01:28:45 +04:00
|
|
|
rc = request->req_status.MPI_ERROR;
|
|
|
|
tmp = ompi_request_free(rptr);
|
|
|
|
if (OMPI_SUCCESS != tmp) rc = tmp;
|
2006-03-16 01:53:41 +03:00
|
|
|
}
|
2004-10-12 22:01:39 +04:00
|
|
|
*index = completed;
|
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ompi_request_wait_all(
|
|
|
|
size_t count,
|
|
|
|
ompi_request_t ** requests,
|
|
|
|
ompi_status_public_t * statuses)
|
|
|
|
{
|
|
|
|
size_t completed = 0, i;
|
|
|
|
ompi_request_t **rptr;
|
|
|
|
ompi_request_t *request;
|
2006-03-16 01:53:41 +03:00
|
|
|
int mpi_error = OMPI_SUCCESS;
|
2004-10-12 19:50:01 +04:00
|
|
|
|
|
|
|
rptr = requests;
|
|
|
|
for (i = 0; i < count; i++) {
|
2004-10-14 23:17:16 +04:00
|
|
|
request = *rptr++;
|
2004-10-12 22:01:39 +04:00
|
|
|
if (request->req_complete == true) {
|
2004-10-12 19:50:01 +04:00
|
|
|
completed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if all requests have not completed -- defer acquiring lock
|
2005-12-13 11:58:00 +03:00
|
|
|
* unless required
|
2004-10-12 19:50:01 +04:00
|
|
|
*/
|
|
|
|
if (completed != count) {
|
2005-11-10 03:45:27 +03:00
|
|
|
|
2004-10-12 19:50:01 +04:00
|
|
|
/*
|
|
|
|
* acquire lock and test for completion - if all requests are
|
|
|
|
* not completed pend on condition variable until a request
|
|
|
|
* completes
|
|
|
|
*/
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
2004-10-12 19:50:01 +04:00
|
|
|
ompi_request_waiting++;
|
2006-01-20 00:46:53 +03:00
|
|
|
#if OMPI_HAVE_THREAD_SUPPORT
|
|
|
|
/*
|
|
|
|
* confirm the status of the pending requests. We have to do it before
|
|
|
|
* taking the condition or otherwise we can miss some requests completion (the
|
|
|
|
* one that happpens between our initial test and the aquisition of the lock).
|
|
|
|
*/
|
|
|
|
rptr = requests;
|
|
|
|
for( completed = i = 0; i < count; i++ ) {
|
|
|
|
request = *rptr++;
|
|
|
|
if (request->req_complete == true) {
|
|
|
|
completed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* OMPI_HAVE_THREAD_SUPPORT */
|
2006-01-20 20:17:13 +03:00
|
|
|
while( completed != count ) {
|
2005-11-10 03:45:27 +03:00
|
|
|
/* check number of pending requests */
|
|
|
|
size_t start = ompi_request_completed;
|
|
|
|
size_t pending = count - completed;
|
|
|
|
/*
|
2006-03-16 01:53:41 +03:00
|
|
|
* wait until at least pending requests complete
|
2006-01-20 20:17:13 +03:00
|
|
|
*/
|
2005-11-10 03:45:27 +03:00
|
|
|
while (pending > ompi_request_completed - start) {
|
|
|
|
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
|
|
}
|
|
|
|
/*
|
2006-01-20 00:46:53 +03:00
|
|
|
* confirm that all pending operations have completed.
|
|
|
|
*/
|
2004-10-12 19:50:01 +04:00
|
|
|
rptr = requests;
|
2006-01-20 00:46:53 +03:00
|
|
|
for( completed = i = 0; i < count; i++ ) {
|
2004-10-14 23:17:16 +04:00
|
|
|
request = *rptr++;
|
2004-10-14 02:56:42 +04:00
|
|
|
if (request->req_complete == true) {
|
2004-10-12 19:50:01 +04:00
|
|
|
completed++;
|
|
|
|
}
|
|
|
|
}
|
2006-01-20 20:17:13 +03:00
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
ompi_request_waiting--;
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
|
|
|
|
2006-03-16 01:53:41 +03:00
|
|
|
rptr = requests;
|
2004-10-27 02:09:26 +04:00
|
|
|
if (MPI_STATUSES_IGNORE != statuses) {
|
2004-10-12 19:50:01 +04:00
|
|
|
/* fill out status and free request if required */
|
2006-03-16 01:53:41 +03:00
|
|
|
for( i = 0; i < count; i++, rptr++ ) {
|
2004-10-12 19:50:01 +04:00
|
|
|
request = *rptr;
|
2006-03-16 01:53:41 +03:00
|
|
|
assert( true == request->req_complete );
|
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
|
2004-10-27 02:09:26 +04:00
|
|
|
statuses[i] = ompi_status_empty;
|
|
|
|
} else {
|
|
|
|
statuses[i] = request->req_status;
|
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
} else {
|
|
|
|
(void)ompi_request_free(rptr);
|
|
|
|
}
|
|
|
|
if( statuses[i].MPI_ERROR != OMPI_SUCCESS) {
|
2006-07-25 19:29:37 +04:00
|
|
|
mpi_error = MPI_ERR_IN_STATUS;
|
2006-03-16 01:53:41 +03:00
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* free request if required */
|
2006-03-16 01:53:41 +03:00
|
|
|
for( i = 0; i < count; i++, rptr++ ) {
|
2004-10-12 22:01:39 +04:00
|
|
|
int rc;
|
2004-10-12 19:50:01 +04:00
|
|
|
request = *rptr;
|
2006-03-16 01:53:41 +03:00
|
|
|
|
|
|
|
assert( true == request->req_complete );
|
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
|
|
|
|
rc = ompi_status_empty.MPI_ERROR;
|
|
|
|
} else {
|
|
|
|
rc = request->req_status.MPI_ERROR;
|
2006-01-20 20:17:13 +03:00
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
} else {
|
|
|
|
(void)ompi_request_free(rptr);
|
|
|
|
}
|
|
|
|
if( rc != OMPI_SUCCESS) {
|
|
|
|
mpi_error = rc;
|
|
|
|
}
|
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
return mpi_error;
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
2004-10-12 22:01:39 +04:00
|
|
|
|
2006-07-25 19:29:37 +04:00
|
|
|
|
|
|
|
int ompi_request_wait_some(
|
|
|
|
size_t count,
|
|
|
|
ompi_request_t ** requests,
|
|
|
|
int * outcount,
|
|
|
|
int * indices,
|
|
|
|
ompi_status_public_t * statuses)
|
|
|
|
{
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
int c;
|
|
|
|
#endif
|
|
|
|
size_t i, num_requests_null_inactive=0, num_requests_done=0;
|
|
|
|
int rc = OMPI_SUCCESS;
|
|
|
|
ompi_request_t **rptr=NULL;
|
|
|
|
ompi_request_t *request=NULL;
|
|
|
|
|
|
|
|
*outcount = 0;
|
|
|
|
for (i = 0; i < count; i++){
|
|
|
|
indices[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
/* poll for completion */
|
|
|
|
OPAL_THREAD_ADD32(&opal_progress_thread_count,1);
|
|
|
|
for (c = 0; c < opal_progress_spin_count; c++) {
|
|
|
|
rptr = requests;
|
|
|
|
num_requests_null_inactive = 0;
|
|
|
|
num_requests_done = 0;
|
|
|
|
for (i = 0; i < count; i++, rptr++) {
|
|
|
|
request = *rptr;
|
|
|
|
/*
|
|
|
|
* Check for null or completed persistent request.
|
|
|
|
* For MPI_REQUEST_NULL, the req_state is always OMPI_REQUEST_INACTIVE
|
|
|
|
*/
|
|
|
|
if (request->req_state == OMPI_REQUEST_INACTIVE ) {
|
|
|
|
num_requests_null_inactive++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (true == request->req_complete) {
|
|
|
|
indices[i] = 1;
|
|
|
|
num_requests_done++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (num_requests_null_inactive == count ||
|
|
|
|
num_requests_done > 0) {
|
|
|
|
OPAL_THREAD_ADD32(&opal_progress_thread_count,-1);
|
|
|
|
goto finished;
|
|
|
|
}
|
|
|
|
opal_progress();
|
|
|
|
}
|
|
|
|
OPAL_THREAD_ADD32(&opal_progress_thread_count,-1);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We only get here when outcount still is 0.
|
|
|
|
* give up and sleep until completion
|
|
|
|
*/
|
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
|
|
|
ompi_request_waiting++;
|
|
|
|
do {
|
|
|
|
rptr = requests;
|
|
|
|
num_requests_null_inactive = 0;
|
|
|
|
num_requests_done = 0;
|
|
|
|
for (i = 0; i < count; i++, rptr++) {
|
|
|
|
request = *rptr;
|
|
|
|
/*
|
|
|
|
* Check for null or completed persistent request.
|
|
|
|
* For MPI_REQUEST_NULL, the req_state is always OMPI_REQUEST_INACTIVE.
|
|
|
|
*/
|
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
|
|
|
|
num_requests_null_inactive++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (request->req_complete == true) {
|
|
|
|
indices[i] = 1;
|
|
|
|
num_requests_done++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (num_requests_null_inactive == count ||
|
|
|
|
num_requests_done > 0)
|
|
|
|
break;
|
|
|
|
opal_condition_wait(&ompi_request_cond, &ompi_request_lock);
|
|
|
|
} while (1);
|
|
|
|
ompi_request_waiting--;
|
|
|
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
|
|
|
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS
|
|
|
|
finished:
|
|
|
|
#endif /* OMPI_ENABLE_PROGRESS_THREADS */
|
|
|
|
|
|
|
|
if(num_requests_null_inactive == count) {
|
|
|
|
*outcount = MPI_UNDEFINED;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Compress the index array.
|
|
|
|
*/
|
|
|
|
for (i = 0, num_requests_done = 0; i < count; i++) {
|
|
|
|
if (0 != indices[i]) {
|
|
|
|
indices[num_requests_done++] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*outcount = num_requests_done;
|
|
|
|
|
|
|
|
for (i = 0; i < num_requests_done; i++) {
|
|
|
|
request = requests[indices[i]];
|
|
|
|
assert( true == request->req_complete );
|
|
|
|
/* return status */
|
|
|
|
if (MPI_STATUSES_IGNORE != statuses) {
|
|
|
|
statuses[i] = request->req_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
rc += request->req_status.MPI_ERROR;
|
|
|
|
|
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
} else {
|
|
|
|
int tmp;
|
|
|
|
/* return request to pool */
|
|
|
|
tmp = ompi_request_free(&(requests[indices[i]]));
|
|
|
|
/*
|
|
|
|
* If it fails, we are screwed. We cannot put the
|
|
|
|
* request_free return code into the status, possibly
|
|
|
|
* overwriting some other important error; therefore just quit.
|
|
|
|
*/
|
|
|
|
if (OMPI_SUCCESS != tmp) {
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (OMPI_SUCCESS != rc) {
|
|
|
|
rc = MPI_ERR_IN_STATUS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|