|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpiimpl.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* -- Begin Profiling Symbol Block for routine MPI_Grequest_start */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_Grequest_start = PMPI_Grequest_start
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_Grequest_start MPI_Grequest_start
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_Grequest_start as PMPI_Grequest_start
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_Grequest_start(MPI_Grequest_query_function * query_fn, MPI_Grequest_free_function * free_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_cancel_function * cancel_fn, void *extra_state,
|
|
Packit Service |
c5cf8c |
MPI_Request * request) __attribute__ ((weak, alias("PMPI_Grequest_start")));
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
/* -- End Profiling Symbol Block */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
PMPI_LOCAL int MPIR_Grequest_free_classes_on_finalize(void *extra_data);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
|
|
Packit Service |
c5cf8c |
the MPI routines. You can use USE_WEAK_SYMBOLS to see if MPICH is
|
|
Packit Service |
c5cf8c |
using weak symbols to implement the MPI routines. */
|
|
Packit Service |
c5cf8c |
#ifndef MPICH_MPI_FROM_PMPI
|
|
Packit Service |
c5cf8c |
#undef MPI_Grequest_start
|
|
Packit Service |
c5cf8c |
#define MPI_Grequest_start PMPI_Grequest_start
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* preallocated grequest classes */
|
|
Packit Service |
c5cf8c |
#ifndef MPIR_GREQ_CLASS_PREALLOC
|
|
Packit Service |
c5cf8c |
#define MPIR_GREQ_CLASS_PREALLOC 2
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_class MPIR_Grequest_class_direct[MPIR_GREQ_CLASS_PREALLOC] = { {0} };
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_Object_alloc_t MPIR_Grequest_class_mem = { 0, 0, 0, 0, MPIR_GREQ_CLASS,
|
|
Packit Service |
c5cf8c |
sizeof(MPIR_Grequest_class),
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_class_direct,
|
|
Packit Service |
c5cf8c |
MPIR_GREQ_CLASS_PREALLOC,
|
|
Packit Service |
c5cf8c |
};
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* We jump through some minor hoops to manage the list of classes ourselves and
|
|
Packit Service |
c5cf8c |
* only register a single finalizer to avoid hitting limitations in the current
|
|
Packit Service |
c5cf8c |
* finalizer code. If the finalizer implementation is ever revisited this code
|
|
Packit Service |
c5cf8c |
* is a good candidate for registering one callback per greq class and trimming
|
|
Packit Service |
c5cf8c |
* some of this logic. */
|
|
Packit Service |
c5cf8c |
int MPIR_Grequest_registered_finalizer = 0;
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_class *MPIR_Grequest_class_list = NULL;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Any internal routines can go here. Make them static if possible. If they
|
|
Packit Service |
c5cf8c |
are used by both the MPI and PMPI versions, use PMPI_LOCAL instead of
|
|
Packit Service |
c5cf8c |
static; this macro expands into "static" if weak symbols are supported and
|
|
Packit Service |
c5cf8c |
into nothing otherwise. */
|
|
Packit Service |
c5cf8c |
PMPI_LOCAL int MPIR_Grequest_free_classes_on_finalize(void *extra_data ATTRIBUTE((unused)))
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_class *last = NULL;
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_class *cur = MPIR_Grequest_class_list;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* FIXME MT this function is not thread safe when using fine-grained threading */
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_class_list = NULL;
|
|
Packit Service |
c5cf8c |
while (cur) {
|
|
Packit Service |
c5cf8c |
last = cur;
|
|
Packit Service |
c5cf8c |
cur = last->next;
|
|
Packit Service |
c5cf8c |
MPIR_Handle_obj_free(&MPIR_Grequest_class_mem, last);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPIR_Grequest_start
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
int MPIR_Grequest_start(MPI_Grequest_query_function * query_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_free_function * free_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_cancel_function * cancel_fn,
|
|
Packit Service |
c5cf8c |
void *extra_state, MPIR_Request ** request_ptr)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
MPIR_CHKPMEM_DECL(1);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* MT FIXME this routine is not thread-safe in the non-global case */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
*request_ptr = MPIR_Request_create(MPIR_REQUEST_KIND__GREQUEST);
|
|
Packit Service |
c5cf8c |
MPIR_ERR_CHKANDJUMP1(*request_ptr == NULL, mpi_errno, MPI_ERR_OTHER, "**nomem", "**nomem %s",
|
|
Packit Service |
c5cf8c |
"generalized request");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_Object_set_ref(*request_ptr, 1);
|
|
Packit Service |
c5cf8c |
(*request_ptr)->cc_ptr = &(*request_ptr)->cc;
|
|
Packit Service |
c5cf8c |
MPIR_cc_set((*request_ptr)->cc_ptr, 1);
|
|
Packit Service |
c5cf8c |
(*request_ptr)->comm = NULL;
|
|
Packit Service |
c5cf8c |
MPIR_CHKPMEM_MALLOC((*request_ptr)->u.ureq.greq_fns, struct MPIR_Grequest_fns *,
|
|
Packit Service |
c5cf8c |
sizeof(struct MPIR_Grequest_fns), mpi_errno, "greq_fns", MPL_MEM_GREQ);
|
|
Packit Service |
c5cf8c |
(*request_ptr)->u.ureq.greq_fns->cancel_fn = cancel_fn;
|
|
Packit Service |
c5cf8c |
(*request_ptr)->u.ureq.greq_fns->free_fn = free_fn;
|
|
Packit Service |
c5cf8c |
(*request_ptr)->u.ureq.greq_fns->query_fn = query_fn;
|
|
Packit Service |
c5cf8c |
(*request_ptr)->u.ureq.greq_fns->poll_fn = NULL;
|
|
Packit Service |
c5cf8c |
(*request_ptr)->u.ureq.greq_fns->wait_fn = NULL;
|
|
Packit Service |
c5cf8c |
(*request_ptr)->u.ureq.greq_fns->grequest_extra_state = extra_state;
|
|
Packit Service |
c5cf8c |
(*request_ptr)->u.ureq.greq_fns->greq_lang = MPIR_LANG__C;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Add an additional reference to the greq. One of them will be
|
|
Packit Service |
c5cf8c |
* released when we complete the request, and the second one, when
|
|
Packit Service |
c5cf8c |
* we test or wait on it. */
|
|
Packit Service |
c5cf8c |
MPIR_Request_add_ref((*request_ptr));
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_CHKPMEM_COMMIT();
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
MPIR_CHKPMEM_REAP();
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
extern MPIR_Grequest_class MPIR_Grequest_class_direct[];
|
|
Packit Service |
c5cf8c |
extern MPIR_Object_alloc_t MPIR_Grequest_class_mem;
|
|
Packit Service |
c5cf8c |
extern int MPIR_Grequest_registered_finalizer;
|
|
Packit Service |
c5cf8c |
extern MPIR_Grequest_class *MPIR_Grequest_class_list;
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPI_Grequest_start
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
/*@
|
|
Packit Service |
c5cf8c |
MPI_Grequest_start - Create and return a user-defined request
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
+ query_fn - callback function invoked when request status is queried (function)
|
|
Packit Service |
c5cf8c |
. free_fn - callback function invoked when request is freed (function)
|
|
Packit Service |
c5cf8c |
. cancel_fn - callback function invoked when request is cancelled (function)
|
|
Packit Service |
c5cf8c |
- extra_state - Extra state passed to the above functions.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Output Parameters:
|
|
Packit Service |
c5cf8c |
. request - Generalized request (handle)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Notes on the callback functions:
|
|
Packit Service |
c5cf8c |
The return values from the callback functions must be a valid MPI error code
|
|
Packit Service |
c5cf8c |
or class. This value may either be the return value from any MPI routine
|
|
Packit Service |
c5cf8c |
(with one exception noted below) or any of the MPI error classes.
|
|
Packit Service |
c5cf8c |
For portable programs, 'MPI_ERR_OTHER' may be used; to provide more
|
|
Packit Service |
c5cf8c |
specific information, create a new MPI error class or code with
|
|
Packit Service |
c5cf8c |
'MPI_Add_error_class' or 'MPI_Add_error_code' and return that value.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
The MPI standard is not clear on the return values from the callback routines.
|
|
Packit Service |
c5cf8c |
However, there are notes in the standard that imply that these are MPI error
|
|
Packit Service |
c5cf8c |
codes. For example, pages 169 line 46 through page 170, line 1 require that
|
|
Packit Service |
c5cf8c |
the 'free_fn' return an MPI error code that may be used in the MPI completion
|
|
Packit Service |
c5cf8c |
functions when they return 'MPI_ERR_IN_STATUS'.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
The one special case is the error value returned by 'MPI_Comm_dup' when
|
|
Packit Service |
c5cf8c |
the attribute callback routine returns a failure. The MPI standard is not
|
|
Packit Service |
c5cf8c |
clear on what values may be used to indicate an error return. Further,
|
|
Packit Service |
c5cf8c |
the Intel MPI test suite made use of non-zero values to indicate failure,
|
|
Packit Service |
c5cf8c |
and expected these values to be returned by the 'MPI_Comm_dup' when the
|
|
Packit Service |
c5cf8c |
attribute routines encountered an error. Such error values may not be valid
|
|
Packit Service |
c5cf8c |
MPI error codes or classes. Because of this, it is the user''s responsibility
|
|
Packit Service |
c5cf8c |
to either use valid MPI error codes in return from the attribute callbacks,
|
|
Packit Service |
c5cf8c |
if those error codes are to be returned by a generalized request callback,
|
|
Packit Service |
c5cf8c |
or to detect and convert those error codes to valid MPI error codes (recall
|
|
Packit Service |
c5cf8c |
that MPI error classes are valid error codes).
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N ThreadSafe
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N Fortran
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N Errors
|
|
Packit Service |
c5cf8c |
.N MPI_SUCCESS
|
|
Packit Service |
c5cf8c |
.N MPI_ERR_ARG
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_Grequest_start(MPI_Grequest_query_function * query_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_free_function * free_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_cancel_function * cancel_fn,
|
|
Packit Service |
c5cf8c |
void *extra_state, MPI_Request * request)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
MPIR_Request *request_ptr;
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_GREQUEST_START);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_INITIALIZED_ORDIE();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPID_THREAD_CS_ENTER(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPI_GREQUEST_START);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Validate parameters if error checking is enabled */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPID_BEGIN_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_ARGNULL(request, "request", mpi_errno);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPID_END_ERROR_CHECKS;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif /* HAVE_ERROR_CHECKING */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Grequest_start(query_fn, free_fn, cancel_fn, extra_state, &request_ptr);
|
|
Packit Service |
c5cf8c |
if (mpi_errno)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_OBJ_PUBLISH_HANDLE(*request, request_ptr->handle);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... end of body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPI_GREQUEST_START);
|
|
Packit Service |
c5cf8c |
MPID_THREAD_CS_EXIT(GLOBAL, MPIR_THREAD_GLOBAL_ALLFUNC_MUTEX);
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
mpi_errno =
|
|
Packit Service |
c5cf8c |
MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
|
|
Packit Service |
c5cf8c |
"**mpi_grequest_start", "**mpi_grequest_start %p %p %p %p %p",
|
|
Packit Service |
c5cf8c |
query_fn, free_fn, cancel_fn, extra_state, request);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_return_comm(NULL, FCNAME, mpi_errno);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* -- Begin Profiling Symbol Block for routine MPIX_Grequest_class_create*/
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPIX_Grequest_class_create = PMPIX_Grequest_class_create
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPIX_Grequest_class_create MPIX_Grequest_class_create
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPIX_Grequest_class_create as PMPIX_Grequest_class_create
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPIX_Grequest_class_create(MPI_Grequest_query_function * query_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_free_function * free_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_cancel_function * cancel_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_poll_function * poll_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_wait_function * wait_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_class * greq_class)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPIX_Grequest_class_create")));
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
/* -- End Profiling Symbol Block */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
|
|
Packit Service |
c5cf8c |
the MPI routines */
|
|
Packit Service |
c5cf8c |
#ifndef MPICH_MPI_FROM_PMPI
|
|
Packit Service |
c5cf8c |
#undef MPIX_Grequest_class_create
|
|
Packit Service |
c5cf8c |
#define MPIX_Grequest_class_create PMPIX_Grequest_class_create
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPIX_Grequest_class_create
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
/* extensions for Generalized Request redesign paper */
|
|
Packit Service |
c5cf8c |
int MPIX_Grequest_class_create(MPI_Grequest_query_function * query_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_free_function * free_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_cancel_function * cancel_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_poll_function * poll_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_wait_function * wait_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_class * greq_class)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_class *class_ptr;
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
class_ptr = (MPIR_Grequest_class *)
|
|
Packit Service |
c5cf8c |
MPIR_Handle_obj_alloc(&MPIR_Grequest_class_mem);
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
if (!class_ptr) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_create_code(MPI_SUCCESS,
|
|
Packit Service |
c5cf8c |
MPIR_ERR_RECOVERABLE, FCNAME, __LINE__,
|
|
Packit Service |
c5cf8c |
MPI_ERR_OTHER, "**nomem",
|
|
Packit Service |
c5cf8c |
"**nomem %s", "MPIX_Grequest_class");
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
class_ptr->query_fn = query_fn;
|
|
Packit Service |
c5cf8c |
class_ptr->free_fn = free_fn;
|
|
Packit Service |
c5cf8c |
class_ptr->cancel_fn = cancel_fn;
|
|
Packit Service |
c5cf8c |
class_ptr->poll_fn = poll_fn;
|
|
Packit Service |
c5cf8c |
class_ptr->wait_fn = wait_fn;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_Object_set_ref(class_ptr, 1);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (MPIR_Grequest_class_list == NULL) {
|
|
Packit Service |
c5cf8c |
class_ptr->next = NULL;
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
class_ptr->next = MPIR_Grequest_class_list;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_class_list = class_ptr;
|
|
Packit Service |
c5cf8c |
if (!MPIR_Grequest_registered_finalizer) {
|
|
Packit Service |
c5cf8c |
/* must run before (w/ higher priority than) the handle check
|
|
Packit Service |
c5cf8c |
* finalizer in order avoid being flagged as a leak */
|
|
Packit Service |
c5cf8c |
MPIR_Add_finalize(&MPIR_Grequest_free_classes_on_finalize,
|
|
Packit Service |
c5cf8c |
NULL, MPIR_FINALIZE_CALLBACK_HANDLE_CHECK_PRIO + 1);
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_registered_finalizer = 1;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_OBJ_PUBLISH_HANDLE(*greq_class, class_ptr->handle);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... end of body of routine ... */
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
/* --BEGIN ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_ERROR_CHECKING
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
mpi_errno =
|
|
Packit Service |
c5cf8c |
MPIR_Err_create_code(mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
|
|
Packit Service |
c5cf8c |
"**mpix_grequest_class_create",
|
|
Packit Service |
c5cf8c |
"**mpix_grequest_class_create %p %p %p %p %p", query_fn, free_fn,
|
|
Packit Service |
c5cf8c |
cancel_fn, poll_fn, wait_fn);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Err_return_comm(0, FCNAME, mpi_errno);
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
/* --END ERROR HANDLING-- */
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* -- Begin Profiling Symbol Block for routine MPIX_Grequest_class_allocate */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPIX_Grequest_class_allocate = PMPIX_Grequest_class_allocate
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPIX_Grequest_class_allocate MPIX_Grequest_class_allocate
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPIX_Grequest_class_allocate as PMPIX_Grequest_class_allocate
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPIX_Grequest_class_allocate(MPIX_Grequest_class greq_class, void *extra_state,
|
|
Packit Service |
c5cf8c |
MPI_Request * request)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPIX_Grequest_class_allocate")));
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
/* -- End Profiling Symbol Block */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
|
|
Packit Service |
c5cf8c |
the MPI routines */
|
|
Packit Service |
c5cf8c |
#ifndef MPICH_MPI_FROM_PMPI
|
|
Packit Service |
c5cf8c |
#undef MPIX_Grequest_class_allocate
|
|
Packit Service |
c5cf8c |
#define MPIX_Grequest_class_allocate PMPIX_Grequest_class_allocate
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPIX_Grequest_class_allocate
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int MPIX_Grequest_class_allocate(MPIX_Grequest_class greq_class,
|
|
Packit Service |
c5cf8c |
void *extra_state, MPI_Request * request)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno;
|
|
Packit Service |
c5cf8c |
MPIR_Request *lrequest_ptr;
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_class *class_ptr;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
*request = MPI_REQUEST_NULL;
|
|
Packit Service |
c5cf8c |
MPIR_Grequest_class_get_ptr(greq_class, class_ptr);
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Grequest_start(class_ptr->query_fn, class_ptr->free_fn,
|
|
Packit Service |
c5cf8c |
class_ptr->cancel_fn, extra_state, &lrequest_ptr);
|
|
Packit Service |
c5cf8c |
if (mpi_errno == MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
*request = lrequest_ptr->handle;
|
|
Packit Service |
c5cf8c |
lrequest_ptr->u.ureq.greq_fns->poll_fn = class_ptr->poll_fn;
|
|
Packit Service |
c5cf8c |
lrequest_ptr->u.ureq.greq_fns->wait_fn = class_ptr->wait_fn;
|
|
Packit Service |
c5cf8c |
lrequest_ptr->u.ureq.greq_fns->greq_class = greq_class;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* -- Begin Profiling Symbol Block for routine MPIX_Grequest_start */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPIX_Grequest_start = PMPIX_Grequest_start
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPIX_Grequest_start MPIX_Grequest_start
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPIX_Grequest_start as PMPIX_Grequest_start
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPIX_Grequest_start(MPI_Grequest_query_function * query_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_free_function * free_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_cancel_function * cancel_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_poll_function * poll_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_wait_function * wait_fn,
|
|
Packit Service |
c5cf8c |
void *extra_state, MPI_Request * request)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPIX_Grequest_start")));
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
/* -- End Profiling Symbol Block */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
|
|
Packit Service |
c5cf8c |
the MPI routines */
|
|
Packit Service |
c5cf8c |
#ifndef MPICH_MPI_FROM_PMPI
|
|
Packit Service |
c5cf8c |
#undef MPIX_Grequest_start
|
|
Packit Service |
c5cf8c |
#define MPIX_Grequest_start PMPIX_Grequest_start
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPIX_Grequest_start
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int MPIX_Grequest_start(MPI_Grequest_query_function * query_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_free_function * free_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_cancel_function * cancel_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_poll_function * poll_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_wait_function * wait_fn,
|
|
Packit Service |
c5cf8c |
void *extra_state, MPI_Request * request)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno;
|
|
Packit Service |
c5cf8c |
MPIR_Request *lrequest_ptr;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
*request = MPI_REQUEST_NULL;
|
|
Packit Service |
c5cf8c |
mpi_errno =
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_start_impl(query_fn, free_fn, cancel_fn, poll_fn, wait_fn, extra_state,
|
|
Packit Service |
c5cf8c |
&lrequest_ptr);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (mpi_errno == MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
*request = lrequest_ptr->handle;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifndef MPICH_MPI_FROM_PMPI
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPIX_Grequest_start_impl
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
int MPIX_Grequest_start_impl(MPI_Grequest_query_function * query_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_free_function * free_fn,
|
|
Packit Service |
c5cf8c |
MPI_Grequest_cancel_function * cancel_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_poll_function * poll_fn,
|
|
Packit Service |
c5cf8c |
MPIX_Grequest_wait_function * wait_fn,
|
|
Packit Service |
c5cf8c |
void *extra_state, MPIR_Request ** request)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_Grequest_start(query_fn, free_fn, cancel_fn, extra_state, request);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (mpi_errno == MPI_SUCCESS) {
|
|
Packit Service |
c5cf8c |
(*request)->u.ureq.greq_fns->poll_fn = poll_fn;
|
|
Packit Service |
c5cf8c |
(*request)->u.ureq.greq_fns->wait_fn = wait_fn;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif /* MPICH_MPI_FROM_PMPI */
|