2004-10-12 19:50:01 +04:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include "mpi.h"
|
|
|
|
#include "include/constants.h"
|
|
|
|
#include "request/request.h"
|
|
|
|
|
|
|
|
|
2004-10-27 01:45:25 +04:00
|
|
|
int ompi_request_test_any(
|
2004-10-12 19:50:01 +04:00
|
|
|
size_t count,
|
|
|
|
ompi_request_t ** requests,
|
|
|
|
int *index,
|
|
|
|
int *completed,
|
|
|
|
ompi_status_public_t * status)
|
|
|
|
{
|
|
|
|
size_t i;
|
2004-10-27 02:09:26 +04:00
|
|
|
size_t num_requests_null_inactive = 0;
|
2004-10-12 19:50:01 +04:00
|
|
|
ompi_request_t **rptr;
|
|
|
|
ompi_request_t *request;
|
|
|
|
|
|
|
|
ompi_atomic_mb();
|
|
|
|
rptr = requests;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
request = *rptr;
|
2004-10-27 02:09:26 +04:00
|
|
|
if (request == MPI_REQUEST_NULL ||
|
|
|
|
request->req_state == OMPI_REQUEST_INACTIVE) {
|
|
|
|
num_requests_null_inactive++;
|
2004-10-12 19:50:01 +04:00
|
|
|
continue;
|
2004-10-27 02:09:26 +04:00
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
if (request->req_complete) {
|
|
|
|
*index = i;
|
|
|
|
*completed = true;
|
2004-10-14 02:27:00 +04:00
|
|
|
if (MPI_STATUS_IGNORE != status) {
|
2004-10-12 19:50:01 +04:00
|
|
|
*status = request->req_status;
|
|
|
|
}
|
2004-10-20 02:00:19 +04:00
|
|
|
return request->req_fini(rptr);
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
|
|
|
rptr++;
|
|
|
|
}
|
|
|
|
|
2004-10-27 01:55:20 +04:00
|
|
|
/* Only fall through here if we found nothing */
|
2004-10-12 19:50:01 +04:00
|
|
|
*index = MPI_UNDEFINED;
|
2004-10-27 02:09:26 +04:00
|
|
|
*completed = (num_requests_null_inactive == count) ? true : false;
|
2004-10-27 01:55:20 +04:00
|
|
|
if (MPI_STATUS_IGNORE != status) {
|
|
|
|
*status = ompi_status_empty;
|
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ompi_request_test_all(
|
|
|
|
size_t count,
|
|
|
|
ompi_request_t ** requests,
|
|
|
|
int *completed,
|
|
|
|
ompi_status_public_t * statuses)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
ompi_request_t **rptr;
|
2004-10-27 03:03:18 +04:00
|
|
|
size_t num_completed = 0;
|
2004-10-12 19:50:01 +04:00
|
|
|
ompi_request_t *request;
|
|
|
|
|
|
|
|
ompi_atomic_mb();
|
|
|
|
rptr = requests;
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
request = *rptr;
|
2004-10-27 03:03:18 +04:00
|
|
|
if (request == MPI_REQUEST_NULL ||
|
|
|
|
request->req_state == OMPI_REQUEST_INACTIVE ||
|
|
|
|
request->req_complete) {
|
2004-10-12 19:50:01 +04:00
|
|
|
num_completed++;
|
|
|
|
}
|
|
|
|
rptr++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_completed != count) {
|
|
|
|
*completed = false;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
*completed = true;
|
2004-10-27 02:09:26 +04:00
|
|
|
if (MPI_STATUSES_IGNORE != statuses) {
|
2004-10-12 19:50:01 +04:00
|
|
|
/* fill out completion status and free request if required */
|
|
|
|
rptr = requests;
|
|
|
|
for (i = 0; i < count; i++) {
|
2004-10-14 02:27:00 +04:00
|
|
|
int rc;
|
2004-10-12 19:50:01 +04:00
|
|
|
request = *rptr;
|
2004-10-27 02:09:26 +04:00
|
|
|
if(request == MPI_REQUEST_NULL ||
|
|
|
|
request->req_state == OMPI_REQUEST_INACTIVE) {
|
|
|
|
statuses[i] = ompi_status_empty;
|
|
|
|
} else {
|
|
|
|
statuses[i] = request->req_status;
|
|
|
|
}
|
2004-10-20 02:00:19 +04:00
|
|
|
rc = request->req_fini(rptr);
|
2004-10-14 02:27:00 +04:00
|
|
|
if(rc != OMPI_SUCCESS)
|
|
|
|
return rc;
|
2004-10-12 19:50:01 +04:00
|
|
|
rptr++;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* free request if required */
|
|
|
|
rptr = requests;
|
|
|
|
for (i = 0; i < count; i++) {
|
2004-10-20 02:00:19 +04:00
|
|
|
int rc;
|
|
|
|
request = *rptr;
|
|
|
|
rc = request->req_fini(rptr);
|
2004-10-14 02:27:00 +04:00
|
|
|
if(rc != OMPI_SUCCESS)
|
|
|
|
return rc;
|
2004-10-12 19:50:01 +04:00
|
|
|
rptr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|