2004-10-12 15:50:01 +00:00
|
|
|
/*
|
2005-11-05 19:57:48 +00:00
|
|
|
* 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.
|
2006-03-15 22:53:41 +00:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 20:09:25 +00:00
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 12:43:37 +00:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2004-11-22 01:38:40 +00:00
|
|
|
* $COPYRIGHT$
|
2006-03-15 22:53:41 +00:00
|
|
|
*
|
2004-11-22 01:38:40 +00:00
|
|
|
* Additional copyrights may follow
|
2006-03-15 22:53:41 +00:00
|
|
|
*
|
2004-10-12 15:50:01 +00:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
2006-02-12 01:33:29 +00:00
|
|
|
#include "ompi/constants.h"
|
|
|
|
#include "ompi/request/request.h"
|
2004-10-12 15:50:01 +00:00
|
|
|
|
|
|
|
|
2004-10-26 21:45:25 +00:00
|
|
|
int ompi_request_test_any(
|
2004-10-12 15:50:01 +00:00
|
|
|
size_t count,
|
|
|
|
ompi_request_t ** requests,
|
|
|
|
int *index,
|
2005-12-13 08:58:00 +00:00
|
|
|
int *completed,
|
2004-10-12 15:50:01 +00:00
|
|
|
ompi_status_public_t * status)
|
|
|
|
{
|
|
|
|
size_t i;
|
2004-10-26 22:09:26 +00:00
|
|
|
size_t num_requests_null_inactive = 0;
|
2004-10-12 15:50:01 +00:00
|
|
|
ompi_request_t **rptr;
|
|
|
|
ompi_request_t *request;
|
|
|
|
|
2005-07-03 21:38:51 +00:00
|
|
|
opal_atomic_mb();
|
2004-10-12 15:50:01 +00:00
|
|
|
rptr = requests;
|
2004-10-26 23:42:02 +00:00
|
|
|
for (i = 0; i < count; i++, rptr++) {
|
2004-10-12 15:50:01 +00:00
|
|
|
request = *rptr;
|
2006-03-15 22:53:41 +00:00
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
|
2004-10-26 22:09:26 +00:00
|
|
|
num_requests_null_inactive++;
|
2004-10-12 15:50:01 +00:00
|
|
|
continue;
|
2004-10-26 22:09:26 +00:00
|
|
|
}
|
2006-03-15 22:53:41 +00:00
|
|
|
if( request->req_complete ) {
|
2004-10-12 15:50:01 +00:00
|
|
|
*index = i;
|
|
|
|
*completed = true;
|
2004-10-13 22:27:00 +00:00
|
|
|
if (MPI_STATUS_IGNORE != status) {
|
2004-10-12 15:50:01 +00:00
|
|
|
*status = request->req_status;
|
|
|
|
}
|
2006-03-15 22:53:41 +00:00
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
return ompi_request_free(rptr);
|
2004-10-12 15:50:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-26 21:55:20 +00:00
|
|
|
/* Only fall through here if we found nothing */
|
2005-11-29 23:41:04 +00:00
|
|
|
*index = MPI_UNDEFINED;
|
2004-10-26 23:42:02 +00:00
|
|
|
if(num_requests_null_inactive != count) {
|
|
|
|
*completed = false;
|
2005-02-16 17:42:07 +00:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 0
|
2005-07-03 21:57:43 +00:00
|
|
|
opal_progress();
|
2004-12-02 21:43:55 +00:00
|
|
|
#endif
|
2004-10-26 23:42:02 +00:00
|
|
|
} else {
|
|
|
|
*completed = true;
|
|
|
|
if (MPI_STATUS_IGNORE != status) {
|
|
|
|
*status = ompi_status_empty;
|
|
|
|
}
|
2004-10-26 21:55:20 +00:00
|
|
|
}
|
2004-10-12 15:50:01 +00:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ompi_request_test_all(
|
|
|
|
size_t count,
|
|
|
|
ompi_request_t ** requests,
|
2005-12-13 08:58:00 +00:00
|
|
|
int *completed,
|
2004-10-12 15:50:01 +00:00
|
|
|
ompi_status_public_t * statuses)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
ompi_request_t **rptr;
|
2004-10-26 23:03:18 +00:00
|
|
|
size_t num_completed = 0;
|
2004-10-12 15:50:01 +00:00
|
|
|
ompi_request_t *request;
|
|
|
|
|
2005-07-03 21:38:51 +00:00
|
|
|
opal_atomic_mb();
|
2004-10-12 15:50:01 +00:00
|
|
|
rptr = requests;
|
2004-10-26 23:42:02 +00:00
|
|
|
for (i = 0; i < count; i++, rptr++) {
|
2004-10-12 15:50:01 +00:00
|
|
|
request = *rptr;
|
2006-03-15 22:53:41 +00:00
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ||
|
2004-10-26 23:03:18 +00:00
|
|
|
request->req_complete) {
|
2004-10-12 15:50:01 +00:00
|
|
|
num_completed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_completed != count) {
|
|
|
|
*completed = false;
|
2005-02-16 17:42:07 +00:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 0
|
2005-07-03 21:57:43 +00:00
|
|
|
opal_progress();
|
2004-12-02 21:43:55 +00:00
|
|
|
#endif
|
2004-10-12 15:50:01 +00:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-03-15 22:53:41 +00:00
|
|
|
rptr = requests;
|
2004-10-12 15:50:01 +00:00
|
|
|
*completed = true;
|
2004-10-26 22:09:26 +00:00
|
|
|
if (MPI_STATUSES_IGNORE != statuses) {
|
2004-10-12 15:50:01 +00:00
|
|
|
/* fill out completion status and free request if required */
|
2006-03-15 22:53:41 +00:00
|
|
|
for( i = 0; i < count; i++, rptr++ ) {
|
2004-10-13 22:27:00 +00:00
|
|
|
int rc;
|
2004-10-12 15:50:01 +00:00
|
|
|
request = *rptr;
|
2006-03-15 22:53:41 +00:00
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
|
2004-10-26 22:09:26 +00:00
|
|
|
statuses[i] = ompi_status_empty;
|
2006-03-15 22:53:41 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
statuses[i] = request->req_status;
|
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
continue;
|
2004-10-26 22:09:26 +00:00
|
|
|
}
|
2006-03-15 22:53:41 +00:00
|
|
|
rc = ompi_request_free(rptr);
|
2004-10-13 22:27:00 +00:00
|
|
|
if(rc != OMPI_SUCCESS)
|
2006-03-15 22:53:41 +00:00
|
|
|
return rc;
|
2004-10-12 15:50:01 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* free request if required */
|
2006-03-15 22:53:41 +00:00
|
|
|
for( i = 0; i < count; i++, rptr++ ) {
|
2004-10-19 22:00:19 +00:00
|
|
|
int rc;
|
|
|
|
request = *rptr;
|
2006-03-15 22:53:41 +00:00
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
rc = ompi_request_free(rptr);
|
2004-10-13 22:27:00 +00:00
|
|
|
if(rc != OMPI_SUCCESS)
|
|
|
|
return rc;
|
2004-10-12 15:50:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|