2004-01-29 05:50:02 +03:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2006-08-24 20:38:08 +04:00
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. 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"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/request/request.h"
|
|
|
|
#include "ompi/constants.h"
|
2004-01-29 05:50:02 +03:00
|
|
|
|
2005-11-10 03:45:27 +03:00
|
|
|
ompi_pointer_array_t ompi_request_f_to_c_table;
|
2006-08-24 20:38:08 +04:00
|
|
|
size_t ompi_request_waiting = 0;
|
|
|
|
size_t ompi_request_completed = 0;
|
|
|
|
opal_mutex_t ompi_request_lock;
|
|
|
|
opal_condition_t ompi_request_cond;
|
|
|
|
ompi_request_t ompi_request_null;
|
|
|
|
ompi_request_t ompi_request_empty;
|
2005-11-10 03:45:27 +03: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
|
|
|
{
|
2006-03-16 01:53:41 +03:00
|
|
|
OMPI_REQUEST_INIT(req, false);
|
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
|
|
|
{
|
2006-03-16 01:53:41 +03:00
|
|
|
assert( MPI_UNDEFINED == req->req_f_to_c_index );
|
|
|
|
assert( OMPI_REQUEST_INVALID == req->req_state );
|
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,
|
2006-06-12 20:44:00 +04:00
|
|
|
ompi_free_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;
|
|
|
|
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
|
2006-03-16 01:53:41 +03:00
|
|
|
* req_free function, which resets the
|
2005-07-27 21:25:12 +04:00
|
|
|
* 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_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)
|
|
|
|
{
|
2006-03-16 01:53:41 +03:00
|
|
|
OMPI_REQUEST_FINI( &ompi_request_null );
|
|
|
|
OBJ_DESTRUCT( &ompi_request_null );
|
|
|
|
OMPI_REQUEST_FINI( &ompi_request_empty );
|
|
|
|
OBJ_DESTRUCT( &ompi_request_empty );
|
|
|
|
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);
|
2005-11-10 03:45:27 +03:00
|
|
|
ompi_request_completed++;
|
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
|
|
|
|