2004-11-22 03:37:56 +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.
|
|
|
|
* Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
* 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-11-22 03:37:56 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-10-20 05:03:09 +04:00
|
|
|
#include "ompi_config.h"
|
2004-10-12 19:50:01 +04:00
|
|
|
#include "request/grequest.h"
|
|
|
|
|
|
|
|
|
2004-10-20 02:00:19 +04:00
|
|
|
static int ompi_grequest_free(ompi_request_t** req)
|
2004-10-12 19:50:01 +04:00
|
|
|
{
|
|
|
|
int rc = OMPI_SUCCESS;
|
2004-10-20 02:00:19 +04:00
|
|
|
ompi_grequest_t* greq = *(ompi_grequest_t**)req;
|
2005-03-26 21:49:16 +03:00
|
|
|
if(greq->greq_free.c_free != NULL)
|
|
|
|
rc = greq->greq_free.c_free(greq->greq_state);
|
2004-10-20 02:00:19 +04:00
|
|
|
if(rc == OMPI_SUCCESS) {
|
|
|
|
OBJ_RELEASE(greq);
|
|
|
|
*req = MPI_REQUEST_NULL;
|
|
|
|
}
|
2004-10-12 19:50:01 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ompi_grequest_cancel(ompi_request_t* req, int flag)
|
|
|
|
{
|
|
|
|
int rc = OMPI_SUCCESS;
|
|
|
|
ompi_grequest_t* greq = (ompi_grequest_t*)req;
|
2005-03-26 21:49:16 +03:00
|
|
|
if(greq->greq_cancel.c_cancel != NULL)
|
|
|
|
rc = greq->greq_cancel.c_cancel(greq->greq_state, flag);
|
2004-10-12 19:50:01 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void ompi_grequest_construct(ompi_grequest_t* greq)
|
|
|
|
{
|
|
|
|
OMPI_REQUEST_INIT(&greq->greq_base);
|
2005-03-26 21:49:16 +03:00
|
|
|
greq->greq_base.req_fini = ompi_grequest_free;
|
|
|
|
greq->greq_base.req_free = ompi_grequest_free;
|
|
|
|
greq->greq_base.req_cancel = ompi_grequest_cancel;
|
2004-10-12 19:50:01 +04:00
|
|
|
greq->greq_base.req_type = OMPI_REQUEST_GEN;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ompi_grequest_destruct(ompi_grequest_t* greq)
|
|
|
|
{
|
|
|
|
OMPI_REQUEST_FINI(&greq->greq_base);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
OBJ_CLASS_INSTANCE(
|
|
|
|
ompi_grequest_t,
|
|
|
|
ompi_request_t,
|
|
|
|
ompi_grequest_construct,
|
|
|
|
ompi_grequest_destruct);
|
|
|
|
|
|
|
|
|
|
|
|
int ompi_grequest_start(
|
|
|
|
MPI_Grequest_query_function *gquery_fn,
|
|
|
|
MPI_Grequest_free_function *gfree_fn,
|
|
|
|
MPI_Grequest_cancel_function *gcancel_fn,
|
|
|
|
void* gstate,
|
|
|
|
ompi_request_t** request)
|
|
|
|
{
|
|
|
|
ompi_grequest_t *greq = OBJ_NEW(ompi_grequest_t);
|
|
|
|
if(greq == NULL) {
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
|
|
|
|
greq->greq_state = gstate;
|
2005-03-26 21:49:16 +03:00
|
|
|
greq->greq_query.c_query = gquery_fn;
|
|
|
|
greq->greq_free.c_free = gfree_fn;
|
|
|
|
greq->greq_cancel.c_cancel = gcancel_fn;
|
2004-10-12 19:50:01 +04:00
|
|
|
*request = &greq->greq_base;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-10-20 18:56:52 +04:00
|
|
|
int ompi_grequest_complete(ompi_grequest_t* grequest)
|
|
|
|
{
|
|
|
|
int rc = OMPI_SUCCESS;
|
2005-07-04 02:45:48 +04:00
|
|
|
OPAL_THREAD_LOCK(&ompi_request_lock);
|
2004-10-20 18:56:52 +04:00
|
|
|
grequest->greq_base.req_complete = true;
|
2005-03-26 21:49:16 +03:00
|
|
|
if(grequest->greq_query.c_query != NULL)
|
|
|
|
rc = grequest->greq_query.c_query(grequest->greq_state, &grequest->greq_base.req_status);
|
2004-10-20 18:56:52 +04:00
|
|
|
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-20 18:56:52 +04:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|