|
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 |
|
|
Packit Service |
c5cf8c |
/* -- Begin Profiling Symbol Block for routine MPI_T_finalize */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_T_finalize = PMPI_T_finalize
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_T_finalize MPI_T_finalize
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_T_finalize as PMPI_T_finalize
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_T_finalize(void) __attribute__ ((weak, alias("PMPI_T_finalize")));
|
|
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_finalize
|
|
Packit Service |
c5cf8c |
#define MPI_T_finalize PMPI_T_finalize
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* any non-MPI functions go here, especially non-static ones */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static void MPIR_T_enum_env_finalize(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
unsigned int i, j;
|
|
Packit Service |
c5cf8c |
MPIR_T_enum_t *e;
|
|
Packit Service |
c5cf8c |
enum_item_t *item;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (enum_table) {
|
|
Packit Service |
c5cf8c |
/* Free all entries */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < utarray_len(enum_table); i++) {
|
|
Packit Service |
c5cf8c |
e = (MPIR_T_enum_t *) utarray_eltptr(enum_table, i);
|
|
Packit Service |
c5cf8c |
MPL_free((void *) e->name);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Free items in this enum */
|
|
Packit Service |
c5cf8c |
for (j = 0; j < utarray_len(e->items); j++) {
|
|
Packit Service |
c5cf8c |
item = (enum_item_t *) utarray_eltptr(e->items, j);
|
|
Packit Service |
c5cf8c |
MPL_free((void *) item->name);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
utarray_free(e->items);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Free enum_table itself */
|
|
Packit Service |
c5cf8c |
utarray_free(enum_table);
|
|
Packit Service |
c5cf8c |
enum_table = NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static void MPIR_T_cat_env_finalize(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
unsigned int i;
|
|
Packit Service |
c5cf8c |
cat_table_entry_t *cat;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (cat_table) {
|
|
Packit Service |
c5cf8c |
/* Free all entries */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < utarray_len(cat_table); i++) {
|
|
Packit Service |
c5cf8c |
cat = (cat_table_entry_t *) utarray_eltptr(cat_table, i);
|
|
Packit Service |
c5cf8c |
MPL_free((void *) cat->name);
|
|
Packit Service |
c5cf8c |
MPL_free((void *) cat->desc);
|
|
Packit Service |
c5cf8c |
utarray_free(cat->cvar_indices);
|
|
Packit Service |
c5cf8c |
utarray_free(cat->pvar_indices);
|
|
Packit Service |
c5cf8c |
utarray_free(cat->subcat_indices);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Free cat_table itself */
|
|
Packit Service |
c5cf8c |
utarray_free(cat_table);
|
|
Packit Service |
c5cf8c |
cat_table = NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (cat_hash) {
|
|
Packit Service |
c5cf8c |
name2index_hash_t *current, *tmp;
|
|
Packit Service |
c5cf8c |
/* Free all entries */
|
|
Packit Service |
c5cf8c |
HASH_ITER(hh, cat_hash, current, tmp) {
|
|
Packit Service |
c5cf8c |
HASH_DEL(cat_hash, current);
|
|
Packit Service |
c5cf8c |
MPL_free(current);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Free cat_hash itself */
|
|
Packit Service |
c5cf8c |
HASH_CLEAR(hh, cat_hash);
|
|
Packit Service |
c5cf8c |
cat_hash = NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static void MPIR_T_cvar_env_finalize(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
unsigned int i;
|
|
Packit Service |
c5cf8c |
cvar_table_entry_t *cvar;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_T_cvar_finalize();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (cvar_table) {
|
|
Packit Service |
c5cf8c |
/* Free all entries */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < utarray_len(cvar_table); i++) {
|
|
Packit Service |
c5cf8c |
cvar = (cvar_table_entry_t *) utarray_eltptr(cvar_table, i);
|
|
Packit Service |
c5cf8c |
MPL_free((void *) cvar->name);
|
|
Packit Service |
c5cf8c |
MPL_free((void *) cvar->desc);
|
|
Packit Service |
c5cf8c |
if (cvar->datatype == MPI_CHAR)
|
|
Packit Service |
c5cf8c |
MPL_free(cvar->addr);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Free pvar_table itself */
|
|
Packit Service |
c5cf8c |
utarray_free(cvar_table);
|
|
Packit Service |
c5cf8c |
cvar_table = NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (cvar_hash) {
|
|
Packit Service |
c5cf8c |
name2index_hash_t *current, *tmp;
|
|
Packit Service |
c5cf8c |
/* Free all entries */
|
|
Packit Service |
c5cf8c |
HASH_ITER(hh, cvar_hash, current, tmp) {
|
|
Packit Service |
c5cf8c |
HASH_DEL(cvar_hash, current);
|
|
Packit Service |
c5cf8c |
MPL_free(current);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Free cvar_hash itself */
|
|
Packit Service |
c5cf8c |
HASH_CLEAR(hh, cvar_hash);
|
|
Packit Service |
c5cf8c |
cvar_hash = NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static void MPIR_T_pvar_env_finalize(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
unsigned int i;
|
|
Packit Service |
c5cf8c |
pvar_table_entry_t *pvar;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (pvar_table) {
|
|
Packit Service |
c5cf8c |
/* Free all entries */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < utarray_len(pvar_table); i++) {
|
|
Packit Service |
c5cf8c |
pvar = (pvar_table_entry_t *) utarray_eltptr(pvar_table, i);
|
|
Packit Service |
c5cf8c |
MPL_free((void *) pvar->name);
|
|
Packit Service |
c5cf8c |
MPL_free((void *) pvar->desc);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Free pvar_table itself */
|
|
Packit Service |
c5cf8c |
utarray_free(pvar_table);
|
|
Packit Service |
c5cf8c |
pvar_table = NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
for (i = 0; i < MPIR_T_PVAR_CLASS_NUMBER; i++) {
|
|
Packit Service |
c5cf8c |
if (pvar_hashs[i]) {
|
|
Packit Service |
c5cf8c |
name2index_hash_t *current, *tmp;
|
|
Packit Service |
c5cf8c |
/* Free all entries */
|
|
Packit Service |
c5cf8c |
HASH_ITER(hh, pvar_hashs[i], current, tmp) {
|
|
Packit Service |
c5cf8c |
HASH_DEL(pvar_hashs[i], current);
|
|
Packit Service |
c5cf8c |
MPL_free(current);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Free pvar_hashs[i] itself */
|
|
Packit Service |
c5cf8c |
HASH_CLEAR(hh, pvar_hashs[i]);
|
|
Packit Service |
c5cf8c |
pvar_hashs[i] = NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
void MPIR_T_env_finalize(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPIR_T_enum_env_finalize();
|
|
Packit Service |
c5cf8c |
MPIR_T_cvar_env_finalize();
|
|
Packit Service |
c5cf8c |
MPIR_T_pvar_env_finalize();
|
|
Packit Service |
c5cf8c |
MPIR_T_cat_env_finalize();
|
|
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_finalize
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
/*@
|
|
Packit Service |
c5cf8c |
MPI_T_finalize - Finalize the MPI tool information interface
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Notes:
|
|
Packit Service |
c5cf8c |
This routine may be called as often as the corresponding MPI_T_init_thread() routine
|
|
Packit Service |
c5cf8c |
up to the current point of execution. Calling it more times returns a corresponding
|
|
Packit Service |
c5cf8c |
error code. As long as the number of calls to MPI_T_finalize() is smaller than the
|
|
Packit Service |
c5cf8c |
number of calls to MPI_T_init_thread() up to the current point of execution, the MPI
|
|
Packit Service |
c5cf8c |
tool information interface remains initialized and calls to its routines are permissible.
|
|
Packit Service |
c5cf8c |
Further, additional calls to MPI_T_init_thread() after one or more calls to MPI_T_finalize()
|
|
Packit Service |
c5cf8c |
are permissible. Once MPI_T_finalize() is called the same number of times as the routine
|
|
Packit Service |
c5cf8c |
MPI_T_init_thread() up to the current point of execution, the MPI tool information
|
|
Packit Service |
c5cf8c |
interface is no longer initialized. The interface can be reinitialized by subsequent calls
|
|
Packit Service |
c5cf8c |
to MPI_T_init_thread().
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
At the end of the program execution, unless MPI_Abort() is called, an application must
|
|
Packit Service |
c5cf8c |
have called MPI_T_init_thread() and MPI_T_finalize() an equal number of times.
|
|
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 |
|
|
Packit Service |
c5cf8c |
.seealso MPI_T_init_thread
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_T_finalize(void)
|
|
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_FINALIZE);
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPI_T_FINALIZE);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
--MPIR_T_init_balance;
|
|
Packit Service |
c5cf8c |
if (MPIR_T_init_balance < 0) {
|
|
Packit Service |
c5cf8c |
mpi_errno = MPI_T_ERR_NOT_INITIALIZED;
|
|
Packit Service |
c5cf8c |
goto fn_fail;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (MPIR_T_init_balance == 0) {
|
|
Packit Service |
c5cf8c |
MPIR_T_THREAD_CS_FINALIZE();
|
|
Packit Service |
c5cf8c |
MPIR_T_env_finalize();
|
|
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_FINALIZE);
|
|
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_finalize", NULL);
|
|
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 |
}
|