2004-10-12 19:50:01 +04:00
|
|
|
/*
|
2007-03-17 02:11:45 +03:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2005-11-05 22:57:48 +03:00
|
|
|
* 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.
|
2008-09-02 19:36:10 +04:00
|
|
|
* Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
* 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.
|
2008-06-07 06:44:10 +04:00
|
|
|
* Copyright (c) 2006-2008 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
2006-03-16 01:53:41 +03:00
|
|
|
*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Additional copyrights may follow
|
2006-03-16 01:53:41 +03:00
|
|
|
*
|
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"
|
2007-12-06 12:23:44 +03:00
|
|
|
#include "ompi/request/request_default.h"
|
2006-11-02 06:34:53 +03:00
|
|
|
#include "ompi/request/grequest.h"
|
2004-10-12 19:50:01 +04:00
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
#include "ompi/mca/crcp/crcp.h"
|
2004-10-12 19:50:01 +04:00
|
|
|
|
2007-12-06 12:23:44 +03:00
|
|
|
int ompi_request_default_test( ompi_request_t ** rptr,
|
2006-11-02 06:34:53 +03:00
|
|
|
int *completed,
|
|
|
|
ompi_status_public_t * status )
|
|
|
|
{
|
|
|
|
ompi_request_t *request = *rptr;
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 0
|
|
|
|
int do_it_once = 0;
|
|
|
|
|
|
|
|
recheck_request_status:
|
|
|
|
#endif
|
|
|
|
opal_atomic_mb();
|
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
|
|
|
|
*completed = true;
|
|
|
|
if (MPI_STATUS_IGNORE != status) {
|
|
|
|
*status = ompi_status_empty;
|
|
|
|
}
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
if (request->req_complete) {
|
2007-03-17 02:11:45 +03:00
|
|
|
OMPI_CRCP_REQUEST_COMPLETE(request);
|
|
|
|
|
2006-11-02 06:34:53 +03:00
|
|
|
*completed = true;
|
|
|
|
/* For a generalized request, we *have* to call the query_fn
|
|
|
|
if it completes, even if the user provided
|
|
|
|
STATUS_IGNORE. See MPI-2:8.2. */
|
|
|
|
if (OMPI_REQUEST_GEN == request->req_type) {
|
|
|
|
ompi_grequest_invoke_query(request, &request->req_status);
|
|
|
|
if (MPI_STATUS_IGNORE != status) {
|
|
|
|
int old_error = status->MPI_ERROR;
|
|
|
|
*status = request->req_status;
|
|
|
|
status->MPI_ERROR = old_error;
|
|
|
|
}
|
|
|
|
} else if (MPI_STATUS_IGNORE != status) {
|
2008-06-07 06:44:10 +04:00
|
|
|
/* Do *NOT* set a new value for status->MPI_ERROR here!
|
|
|
|
See MPI-1.1 doc, sec 3.2.5, p.22 */
|
2006-11-02 06:34:53 +03:00
|
|
|
int old_error = status->MPI_ERROR;
|
|
|
|
*status = request->req_status;
|
|
|
|
status->MPI_ERROR = old_error;
|
|
|
|
}
|
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
return request->req_status.MPI_ERROR;
|
|
|
|
}
|
2006-12-09 17:20:08 +03:00
|
|
|
/* If there was an error, don't free the request -- just
|
|
|
|
return the single error. */
|
|
|
|
if (MPI_SUCCESS != request->req_status.MPI_ERROR) {
|
|
|
|
return request->req_status.MPI_ERROR;
|
2006-11-02 06:34:53 +03:00
|
|
|
}
|
2006-12-09 17:20:08 +03:00
|
|
|
/* If there's an error on the request, assume that the request
|
|
|
|
is still there. Otherwise, Bad Things will happen
|
|
|
|
later! */
|
|
|
|
return ompi_request_free(rptr);
|
2006-11-02 06:34:53 +03:00
|
|
|
}
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 0
|
|
|
|
if( 0 == do_it_once ) {
|
|
|
|
/**
|
|
|
|
* If we run the opal_progress then check the status of the request before
|
|
|
|
* leaving. We will call the opal_progress only once per call.
|
|
|
|
*/
|
|
|
|
opal_progress();
|
|
|
|
do_it_once++;
|
|
|
|
goto recheck_request_status;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
*completed = false;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2007-12-06 12:23:44 +03:00
|
|
|
int ompi_request_default_test_any(
|
2004-10-12 19:50:01 +04:00
|
|
|
size_t count,
|
|
|
|
ompi_request_t ** requests,
|
|
|
|
int *index,
|
2005-12-13 11:58:00 +03:00
|
|
|
int *completed,
|
2004-10-12 19:50:01 +04:00
|
|
|
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;
|
|
|
|
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_mb();
|
2004-10-12 19:50:01 +04:00
|
|
|
rptr = requests;
|
2004-10-27 03:42:02 +04: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
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
|
2004-10-27 02:09:26 +04:00
|
|
|
num_requests_null_inactive++;
|
2004-10-12 19:50:01 +04:00
|
|
|
continue;
|
2004-10-27 02:09:26 +04:00
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
if( request->req_complete ) {
|
2007-03-17 02:11:45 +03:00
|
|
|
OMPI_CRCP_REQUEST_COMPLETE(request);
|
|
|
|
|
2004-10-12 19:50:01 +04:00
|
|
|
*index = i;
|
|
|
|
*completed = true;
|
2006-11-02 06:34:53 +03:00
|
|
|
/* MPI 2:8.2 says that generalized requests always have
|
|
|
|
the query function invoked in TEST* / WAIT*
|
|
|
|
(#@$%@#$%!!! Would have been simpler to call it in
|
|
|
|
GREQUEST_COMPLETE!), even if the user passed in
|
|
|
|
STATUS_IGNORE */
|
|
|
|
if (OMPI_REQUEST_GEN == request->req_type) {
|
|
|
|
ompi_grequest_invoke_query(request, &request->req_status);
|
|
|
|
if (MPI_STATUS_IGNORE != status) {
|
2008-06-07 06:44:10 +04:00
|
|
|
/* Do *NOT* set a new value for status->MPI_ERROR
|
|
|
|
here! See MPI-1.1 doc, sec 3.2.5, p.22 */
|
2006-11-02 06:34:53 +03:00
|
|
|
int old_error = status->MPI_ERROR;
|
|
|
|
*status = request->req_status;
|
|
|
|
status->MPI_ERROR = old_error;
|
|
|
|
}
|
|
|
|
} else if (MPI_STATUS_IGNORE != status) {
|
2008-06-07 06:44:10 +04:00
|
|
|
/* Do *NOT* set a new value for status->MPI_ERROR
|
|
|
|
here! See MPI-1.1 doc, sec 3.2.5, p.22 */
|
2006-07-25 19:29:37 +04:00
|
|
|
int old_error = status->MPI_ERROR;
|
2004-10-12 19:50:01 +04:00
|
|
|
*status = request->req_status;
|
2006-07-25 19:29:37 +04:00
|
|
|
status->MPI_ERROR = old_error;
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
2006-11-02 06:34:53 +03:00
|
|
|
|
2006-03-16 01:53:41 +03:00
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2006-12-09 17:20:08 +03:00
|
|
|
/* If there is an error on the request, don't free it */
|
|
|
|
if (MPI_SUCCESS != request->req_status.MPI_ERROR) {
|
|
|
|
return request->req_status.MPI_ERROR;
|
2006-07-19 01:28:45 +04:00
|
|
|
}
|
2006-12-09 17:20:08 +03:00
|
|
|
/* If there's an error while freeing the request, assume
|
|
|
|
that the request is still there. Otherwise, Bad Things
|
|
|
|
will happen later! */
|
|
|
|
return ompi_request_free(rptr);
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-10-27 01:55:20 +04:00
|
|
|
/* Only fall through here if we found nothing */
|
2005-11-30 02:41:04 +03:00
|
|
|
*index = MPI_UNDEFINED;
|
2004-10-27 03:42:02 +04:00
|
|
|
if(num_requests_null_inactive != count) {
|
|
|
|
*completed = false;
|
2005-02-16 20:42:07 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 0
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress();
|
2004-12-03 00:43:55 +03:00
|
|
|
#endif
|
2004-10-27 03:42:02 +04:00
|
|
|
} else {
|
|
|
|
*completed = true;
|
|
|
|
if (MPI_STATUS_IGNORE != status) {
|
|
|
|
*status = ompi_status_empty;
|
|
|
|
}
|
2004-10-27 01:55:20 +04:00
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-06 12:23:44 +03:00
|
|
|
int ompi_request_default_test_all(
|
2004-10-12 19:50:01 +04:00
|
|
|
size_t count,
|
|
|
|
ompi_request_t ** requests,
|
2005-12-13 11:58:00 +03:00
|
|
|
int *completed,
|
2004-10-12 19:50:01 +04:00
|
|
|
ompi_status_public_t * statuses)
|
|
|
|
{
|
2006-12-09 17:20:08 +03:00
|
|
|
size_t i, rc;
|
2004-10-12 19:50:01 +04:00
|
|
|
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;
|
|
|
|
|
2005-07-04 01:38:51 +04:00
|
|
|
opal_atomic_mb();
|
2004-10-12 19:50:01 +04:00
|
|
|
rptr = requests;
|
2004-10-27 03:42:02 +04: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
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ||
|
2004-10-27 03:03:18 +04:00
|
|
|
request->req_complete) {
|
2007-03-17 02:11:45 +03:00
|
|
|
OMPI_CRCP_REQUEST_COMPLETE(request);
|
2004-10-12 19:50:01 +04:00
|
|
|
num_completed++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (num_completed != count) {
|
|
|
|
*completed = false;
|
2005-02-16 20:42:07 +03:00
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 0
|
2005-07-04 01:57:43 +04:00
|
|
|
opal_progress();
|
2004-12-03 00:43:55 +03:00
|
|
|
#endif
|
2004-10-12 19:50:01 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2006-03-16 01:53:41 +03:00
|
|
|
rptr = requests;
|
2004-10-12 19:50:01 +04:00
|
|
|
*completed = true;
|
2006-12-09 17:20:08 +03:00
|
|
|
|
|
|
|
rc = MPI_SUCCESS;
|
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 */
|
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;
|
2008-09-02 19:36:10 +04:00
|
|
|
/*
|
|
|
|
* If the request is OMPI_REQUEST_INACTIVE set the status
|
|
|
|
* (either in the case of standard and persistent requests),
|
|
|
|
* to the already initialized req_status.
|
|
|
|
* Works also in the case of persistent request w/ MPI_PROC_NULL.
|
|
|
|
*/
|
2006-03-16 01:53:41 +03:00
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE ) {
|
2008-09-02 19:36:10 +04:00
|
|
|
statuses[i] = request->req_status;
|
2006-03-16 01:53:41 +03:00
|
|
|
continue;
|
|
|
|
}
|
2006-11-02 06:34:53 +03:00
|
|
|
if (OMPI_REQUEST_GEN == request->req_type) {
|
|
|
|
ompi_grequest_invoke_query(request, &request->req_status);
|
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
statuses[i] = request->req_status;
|
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
continue;
|
2004-10-27 02:09:26 +04:00
|
|
|
}
|
2006-12-09 17:20:08 +03:00
|
|
|
/* MPI-2:4.5.1 says that we can return MPI_ERR_IN_STATUS
|
|
|
|
even if MPI_STATUSES_IGNORE was used. Woot! */
|
|
|
|
/* Only free the request if there was no error on it */
|
|
|
|
if (MPI_SUCCESS == request->req_status.MPI_ERROR) {
|
|
|
|
int tmp = ompi_request_free(rptr);
|
|
|
|
if (tmp != OMPI_SUCCESS) {
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rc = MPI_ERR_IN_STATUS;
|
|
|
|
}
|
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-20 02:00:19 +04:00
|
|
|
request = *rptr;
|
2006-03-16 01:53:41 +03:00
|
|
|
if( request->req_state == OMPI_REQUEST_INACTIVE) {
|
|
|
|
continue;
|
|
|
|
}
|
2006-11-02 06:34:53 +03:00
|
|
|
/* See note above: if a generalized request completes, we
|
|
|
|
*have* to call the query fn, even if STATUSES_IGNORE
|
|
|
|
was supplied */
|
|
|
|
if (OMPI_REQUEST_GEN == request->req_type) {
|
|
|
|
ompi_grequest_invoke_query(request, &request->req_status);
|
|
|
|
}
|
2006-03-16 01:53:41 +03:00
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
continue;
|
|
|
|
}
|
2006-12-09 17:20:08 +03:00
|
|
|
/* Only free the request if there was no error */
|
|
|
|
if (MPI_SUCCESS == request->req_status.MPI_ERROR) {
|
|
|
|
int tmp = ompi_request_free(rptr);
|
|
|
|
if (tmp != OMPI_SUCCESS) {
|
|
|
|
return tmp;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
rc = MPI_ERR_IN_STATUS;
|
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
|
|
|
}
|
2006-12-09 17:20:08 +03:00
|
|
|
|
|
|
|
return rc;
|
2004-10-12 19:50:01 +04:00
|
|
|
}
|
|
|
|
|
2006-07-25 19:29:37 +04:00
|
|
|
|
2007-12-06 12:23:44 +03:00
|
|
|
int ompi_request_default_test_some(
|
2006-07-25 19:29:37 +04:00
|
|
|
size_t count,
|
|
|
|
ompi_request_t ** requests,
|
|
|
|
int * outcount,
|
|
|
|
int * indices,
|
|
|
|
ompi_status_public_t * statuses)
|
|
|
|
{
|
|
|
|
size_t i, num_requests_null_inactive=0, num_requests_done = 0;
|
|
|
|
int rc = OMPI_SUCCESS;
|
|
|
|
ompi_request_t **rptr;
|
|
|
|
ompi_request_t *request;
|
|
|
|
|
|
|
|
opal_atomic_mb();
|
|
|
|
rptr = requests;
|
|
|
|
for (i = 0; i < count; i++, rptr++) {
|
|
|
|
request = *rptr;
|
|
|
|
if (request->req_state == OMPI_REQUEST_INACTIVE) {
|
|
|
|
num_requests_null_inactive++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (true == request->req_complete) {
|
2007-03-17 02:11:45 +03:00
|
|
|
OMPI_CRCP_REQUEST_COMPLETE(request);
|
2006-07-25 19:29:37 +04:00
|
|
|
indices[num_requests_done++] = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If there are no active requests, no need to progress
|
|
|
|
*/
|
|
|
|
if (num_requests_null_inactive == count) {
|
|
|
|
*outcount = MPI_UNDEFINED;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
*outcount = num_requests_done;
|
|
|
|
|
|
|
|
if (num_requests_done == 0) {
|
|
|
|
#if OMPI_ENABLE_PROGRESS_THREADS == 0
|
|
|
|
opal_progress();
|
|
|
|
#endif
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fill out completion status and free request if required */
|
|
|
|
for( i = 0; i < num_requests_done; i++) {
|
|
|
|
request = requests[indices[i]];
|
|
|
|
|
|
|
|
if (MPI_STATUSES_IGNORE != statuses) {
|
2006-11-02 06:34:53 +03:00
|
|
|
if (OMPI_REQUEST_GEN == request->req_type) {
|
|
|
|
ompi_grequest_invoke_query(request, &request->req_status);
|
|
|
|
}
|
2006-07-25 19:29:37 +04:00
|
|
|
statuses[i] = request->req_status;
|
|
|
|
}
|
|
|
|
|
2006-12-09 17:20:08 +03:00
|
|
|
if (MPI_SUCCESS != request->req_status.MPI_ERROR) {
|
|
|
|
rc = MPI_ERR_IN_STATUS;
|
|
|
|
}
|
2006-07-25 19:29:37 +04:00
|
|
|
|
|
|
|
if( request->req_persistent ) {
|
|
|
|
request->req_state = OMPI_REQUEST_INACTIVE;
|
|
|
|
} else {
|
2006-12-09 17:20:08 +03:00
|
|
|
/* Only free the request if there was no error */
|
|
|
|
if (MPI_SUCCESS == request->req_status.MPI_ERROR) {
|
|
|
|
int tmp;
|
|
|
|
tmp = ompi_request_free(&(requests[indices[i]]));
|
|
|
|
if (OMPI_SUCCESS != tmp) {
|
|
|
|
return tmp;
|
|
|
|
}
|
2006-07-25 19:29:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|