2004-01-29 05:50:02 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-08 21:12:36 +04:00
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include "class/ompi_object.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "request/request.h"
|
2004-06-25 18:29:21 +04:00
|
|
|
#include "include/constants.h"
|
2004-01-29 05:50:02 +03:00
|
|
|
|
2004-10-12 19:50:01 +04:00
|
|
|
ompi_pointer_array_t ompi_request_f_to_c_table;
|
|
|
|
volatile int ompi_request_waiting = 0;
|
|
|
|
int ompi_request_poll_iterations = 20000;
|
|
|
|
ompi_mutex_t ompi_request_lock;
|
|
|
|
ompi_condition_t ompi_request_cond;
|
|
|
|
ompi_request_t ompi_request_null;
|
2004-10-27 01:55:20 +04:00
|
|
|
ompi_status_public_t ompi_status_empty;
|
2004-10-08 21:12:36 +04:00
|
|
|
|
2004-01-29 05:50:02 +03:00
|
|
|
|
2004-06-21 19:24:40 +04:00
|
|
|
static void ompi_request_construct(ompi_request_t* req)
|
2004-01-29 05:50:02 +03:00
|
|
|
{
|
2004-10-08 21:12:36 +04:00
|
|
|
OMPI_REQUEST_INIT(req);
|
2004-10-20 02:00:19 +04:00
|
|
|
req->req_fini = NULL;
|
2004-10-12 19:50:01 +04:00
|
|
|
req->req_free = NULL;
|
|
|
|
req->req_cancel = NULL;
|
2004-10-23 23:24:00 +04:00
|
|
|
req->req_f_to_c_index = MPI_UNDEFINED;
|
2004-01-29 05:50:02 +03:00
|
|
|
}
|
|
|
|
|
2004-06-21 19:24:40 +04:00
|
|
|
static void ompi_request_destruct(ompi_request_t* req)
|
2004-01-29 05:50:02 +03:00
|
|
|
{
|
2004-10-08 21:12:36 +04:00
|
|
|
OMPI_REQUEST_FINI(req);
|
2004-01-29 05:50:02 +03:00
|
|
|
}
|
|
|
|
|
2004-10-20 02:00:19 +04:00
|
|
|
static int ompi_request_null_free(ompi_request_t** request)
|
2004-10-12 19:50:01 +04:00
|
|
|
{
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ompi_request_null_cancel(ompi_request_t* request, int flag)
|
|
|
|
{
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-01-29 05:50:02 +03:00
|
|
|
|
2004-06-21 19:24:40 +04:00
|
|
|
OBJ_CLASS_INSTANCE(
|
|
|
|
ompi_request_t,
|
|
|
|
ompi_object_t,
|
|
|
|
ompi_request_construct,
|
|
|
|
ompi_request_destruct);
|
|
|
|
|
|
|
|
|
2004-10-08 21:12:36 +04:00
|
|
|
int ompi_request_init(void)
|
|
|
|
{
|
2004-10-12 19:50:01 +04:00
|
|
|
OBJ_CONSTRUCT(&ompi_request_f_to_c_table, ompi_pointer_array_t);
|
|
|
|
OBJ_CONSTRUCT(&ompi_request_lock, ompi_mutex_t);
|
|
|
|
OBJ_CONSTRUCT(&ompi_request_cond, ompi_condition_t);
|
|
|
|
OBJ_CONSTRUCT(&ompi_request_null, ompi_request_t);
|
|
|
|
|
|
|
|
ompi_request_null.req_status.MPI_SOURCE = MPI_PROC_NULL;
|
|
|
|
ompi_request_null.req_status.MPI_TAG = MPI_ANY_TAG;
|
|
|
|
ompi_request_null.req_status.MPI_ERROR = MPI_SUCCESS;
|
|
|
|
ompi_request_null.req_status._count = 0;
|
|
|
|
|
2004-10-27 02:09:26 +04:00
|
|
|
ompi_request_null.req_state = OMPI_REQUEST_INACTIVE;
|
2004-10-12 19:50:01 +04:00
|
|
|
ompi_request_null.req_complete = true;
|
|
|
|
ompi_request_null.req_type = OMPI_REQUEST_NULL;
|
2004-10-20 02:00:19 +04:00
|
|
|
ompi_request_null.req_fini = ompi_request_null_free;
|
2004-10-12 19:50:01 +04:00
|
|
|
ompi_request_null.req_free = ompi_request_null_free;
|
|
|
|
ompi_request_null.req_cancel = ompi_request_null_cancel;
|
2004-10-26 16:11:16 +04:00
|
|
|
ompi_request_null.req_f_to_c_index =
|
|
|
|
ompi_pointer_array_add(&ompi_request_f_to_c_table, &ompi_request_null);
|
2004-10-12 19:50:01 +04:00
|
|
|
|
2004-10-26 16:11:16 +04:00
|
|
|
if (0 != ompi_request_null.req_f_to_c_index) {
|
2004-10-08 21:12:36 +04:00
|
|
|
return OMPI_ERR_REQUEST;
|
|
|
|
}
|
2004-10-27 01:55:20 +04:00
|
|
|
|
|
|
|
ompi_status_empty.MPI_SOURCE = MPI_ANY_SOURCE;
|
|
|
|
ompi_status_empty.MPI_TAG = MPI_ANY_TAG;
|
|
|
|
ompi_status_empty.MPI_ERROR = MPI_SUCCESS;
|
|
|
|
ompi_status_empty._count = 0;
|
|
|
|
|
2004-10-08 21:12:36 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ompi_request_finalize(void)
|
|
|
|
{
|
2004-10-12 19:50:01 +04:00
|
|
|
OBJ_DESTRUCT(&ompi_request_null);
|
2004-10-20 15:03:29 +04:00
|
|
|
OBJ_DESTRUCT(&ompi_request_cond);
|
|
|
|
OBJ_DESTRUCT(&ompi_request_lock);
|
|
|
|
OBJ_DESTRUCT(&ompi_request_f_to_c_table);
|
2004-10-12 19:50:01 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int ompi_request_complete(ompi_request_t* request)
|
|
|
|
{
|
|
|
|
OMPI_THREAD_LOCK(&ompi_request_lock);
|
|
|
|
request->req_complete = true;
|
|
|
|
if(ompi_request_waiting)
|
|
|
|
ompi_condition_signal(&ompi_request_cond);
|
|
|
|
OMPI_THREAD_UNLOCK(&ompi_request_lock);
|
2004-10-08 21:12:36 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
|