|
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_init_thread */
|
|
Packit Service |
c5cf8c |
#if defined(HAVE_PRAGMA_WEAK)
|
|
Packit Service |
c5cf8c |
#pragma weak MPI_T_init_thread = PMPI_T_init_thread
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
|
|
Packit Service |
c5cf8c |
#pragma _HP_SECONDARY_DEF PMPI_T_init_thread MPI_T_init_thread
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_PRAGMA_CRI_DUP)
|
|
Packit Service |
c5cf8c |
#pragma _CRI duplicate MPI_T_init_thread as PMPI_T_init_thread
|
|
Packit Service |
c5cf8c |
#elif defined(HAVE_WEAK_ATTRIBUTE)
|
|
Packit Service |
c5cf8c |
int MPI_T_init_thread(int required, int *provided)
|
|
Packit Service |
c5cf8c |
__attribute__ ((weak, alias("PMPI_T_init_thread")));
|
|
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_init_thread
|
|
Packit Service |
c5cf8c |
#define MPI_T_init_thread PMPI_T_init_thread
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* any non-MPI functions go here, especially non-static ones */
|
|
Packit Service |
c5cf8c |
static inline void MPIR_T_enum_env_init(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
static const UT_icd enum_table_entry_icd = { sizeof(MPIR_T_enum_t), NULL, NULL, NULL };
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
utarray_new(enum_table, &enum_table_entry_icd, MPL_MEM_MPIT);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static inline void MPIR_T_cat_env_init(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
static const UT_icd cat_table_entry_icd = { sizeof(cat_table_entry_t), NULL, NULL, NULL };
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
utarray_new(cat_table, &cat_table_entry_icd, MPL_MEM_MPIT);
|
|
Packit Service |
c5cf8c |
cat_hash = NULL;
|
|
Packit Service |
c5cf8c |
cat_stamp = 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static inline void MPIR_T_cvar_env_init(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
static const UT_icd cvar_table_entry_icd = { sizeof(cvar_table_entry_t), NULL, NULL, NULL };
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
utarray_new(cvar_table, &cvar_table_entry_icd, MPL_MEM_MPIT);
|
|
Packit Service |
c5cf8c |
cvar_hash = NULL;
|
|
Packit Service |
c5cf8c |
MPIR_T_cvar_init();
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static inline void MPIR_T_pvar_env_init(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int i;
|
|
Packit Service |
c5cf8c |
static const UT_icd pvar_table_entry_icd = { sizeof(pvar_table_entry_t), NULL, NULL, NULL };
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
utarray_new(pvar_table, &pvar_table_entry_icd, MPL_MEM_MPIT);
|
|
Packit Service |
c5cf8c |
for (i = 0; i < MPIR_T_PVAR_CLASS_NUMBER; i++) {
|
|
Packit Service |
c5cf8c |
pvar_hashs[i] = NULL;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
void MPIR_T_env_init(void)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
static int initialized = FALSE;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (!initialized) {
|
|
Packit Service |
c5cf8c |
initialized = TRUE;
|
|
Packit Service |
c5cf8c |
MPIR_T_enum_env_init();
|
|
Packit Service |
c5cf8c |
MPIR_T_cat_env_init();
|
|
Packit Service |
c5cf8c |
MPIR_T_cvar_env_init();
|
|
Packit Service |
c5cf8c |
MPIR_T_pvar_env_init();
|
|
Packit Service |
c5cf8c |
}
|
|
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_init_thread
|
|
Packit Service |
c5cf8c |
#undef FCNAME
|
|
Packit Service |
c5cf8c |
#define FCNAME MPL_QUOTE(FUNCNAME)
|
|
Packit Service |
c5cf8c |
/*@
|
|
Packit Service |
c5cf8c |
MPI_T_init_thread - Initialize the MPI_T execution environment
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Input Parameters:
|
|
Packit Service |
c5cf8c |
. required - desired level of thread support (integer)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Output Parameters:
|
|
Packit Service |
c5cf8c |
. provided - provided level of thread support (integer)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
Notes:
|
|
Packit Service |
c5cf8c |
The valid values for the level of thread support are:
|
|
Packit Service |
c5cf8c |
+ MPI_THREAD_SINGLE - Only one thread will execute.
|
|
Packit Service |
c5cf8c |
. MPI_THREAD_FUNNELED - The process may be multi-threaded, but only the main
|
|
Packit Service |
c5cf8c |
thread will make MPI_T calls (all MPI_T calls are funneled to the
|
|
Packit Service |
c5cf8c |
main thread).
|
|
Packit Service |
c5cf8c |
. MPI_THREAD_SERIALIZED - The process may be multi-threaded, and multiple
|
|
Packit Service |
c5cf8c |
threads may make MPI_T calls, but only one at a time: MPI_T calls are not
|
|
Packit Service |
c5cf8c |
made concurrently from two distinct threads (all MPI_T calls are serialized).
|
|
Packit Service |
c5cf8c |
- MPI_THREAD_MULTIPLE - Multiple threads may call MPI_T, with no restrictions.
|
|
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 |
|
|
Packit Service |
c5cf8c |
.seealso MPI_T_finalize
|
|
Packit Service |
c5cf8c |
@*/
|
|
Packit Service |
c5cf8c |
int MPI_T_init_thread(int required, int *provided)
|
|
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_INIT_THREAD);
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_ENTER(MPID_STATE_MPI_T_INIT_THREAD);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if defined MPICH_IS_THREADED
|
|
Packit Service |
c5cf8c |
MPIR_T_is_threaded = (required == MPI_THREAD_MULTIPLE);
|
|
Packit Service |
c5cf8c |
#endif /* MPICH_IS_THREADED */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (provided != NULL) {
|
|
Packit Service |
c5cf8c |
/* This must be min(required,MPICH_THREAD_LEVEL) if runtime
|
|
Packit Service |
c5cf8c |
* control of thread level is available */
|
|
Packit Service |
c5cf8c |
*provided = (MPICH_THREAD_LEVEL < required) ? MPICH_THREAD_LEVEL : required;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
++MPIR_T_init_balance;
|
|
Packit Service |
c5cf8c |
if (MPIR_T_init_balance == 1) {
|
|
Packit Service |
c5cf8c |
MPIR_T_THREAD_CS_INIT();
|
|
Packit Service |
c5cf8c |
MPIR_T_env_init();
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* ... end of body of routine ... */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPIR_FUNC_TERSE_EXIT(MPID_STATE_MPI_T_INIT_THREAD);
|
|
Packit Service |
c5cf8c |
return mpi_errno;
|
|
Packit Service |
c5cf8c |
}
|