2004-01-29 05:50:02 +03:00
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* 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-01-29 05:50:02 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-08 21:12:36 +04:00
|
|
|
#include "ompi_config.h"
|
|
|
|
|
2005-07-03 20:06:07 +04:00
|
|
|
#include "opal/class/opal_object.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "request/request.h"
|
2005-08-13 01:42:07 +04:00
|
|
|
#include "ompi/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;
|
2005-05-09 20:23:00 +04:00
|
|
|
OMPI_DECLSPEC volatile int ompi_request_waiting = 0;
|
2005-07-04 02:45:48 +04:00
|
|
|
OMPI_DECLSPEC opal_mutex_t ompi_request_lock;
|
|
|
|
OMPI_DECLSPEC opal_condition_t ompi_request_cond;
|
2005-05-09 20:23:00 +04:00
|
|
|
OMPI_DECLSPEC ompi_request_t ompi_request_null;
|
2005-07-27 05:00:02 +04:00
|
|
|
OMPI_DECLSPEC ompi_request_t ompi_request_empty;
|
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;
|
|
|
|
}
|
|
|
|
|
2005-07-27 21:25:12 +04:00
|
|
|
static int ompi_request_empty_free(ompi_request_t** request)
|
|
|
|
{
|
|
|
|
*request = &ompi_request_null;
|
|
|
|
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,
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t,
|
2004-06-21 19:24:40 +04:00
|
|
|
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);
|
2005-07-04 02:45:48 +04:00
|
|
|
OBJ_CONSTRUCT(&ompi_request_lock, opal_mutex_t);
|
|
|
|
OBJ_CONSTRUCT(&ompi_request_cond, opal_condition_t);
|
2004-10-12 19:50:01 +04:00
|
|
|
OBJ_CONSTRUCT(&ompi_request_null, ompi_request_t);
|
2005-07-27 05:00:02 +04:00
|
|
|
OBJ_CONSTRUCT(&ompi_request_empty, ompi_request_t);
|
2004-10-12 19:50:01 +04:00
|
|
|
|
|
|
|
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;
|
2005-02-24 03:12:26 +03:00
|
|
|
ompi_request_null.req_status._cancelled = 0;
|
2004-10-12 19:50:01 +04:00
|
|
|
|
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
|
|
|
|
2005-07-27 05:00:02 +04:00
|
|
|
/* We need a way to distinguish between the user provided
|
|
|
|
* MPI_REQUEST_NULL to MPI_Wait* and a non-active (MPI_PROC_NULL)
|
|
|
|
* request passed to any P2P non-blocking function.
|
|
|
|
*
|
|
|
|
* The main difference to ompi_request_null is
|
|
|
|
* req_state being OMPI_REQUEST_ACTIVE, so that MPI_Waitall
|
2005-07-27 21:25:12 +04:00
|
|
|
* does not set the status to ompi_status_empty and the different
|
|
|
|
* req_fini and req_free function, which resets the
|
|
|
|
* request to MPI_REQUEST_NULL.
|
|
|
|
* The req_cancel function need not be changed.
|
2005-07-27 05:00:02 +04:00
|
|
|
*/
|
|
|
|
ompi_request_empty.req_status.MPI_SOURCE = MPI_PROC_NULL;
|
|
|
|
ompi_request_empty.req_status.MPI_TAG = MPI_ANY_TAG;
|
|
|
|
ompi_request_empty.req_status.MPI_ERROR = MPI_SUCCESS;
|
|
|
|
ompi_request_empty.req_status._count = 0;
|
|
|
|
ompi_request_empty.req_status._cancelled = 0;
|
|
|
|
|
|
|
|
ompi_request_empty.req_state = OMPI_REQUEST_ACTIVE;
|
|
|
|
ompi_request_empty.req_complete = true;
|
|
|
|
ompi_request_empty.req_type = OMPI_REQUEST_NULL;
|
2005-07-27 21:25:12 +04:00
|
|
|
ompi_request_empty.req_fini = ompi_request_empty_free;
|
|
|
|
ompi_request_empty.req_free = ompi_request_empty_free;
|
2005-07-27 05:00:02 +04:00
|
|
|
ompi_request_empty.req_cancel = ompi_request_null_cancel;
|
|
|
|
ompi_request_empty.req_f_to_c_index =
|
|
|
|
ompi_pointer_array_add(&ompi_request_f_to_c_table, &ompi_request_empty);
|
|
|
|
|
|
|
|
if (1 != ompi_request_empty.req_f_to_c_index) {
|
|
|
|
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;
|
2005-02-24 03:12:26 +03:00
|
|
|
ompi_status_empty._cancelled = 0;
|
2004-10-27 01:55:20 +04:00
|
|
|
|
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)
|
|
|
|
{
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
2004-10-12 19:50:01 +04:00
|
|
|
request->req_complete = true;
|
|
|
|
if(ompi_request_waiting)
|
2005-07-04 02:45:48 +04:00
|
|
|
opal_condition_signal(&ompi_request_cond);
|
|
|
|
OPAL_THREAD_UNLOCK(&ompi_request_lock);
|
2004-10-08 21:12:36 +04:00
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
|