|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2011 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 |
#include "utlist.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* -- Begin Profiling Symbol Block for routine MPI_T_pvar_stop */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_T_pvar_stop = PMPI_T_pvar_stop
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_T_pvar_stop MPI_T_pvar_stop
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_T_pvar_stop as PMPI_T_pvar_stop
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_T_pvar_stop(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPI_T_pvar_stop")));
|
|
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 MPI_T_pvar_stop
|
|
Packit Service |
c5cf8c |
#define MPI_T_pvar_stop PMPI_T_pvar_stop
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* any non-MPI functions go here, especially non-static ones */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPIR_T_pvar_stop_impl
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
int MPIR_T_pvar_stop_impl(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int i, mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
MPIR_T_pvar_watermark_t *mark;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_T_pvar_unset_started(handle);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Side-effect when pvar is SUM or WATERMARK */
|
|
Packit Service |
c5cf8c |
if (MPIR_T_pvar_is_sum(handle)) {
|
|
Packit Service |
c5cf8c |
/* Read the current value first */
|
|
Packit Service |
c5cf8c |
if (handle->get_value == NULL) {
|
|
Packit Service |
c5cf8c |
MPIR_Memcpy(handle->current, handle->addr, handle->bytes * handle->count);
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
handle->get_value(handle->addr, handle->obj_handle, handle->count, handle->current);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Substract offset from current, and accumulate the result to accum */
|
|
Packit Service |
c5cf8c |
switch (handle->datatype) {
|
|
Packit Service |
c5cf8c |
case MPI_UNSIGNED_LONG_LONG:
|
|
Packit Service |
c5cf8c |
for (i = 0; i < handle->count; i++) {
|
|
Packit Service |
c5cf8c |
((unsigned long long *) handle->accum)[i] +=
|
|
Packit Service |
c5cf8c |
((unsigned long long *) handle->current)[i]
|
|
Packit Service |
c5cf8c |
- ((unsigned long long *) handle->offset)[i];
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPI_DOUBLE:
|
|
Packit Service |
c5cf8c |
for (i = 0; i < handle->count; i++) {
|
|
Packit Service |
c5cf8c |
((double *) handle->accum)[i] += ((double *) handle->current)[i]
|
|
Packit Service |
c5cf8c |
- ((double *) handle->offset)[i];
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPI_UNSIGNED:
|
|
Packit Service |
c5cf8c |
for (i = 0; i < handle->count; i++) {
|
|
Packit Service |
c5cf8c |
((unsigned *) handle->accum)[i] += ((unsigned *) handle->current)[i]
|
|
Packit Service |
c5cf8c |
- ((unsigned *) handle->offset)[i];
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
case MPI_UNSIGNED_LONG:
|
|
Packit Service |
c5cf8c |
for (i = 0; i < handle->count; i++) {
|
|
Packit Service |
c5cf8c |
((unsigned long *) handle->accum)[i] += ((unsigned long *) handle->current)[i]
|
|
Packit Service |
c5cf8c |
- ((unsigned long *) handle->offset)[i];
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
default:
|
|
Packit Service |
c5cf8c |
/* Code should never come here */
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_ERR_INTERN;
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
break;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
} else if (MPIR_T_pvar_is_watermark(handle)) {
|
|
Packit Service |
c5cf8c |
/* When handle is first, clear the flag in pvar too */
|
|
Packit Service |
c5cf8c |
if (MPIR_T_pvar_is_first(handle)) {
|
|
Packit Service |
c5cf8c |
mark = (MPIR_T_pvar_watermark_t *) handle->addr;
|
|
Packit Service |
c5cf8c |
MPIR_Assert(mark->first_used);
|
|
Packit Service |
c5cf8c |
mark->first_started = FALSE;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
fn_exit:
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
fn_fail:
|
|
Packit Service |
c5cf8c |
goto fn_exit;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#endif /* MPICH_MPI_FROM_PMPI */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#undef FUNCNAME
|
|
Packit Service |
c5cf8c |
#define FUNCNAME MPI_T_pvar_stop
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
/*@
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_stop - Stop a performance variable
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
+ session - identifier of performance experiment session (handle)
|
|
Packit Service |
c5cf8c |
- handle - handle of a performance variable (handle)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Notes:
|
|
Packit Service |
c5cf8c |
This functions stops the performance variable with the handle identified by the parameter
|
|
Packit Service |
c5cf8c |
handle in the session identified by the parameter session.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
If the constant MPI_T_PVAR_ALL_HANDLES is passed in handle, the MPI implementation
|
|
Packit Service |
c5cf8c |
attempts to stop all variables within the session identified by the parameter session for
|
|
Packit Service |
c5cf8c |
which handles have been allocated. In this case, the routine returns MPI_SUCCESS if all
|
|
Packit Service |
c5cf8c |
variables are stopped successfully, otherwise MPI_T_ERR_PVAR_NO_STARTSTOP is returned.
|
|
Packit Service |
c5cf8c |
Continuous variables and variables that are already stopped are ignored when
|
|
Packit Service |
c5cf8c |
MPI_T_PVAR_ALL_HANDLES is specified.
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N ThreadSafe
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
.N Errors
|
|
Packit Service |
c5cf8c |
.N MPI_SUCCESS
|
|
Packit Service |
c5cf8c |
.N MPI_T_ERR_NOT_INITIALIZED
|
|
Packit Service |
c5cf8c |
.N MPI_T_ERR_INVALID_SESSION
|
|
Packit Service |
c5cf8c |
.N MPI_T_ERR_INVALID_HANDLE
|
|
Packit Service |
c5cf8c |
.N MPI_T_ERR_PVAR_NO_STARTSTOP
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_T_pvar_stop(MPI_T_pvar_session session, MPI_T_pvar_handle handle)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int mpi_errno = MPI_SUCCESS;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_STATE_DECL(MPID_STATE_MPI_T_PVAR_STOP);
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
|
|
Packit Service |
c5cf8c |
MPIR_T_THREAD_CS_ENTER();
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPI_T_PVAR_STOP);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Validate parameters, especially handles needing to be converted */
|
|
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_PVAR_SESSION(session, mpi_errno);
|
|
Packit Service |
c5cf8c |
MPIR_ERRTEST_PVAR_HANDLE(handle, 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 |
/* If handle is MPI_T_PVAR_ALL_HANDLES, dispatch the call.
|
|
Packit Service |
c5cf8c |
* Otherwise, do correctness check, then go to impl.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
if (handle == MPI_T_PVAR_ALL_HANDLES) {
|
|
Packit Service |
c5cf8c |
MPIR_T_pvar_handle_t *hnd;
|
|
Packit Service |
c5cf8c |
DL_FOREACH(session->hlist, hnd) {
|
|
Packit Service |
c5cf8c |
if (!MPIR_T_pvar_is_continuous(hnd) && MPIR_T_pvar_is_started(hnd)) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_T_pvar_stop_impl(session, hnd);
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
} else {
|
|
Packit Service |
c5cf8c |
if (handle->session != session) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_T_ERR_INVALID_HANDLE;
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (MPIR_T_pvar_is_continuous(handle)) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_T_ERR_PVAR_NO_STARTSTOP;
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (MPIR_T_pvar_is_started(handle)) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPIR_T_pvar_stop_impl(session, handle);
|
|
Packit Service |
c5cf8c |
if (mpi_errno != MPI_SUCCESS)
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
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_T_PVAR_STOP);
|
|
Packit Service |
c5cf8c |
MPIR_T_THREAD_CS_EXIT();
|
|
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_t_pvar_stop", "**mpi_t_pvar_stop %p %p", session, handle);
|
|
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 |
}
|