[mpich-commits] [mpich] MPICH primary repository branch, master, updated. v3.1rc2-153-g2ce5a7e
mysql vizuser
noreply at mpich.org
Fri Jan 10 22:36:55 CST 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "MPICH primary repository".
The branch, master has been updated
via 2ce5a7e2786fd07ffb13dc4650fc231b7e9ef829 (commit)
via 1a0c3dbc9d8055314613016d5c64f801d9b87219 (commit)
via 99485af86e826a946fe038a77f0b98244526dc4d (commit)
from 3b24d31851794830cb449b03ba09bfc6cf1168f0 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.mpich.org/mpich.git/commitdiff/2ce5a7e2786fd07ffb13dc4650fc231b7e9ef829
commit 2ce5a7e2786fd07ffb13dc4650fc231b7e9ef829
Author: Pavan Balaji <balaji at mcs.anl.gov>
Date: Tue Jan 7 15:02:30 2014 -0600
Prioritize thread-multiple branch.
Give a "likely" attribute to the branch that checks if an MPI process
is initialized in THREAD_MULTIPLE or not. This should reduce the cost
of the branch for applications that require THREAD_MULTIPLE.
The per-object mode in the pamid branch is intended for the case where
comm-threads are used. In this case, the application is mostly in
THREAD_MULTIPLE mode, even if it didn't explicitly initialize it as
such. The only time it'll not be in that mode is during
initialization before the appropriate mutexes have been setup.
See #1900.
Signed-off-by: Michael Blocksome <blocksom at us.ibm.com>
Signed-off-by: Rob Latham <robl at mcs.anl.gov>
diff --git a/src/mpid/pamid/include/mpidi_thread.h b/src/mpid/pamid/include/mpidi_thread.h
index eb31b24..dff875e 100644
--- a/src/mpid/pamid/include/mpidi_thread.h
+++ b/src/mpid/pamid/include/mpidi_thread.h
@@ -107,45 +107,45 @@
#elif MPIU_THREAD_GRANULARITY == MPIU_THREAD_GRANULARITY_PER_OBJECT
-#define MPIDI_CS_ENTER(m) \
- do { \
- MPIU_THREAD_CHECK_BEGIN \
- MPIDI_Mutex_acquire(m); \
- MPIU_THREAD_CHECK_END \
+#define MPIDI_CS_ENTER(m) \
+ do { \
+ if (likely(MPIR_ThreadInfo.isThreaded)) { \
+ MPIDI_Mutex_acquire(m); \
+ } \
} while (0)
-#define MPIDI_CS_EXIT(m) \
- do { \
- MPIU_THREAD_CHECK_BEGIN \
- MPIDI_Mutex_sync(); \
- MPIDI_Mutex_release(m); \
- MPIU_THREAD_CHECK_END \
+#define MPIDI_CS_EXIT(m) \
+ do { \
+ if (likely(MPIR_ThreadInfo.isThreaded)) { \
+ MPIDI_Mutex_sync(); \
+ MPIDI_Mutex_release(m); \
+ } \
} while (0)
-#define MPIDI_CS_YIELD(m) \
- do { \
- MPIU_THREAD_CHECK_BEGIN \
- MPIDI_Mutex_sync(); \
- MPIDI_Mutex_release(m); \
- MPIDI_Mutex_acquire(m); \
- MPIU_THREAD_CHECK_END \
+#define MPIDI_CS_YIELD(m) \
+ do { \
+ if (likely(MPIR_ThreadInfo.isThreaded)) { \
+ MPIDI_Mutex_sync(); \
+ MPIDI_Mutex_release(m); \
+ MPIDI_Mutex_acquire(m); \
+ } \
} while (0)
-#define MPIDI_CS_TRY(m) \
- do { \
- MPIU_THREAD_CHECK_BEGIN \
- MPIDI_Mutex_try_acquire(m); \
- MPIU_THREAD_CHECK_END \
+#define MPIDI_CS_TRY(m) \
+ do { \
+ if (likely(MPIR_ThreadInfo.isThreaded)) { \
+ MPIDI_Mutex_try_acquire(m); \
+ } \
} while (0)
-#define MPIDI_CS_SCHED_YIELD(m) \
- do { \
- MPIU_THREAD_CHECK_BEGIN \
- MPIDI_Mutex_sync(); \
- MPIDI_Mutex_release(m); \
- sched_yield(); \
- MPIDI_Mutex_acquire(m); \
- MPIU_THREAD_CHECK_END \
+#define MPIDI_CS_SCHED_YIELD(m) \
+ do { \
+ if (likely(MPIR_ThreadInfo.isThreaded)) { \
+ MPIDI_Mutex_sync(); \
+ MPIDI_Mutex_release(m); \
+ sched_yield(); \
+ MPIDI_Mutex_acquire(m); \
+ } \
} while (0)
#define MPIU_THREAD_CS_ALLFUNC_ENTER(_context)
http://git.mpich.org/mpich.git/commitdiff/1a0c3dbc9d8055314613016d5c64f801d9b87219
commit 1a0c3dbc9d8055314613016d5c64f801d9b87219
Author: Pavan Balaji <balaji at mcs.anl.gov>
Date: Tue Jan 7 00:40:17 2014 -0600
We always need the runtime thread-safety check.
Disabling runtime check for thread-safety is not a correct option.
This would cause memory allocation and string manipulation routines to
be unusable before the thread-safety level is set. Fixes #1900.
Signed-off-by: Michael Blocksome <blocksom at us.ibm.com>
Signed-off-by: Rob Latham <robl at mcs.anl.gov>
diff --git a/configure.ac b/configure.ac
index 3c27a6b..21fc951 100644
--- a/configure.ac
+++ b/configure.ac
@@ -486,9 +486,6 @@ AC_ARG_WITH(logging,
AC_HELP_STRING([--with-logging=name], [Specify the logging library for MPICH]),
[if test -z "$withval" ; then with_logging=rlog ; fi],with_logging=none)
-dnl The default option needs to be defined in terms of a specific choice
-dnl (runtime in this case). Note that the default choice is the same as
-dnl runtime only for certain devices - not for every device.
AC_ARG_ENABLE(threads,
[ --enable-threads=level - Control the level of thread support in the
MPICH implementation. The following levels
@@ -496,14 +493,8 @@ AC_ARG_ENABLE(threads,
single - No threads (MPI_THREAD_SINGLE)
funneled - Only the main thread calls MPI (MPI_THREAD_FUNNELED)
serialized - User serializes calls to MPI (MPI_THREAD_SERIALIZED)
- runtime - The level of thread support is determined by
- the arguments to MPI_Init_thread, with
- MPI_THREAD_MULTIPLE available. The default option
- for many communication devices.
- multiple - Fully multi-threaded (MPI_THREAD_MULTIPLE) always.
- DO NOT select this option. The option runtime is more
- efficient and also supports thread_multiple.
- (multiple aliased to runtime now)
+ multiple - Fully multi-threaded (MPI_THREAD_MULTIPLE)
+ runtime - Alias to "multiple"
See also the --enable-thread-cs option for controlling the granularity of
the concurrency inside of the library
@@ -1278,7 +1269,10 @@ fi
#
# Threads must be supported by the device. First, set the default to
# be the highest supported by the device
+# "runtime" was an old (now deprecated) option; just map it to multiple
+if test "$enable_threads" = "runtime" ; then enable_threads=multiple ; fi
if test "$enable_threads" = "yes" ; then enable_threads=default ; fi
+if test "$enable_threads" = "no" ; then enable_threads=single ; fi
if test "$enable_threads" = default ; then
# XXX DJG bug is here, PREREQ is not being used right now
if test -n "$MPID_MAX_THREAD_LEVEL" ; then
@@ -1286,7 +1280,7 @@ if test "$enable_threads" = default ; then
MPI_THREAD_SINGLE) enable_threads=single ;;
MPI_THREAD_FUNNELED) enable_threads=funneled ;;
MPI_THREAD_SERIALIZED) enable_threads=serialized ;;
- MPI_THREAD_MULTIPLE) enable_threads=runtime ;;
+ MPI_THREAD_MULTIPLE) enable_threads=multiple ;;
*) AC_MSG_ERROR([Unrecognized thread level from device $MPID_MAX_THREAD_LEVEL])
;;
esac
@@ -1295,18 +1289,6 @@ if test "$enable_threads" = default ; then
fi
fi
-if test "$enable_threads" = "default" ; then
- enable_threads=runtime
-elif test "$enable_threads" = "no" ; then
- enable_threads=single
-fi
-
-# Runtime is an alias for multiple with an additional value
-if test "$enable_threads" = "runtime" ; then
- AC_DEFINE(HAVE_RUNTIME_THREADCHECK,1,[Define if MPI supports MPI_THREAD_MULTIPLE with a runtime check for thread level])
- enable_threads=multiple
-fi
-
MPICH_THREAD_LEVEL=MPI_THREAD_FUNNELED
case "$enable_threads" in
single)
diff --git a/src/include/mpiimplthread.h b/src/include/mpiimplthread.h
index 1f81e33..f0141c6 100644
--- a/src/include/mpiimplthread.h
+++ b/src/include/mpiimplthread.h
@@ -72,10 +72,11 @@ typedef struct MPICH_ThreadInfo_t {
# endif /* !TLS */
MPID_Thread_id_t master_thread; /* Thread that started MPI */
#endif
-#ifdef HAVE_RUNTIME_THREADCHECK
+
+#if defined MPICH_IS_THREADED
int isThreaded; /* Set to true if user requested
THREAD_MULTIPLE */
-#endif
+#endif /* MPICH_IS_THREADED */
/* Define the mutex values used for each kind of implementation */
#if MPIU_THREAD_GRANULARITY == MPIU_THREAD_GRANULARITY_GLOBAL || \
@@ -107,11 +108,6 @@ extern MPICH_ThreadInfo_t MPIR_ThreadInfo;
#else /* defined(MPICH_IS_THREADED) */
-/* We want to avoid the overhead of the thread call if we're in the
- runtime state and threads are not in use. In that case, MPIR_Thread
- is still a pointer but it was already allocated in InitThread */
-#ifdef HAVE_RUNTIME_THREADCHECK
-
#define MPIU_THREAD_CHECK_BEGIN if (MPIR_ThreadInfo.isThreaded) {
#define MPIU_THREAD_CHECK_END }
/* This macro used to take an argument of one or more statements that
@@ -124,14 +120,6 @@ extern MPICH_ThreadInfo_t MPIR_ThreadInfo;
* completely eliminate unnecessary if's. */
#define MPIU_ISTHREADED (MPIR_ThreadInfo.isThreaded)
-#else /* !defined(HAVE_RUNTIME_THREADCHECK) */
-
-#define MPIU_THREAD_CHECK_BEGIN
-#define MPIU_THREAD_CHECK_END
-#define MPIU_ISTHREADED (1)
-
-#endif /* HAVE_RUNTIME_THREADCHECK */
-
#endif /* MPICH_IS_THREADED */
/* ------------------------------------------------------------------------- */
@@ -218,7 +206,6 @@ extern MPICH_PerThread_t MPIR_Thread;
void MPIR_CleanupThreadStorage(void *a);
#if !defined(MPIU_TLS_SPECIFIER)
-# if defined(HAVE_RUNTIME_THREADCHECK)
/* In the case where the thread level is set in MPI_Init_thread, we
need a blended version of the non-threaded and the thread-multiple
definitions.
@@ -268,36 +255,6 @@ extern MPICH_PerThread_t MPIR_ThreadSingle;
} \
} while (0)
-# else /* unconditional thread multiple */
-
-/* We initialize the MPIR_Thread pointer to null so that we need call the
- * routine to get the thread-private storage only once in an invocation of a
- * routine. */
-#define MPIU_THREADPRIV_INITKEY \
- do { \
- int err_; \
- MPID_Thread_tls_create(MPIR_CleanupThreadStorage,&MPIR_ThreadInfo.thread_storage,&err_); \
- MPIU_Assert(err_ == 0); \
- } while (0)
-#define MPIU_THREADPRIV_INIT \
- do { \
- MPIR_Thread = (MPICH_PerThread_t *) MPIU_Calloc(1, sizeof(MPICH_PerThread_t)); \
- MPIU_Assert(MPIR_Thread); \
- MPID_Thread_tls_set(&MPIR_ThreadInfo.thread_storage, (void *)MPIR_Thread); \
- } while (0)
-#define MPIU_THREADPRIV_GET \
- do { \
- if (!MPIR_Thread) { \
- MPID_Thread_tls_get(&MPIR_ThreadInfo.thread_storage, &MPIR_Thread); \
- if (!MPIR_Thread) { \
- MPIU_THREADPRIV_INIT; /* subtle, sets MPIR_Thread */ \
- } \
- MPIU_Assert(MPIR_Thread); \
- } \
- } while (0)
-
-# endif /* runtime vs. unconditional */
-
/* common definitions when using MPID_Thread-based TLS */
#define MPIU_THREADPRIV_DECL MPICH_PerThread_t *MPIR_Thread=NULL
#define MPIU_THREADPRIV_FIELD(a_) (MPIR_Thread->a_)
diff --git a/src/include/mpitimpl.h b/src/include/mpitimpl.h
index d7c3844..8de41f8 100644
--- a/src/include/mpitimpl.h
+++ b/src/include/mpitimpl.h
@@ -1363,14 +1363,9 @@ static inline int MPIR_T_is_initialized() {
extern void MPIR_T_strncpy(char *dst, const char *src, int *len);
/* Stuffs to support multithreaded MPI_T */
-#ifdef HAVE_RUNTIME_THREADCHECK
extern int MPIR_T_is_threaded;
#define MPIR_T_THREAD_CHECK_BEGIN if (MPIR_T_is_threaded) {
#define MPIR_T_THREAD_CHECK_END }
-#else /* !HAVE_RUNTIME_THREADCHECK */
-#define MPIR_T_THREAD_CHECK_BEGIN
-#define MPIR_T_THREAD_CHECK_END
-#endif
#ifdef MPICH_IS_THREADED
extern MPIU_Thread_mutex_t mpi_t_mutex;
diff --git a/src/mpi/init/init.c b/src/mpi/init/init.c
index f9d1c9a..a5af3da 100644
--- a/src/mpi/init/init.c
+++ b/src/mpi/init/init.c
@@ -146,12 +146,9 @@ int MPI_Init( int *argc, char ***argv )
* mutexes are not initialized yet, and we don't want to
* accidentally use them before they are initialized. We will
* reset this value once it is properly initialized. */
- /* FIXME: This only works when runtime thread-safety is enabled.
- * When we use configure-time thread-levels, we might still have a
- * problem. */
-#ifdef HAVE_RUNTIME_THREADCHECK
+#if defined MPICH_IS_THREADED
MPIR_ThreadInfo.isThreaded = 0;
-#endif
+#endif /* MPICH_IS_THREADED */
MPIR_T_env_init();
diff --git a/src/mpi/init/initthread.c b/src/mpi/init/initthread.c
index 98ca462..231e214 100644
--- a/src/mpi/init/initthread.c
+++ b/src/mpi/init/initthread.c
@@ -160,7 +160,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
MPICH_PerThread_t MPIR_Thread = { 0 };
#elif defined(MPIU_TLS_SPECIFIER)
MPIU_TLS_SPECIFIER MPICH_PerThread_t MPIR_Thread = { 0 };
-#elif defined(HAVE_RUNTIME_THREADCHECK)
+#else
/* If we may be single threaded, we need a preallocated version to use
if we are single threaded case */
MPICH_PerThread_t MPIR_ThreadSingle = { 0 };
@@ -302,9 +302,9 @@ int MPIR_Init_thread(int * argc, char ***argv, int required, int * provided)
/* For any code in the device that wants to check for runtime
decisions on the value of isThreaded, set a provisional
value here. We could let the MPID_Init routine override this */
-#ifdef HAVE_RUNTIME_THREADCHECK
+#if defined MPICH_IS_THREADED
MPIR_ThreadInfo.isThreaded = required == MPI_THREAD_MULTIPLE;
-#endif
+#endif /* MPICH_IS_THREADED */
MPIU_THREAD_CS_INIT;
@@ -479,9 +479,9 @@ int MPIR_Init_thread(int * argc, char ***argv, int required, int * provided)
/* Capture the level of thread support provided */
MPIR_ThreadInfo.thread_provided = thread_provided;
if (provided) *provided = thread_provided;
-#ifdef HAVE_RUNTIME_THREADCHECK
+#if defined MPICH_IS_THREADED
MPIR_ThreadInfo.isThreaded = (thread_provided == MPI_THREAD_MULTIPLE);
-#endif
+#endif /* MPICH_IS_THREADED */
/* FIXME: Define these in the interface. Does Timer init belong here? */
MPIU_dbg_init(MPIR_Process.comm_world->rank);
@@ -618,12 +618,9 @@ int MPI_Init_thread( int *argc, char ***argv, int required, int *provided )
* mutexes are not initialized yet, and we don't want to
* accidentally use them before they are initialized. We will
* reset this value once it is properly initialized. */
- /* FIXME: This only works when runtime thread-safety is enabled.
- * When we use configure-time thread-levels, we might still have a
- * problem. */
-#ifdef HAVE_RUNTIME_THREADCHECK
+#if defined MPICH_IS_THREADED
MPIR_ThreadInfo.isThreaded = 0;
-#endif
+#endif /* MPICH_IS_THREADED */
MPIR_T_env_init();
diff --git a/src/mpi_t/mpit.c b/src/mpi_t/mpit.c
index 2d580de..62f602c 100644
--- a/src/mpi_t/mpit.c
+++ b/src/mpi_t/mpit.c
@@ -10,9 +10,6 @@ int MPIR_T_init_balance = 0;
#ifdef MPICH_IS_THREADED
MPIU_Thread_mutex_t mpi_t_mutex;
-#endif
-
-#ifdef HAVE_RUNTIME_THREADCHECK
int MPIR_T_is_threaded;
#endif
diff --git a/src/mpi_t/mpit_initthread.c b/src/mpi_t/mpit_initthread.c
index 23ab02e..1e7fcba 100644
--- a/src/mpi_t/mpit_initthread.c
+++ b/src/mpi_t/mpit_initthread.c
@@ -118,9 +118,9 @@ int MPI_T_init_thread(int required, int *provided)
/* ... body of routine ... */
-#ifdef HAVE_RUNTIME_THREADCHECK
+#if defined MPICH_IS_THREADED
MPIR_T_is_threaded = (required == MPI_THREAD_MULTIPLE);
-#endif
+#endif /* MPICH_IS_THREADED */
if (provided != NULL) {
/* This must be min(required,MPICH_THREAD_LEVEL) if runtime
diff --git a/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h b/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h
index f702e1f..7f21c6d 100644
--- a/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h
+++ b/src/mpid/ch3/channels/nemesis/include/mpid_nem_inline.h
@@ -878,11 +878,7 @@ MPID_nem_mpich_blocking_recv(MPID_nem_cell_ptr_t *cell, int *in_fbox, int comple
#ifdef MPICH_IS_THREADED
/* We should never enter this function in a multithreaded app */
-#ifdef HAVE_RUNTIME_THREADCHECK
MPIU_Assert(!MPIR_ThreadInfo.isThreaded);
-#else
- MPIU_Assert(0);
-#endif
#endif
#ifdef USE_FASTBOX
diff --git a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
index 7e9cf28..785476a 100644
--- a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
@@ -350,11 +350,7 @@ int MPIDI_CH3I_Progress (MPID_Progress_state *progress_state, int is_blocking)
/* check queue */
if (MPID_nem_safe_to_block_recv() && is_blocking
#ifdef MPICH_IS_THREADED
-#ifdef HAVE_RUNTIME_THREADCHECK
&& !MPIR_ThreadInfo.isThreaded
-#else
- && 0
-#endif
#endif
)
{
diff --git a/src/mpid/ch3/channels/sock/src/ch3_progress.c b/src/mpid/ch3/channels/sock/src/ch3_progress.c
index 0311856..fec55f7 100644
--- a/src/mpid/ch3/channels/sock/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/sock/src/ch3_progress.c
@@ -188,7 +188,6 @@ static int MPIDI_CH3i_Progress_wait(MPID_Progress_state * progress_state)
/* The logic for this case is just complicated enough that
we write separate code for each possibility */
-# ifdef HAVE_RUNTIME_THREADCHECK
if (MPIR_ThreadInfo.isThreaded) {
MPIDI_CH3I_progress_blocked = TRUE;
mpi_errno = MPIDU_Sock_wait(MPIDI_CH3I_sock_set,
@@ -200,13 +199,6 @@ static int MPIDI_CH3i_Progress_wait(MPID_Progress_state * progress_state)
mpi_errno = MPIDU_Sock_wait(MPIDI_CH3I_sock_set,
MPIDU_SOCK_INFINITE_TIME, &event);
}
-# else
- MPIDI_CH3I_progress_blocked = TRUE;
- mpi_errno = MPIDU_Sock_wait(MPIDI_CH3I_sock_set,
- MPIDU_SOCK_INFINITE_TIME, &event);
- MPIDI_CH3I_progress_blocked = FALSE;
- MPIDI_CH3I_progress_wakeup_signalled = FALSE;
-# endif /* HAVE_RUNTIME_THREADCHECK */
# else
mpi_errno = MPIDU_Sock_wait(MPIDI_CH3I_sock_set,
diff --git a/src/mpid/common/sock/poll/sock_wait.i b/src/mpid/common/sock/poll/sock_wait.i
index 393e71a..7a7e85d 100644
--- a/src/mpid/common/sock/poll/sock_wait.i
+++ b/src/mpid/common/sock/poll/sock_wait.i
@@ -118,7 +118,6 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
just use the same code as above. Otherwise, use
multithreaded code (and we don't then need the
MPIU_THREAD_CHECK_BEGIN/END macros) */
-#ifdef HAVE_RUNTIME_THREADCHECK
if (!MPIR_ThreadInfo.isThreaded) {
MPIDI_FUNC_ENTER(MPID_STATE_POLL);
n_fds = poll(sock_set->pollfds, sock_set->poll_array_elems,
@@ -126,7 +125,6 @@ int MPIDU_Sock_wait(struct MPIDU_Sock_set * sock_set, int millisecond_timeout,
MPIDI_FUNC_EXIT(MPID_STATE_POLL);
}
else
-#endif
{
/*
* First try a non-blocking poll to see if any immediate
diff --git a/src/mpid/pamid/include/mpidi_thread.h b/src/mpid/pamid/include/mpidi_thread.h
index aaa1c2f..eb31b24 100644
--- a/src/mpid/pamid/include/mpidi_thread.h
+++ b/src/mpid/pamid/include/mpidi_thread.h
@@ -46,9 +46,6 @@
#if (MPICH_THREAD_LEVEL != MPI_THREAD_MULTIPLE)
#error MPICH_THREAD_LEVEL should be MPI_THREAD_MULTIPLE
#endif
-#ifndef HAVE_RUNTIME_THREADCHECK
-#error Need HAVE_RUNTIME_THREADCHECK
-#endif
#define MPIU_THREAD_CS_INIT ({ MPIDI_Mutex_initialize(); })
#define MPIU_THREAD_CS_FINALIZE
http://git.mpich.org/mpich.git/commitdiff/99485af86e826a946fe038a77f0b98244526dc4d
commit 99485af86e826a946fe038a77f0b98244526dc4d
Author: Pavan Balaji <balaji at mcs.anl.gov>
Date: Tue Jan 7 04:58:42 2014 +0000
Thread critical-section initialization fixes.
This patch has two related parts.
1. We initialize the isThreaded runtime check to FALSE before doing
the cvar checks. This is because the cvar initialization uses memory
allocation and string duping, which internally use mutexes. But the
mutexes are not initialized yet, so disabling isThreaded would make
sure we don't use them.
2. Updates to the pamid device to respect the isThreaded variable.
This is needed since we were initializing cvars before setting the
thread-level, so the thread-safety macros are not initialized at that
point. See #1900.
Signed-off-by: Michael Blocksome <blocksom at us.ibm.com>
Signed-off-by: Rob Latham <robl at mcs.anl.gov>
diff --git a/src/mpi/init/init.c b/src/mpi/init/init.c
index 56a87d0..f9d1c9a 100644
--- a/src/mpi/init/init.c
+++ b/src/mpi/init/init.c
@@ -142,6 +142,17 @@ int MPI_Init( int *argc, char ***argv )
/* ... body of routine ... */
+ /* Temporarily disable thread-safety. This is needed because the
+ * mutexes are not initialized yet, and we don't want to
+ * accidentally use them before they are initialized. We will
+ * reset this value once it is properly initialized. */
+ /* FIXME: This only works when runtime thread-safety is enabled.
+ * When we use configure-time thread-levels, we might still have a
+ * problem. */
+#ifdef HAVE_RUNTIME_THREADCHECK
+ MPIR_ThreadInfo.isThreaded = 0;
+#endif
+
MPIR_T_env_init();
if (!strcmp(MPIR_CVAR_DEFAULT_THREAD_LEVEL, "MPI_THREAD_MULTIPLE"))
diff --git a/src/mpi/init/initthread.c b/src/mpi/init/initthread.c
index 3ebe996..98ca462 100644
--- a/src/mpi/init/initthread.c
+++ b/src/mpi/init/initthread.c
@@ -614,6 +614,17 @@ int MPI_Init_thread( int *argc, char ***argv, int required, int *provided )
/* ... body of routine ... */
+ /* Temporarily disable thread-safety. This is needed because the
+ * mutexes are not initialized yet, and we don't want to
+ * accidentally use them before they are initialized. We will
+ * reset this value once it is properly initialized. */
+ /* FIXME: This only works when runtime thread-safety is enabled.
+ * When we use configure-time thread-levels, we might still have a
+ * problem. */
+#ifdef HAVE_RUNTIME_THREADCHECK
+ MPIR_ThreadInfo.isThreaded = 0;
+#endif
+
MPIR_T_env_init();
/* If the user requested for asynchronous progress, request for
diff --git a/src/mpid/pamid/include/mpidi_thread.h b/src/mpid/pamid/include/mpidi_thread.h
index 5f3fb7e..aaa1c2f 100644
--- a/src/mpid/pamid/include/mpidi_thread.h
+++ b/src/mpid/pamid/include/mpidi_thread.h
@@ -50,7 +50,6 @@
#error Need HAVE_RUNTIME_THREADCHECK
#endif
-
#define MPIU_THREAD_CS_INIT ({ MPIDI_Mutex_initialize(); })
#define MPIU_THREAD_CS_FINALIZE
@@ -111,19 +110,55 @@
#elif MPIU_THREAD_GRANULARITY == MPIU_THREAD_GRANULARITY_PER_OBJECT
-#define MPIDI_CS_ENTER(m) ({ MPIDI_Mutex_acquire(m); })
-#define MPIDI_CS_EXIT(m) ({ MPIDI_Mutex_sync(); MPIDI_Mutex_release(m); })
-#define MPIDI_CS_YIELD(m) ({ MPIDI_Mutex_sync(); MPIDI_Mutex_release(m); MPIDI_Mutex_acquire(m); })
-#define MPIDI_CS_TRY(m) ({ (0==MPIDI_Mutex_try_acquire(m)); })
-#define MPIDI_CS_SCHED_YIELD(m) ({ MPIDI_Mutex_sync(); MPIDI_Mutex_release(m); sched_yield(); MPIDI_Mutex_acquire(m); })
+#define MPIDI_CS_ENTER(m) \
+ do { \
+ MPIU_THREAD_CHECK_BEGIN \
+ MPIDI_Mutex_acquire(m); \
+ MPIU_THREAD_CHECK_END \
+ } while (0)
+
+#define MPIDI_CS_EXIT(m) \
+ do { \
+ MPIU_THREAD_CHECK_BEGIN \
+ MPIDI_Mutex_sync(); \
+ MPIDI_Mutex_release(m); \
+ MPIU_THREAD_CHECK_END \
+ } while (0)
+
+#define MPIDI_CS_YIELD(m) \
+ do { \
+ MPIU_THREAD_CHECK_BEGIN \
+ MPIDI_Mutex_sync(); \
+ MPIDI_Mutex_release(m); \
+ MPIDI_Mutex_acquire(m); \
+ MPIU_THREAD_CHECK_END \
+ } while (0)
+
+#define MPIDI_CS_TRY(m) \
+ do { \
+ MPIU_THREAD_CHECK_BEGIN \
+ MPIDI_Mutex_try_acquire(m); \
+ MPIU_THREAD_CHECK_END \
+ } while (0)
+
+#define MPIDI_CS_SCHED_YIELD(m) \
+ do { \
+ MPIU_THREAD_CHECK_BEGIN \
+ MPIDI_Mutex_sync(); \
+ MPIDI_Mutex_release(m); \
+ sched_yield(); \
+ MPIDI_Mutex_acquire(m); \
+ MPIU_THREAD_CHECK_END \
+ } while (0)
#define MPIU_THREAD_CS_ALLFUNC_ENTER(_context)
#define MPIU_THREAD_CS_ALLFUNC_EXIT(_context)
#define MPIU_THREAD_CS_ALLFUNC_YIELD(_context)
#define MPIU_THREAD_CS_ALLFUNC_SCHED_YIELD(_context)
#define MPIU_THREAD_CS_ALLFUNC_TRY(_context) (0)
-#define MPIU_THREAD_CS_INIT_ENTER(_context) MPIDI_Mutex_acquire(0)
-#define MPIU_THREAD_CS_INIT_EXIT(_context) MPIDI_Mutex_release(0)
+
+#define MPIU_THREAD_CS_INIT_ENTER(_context) MPIDI_CS_ENTER(0)
+#define MPIU_THREAD_CS_INIT_EXIT(_context) MPIDI_CS_EXIT(0)
#define MPIU_THREAD_CS_CONTEXTID_ENTER(_context) MPIDI_CS_ENTER(0)
#define MPIU_THREAD_CS_CONTEXTID_EXIT(_context) MPIDI_CS_EXIT (0)
-----------------------------------------------------------------------
Summary of changes:
configure.ac | 30 ++---------
src/include/mpiimplthread.h | 49 +-----------------
src/include/mpitimpl.h | 5 --
src/mpi/init/init.c | 8 +++
src/mpi/init/initthread.c | 18 +++++--
src/mpi_t/mpit.c | 3 -
src/mpi_t/mpit_initthread.c | 4 +-
.../ch3/channels/nemesis/include/mpid_nem_inline.h | 4 --
src/mpid/ch3/channels/nemesis/src/ch3_progress.c | 4 --
src/mpid/ch3/channels/sock/src/ch3_progress.c | 8 ---
src/mpid/common/sock/poll/sock_wait.i | 2 -
src/mpid/pamid/include/mpidi_thread.h | 54 ++++++++++++++++----
12 files changed, 75 insertions(+), 114 deletions(-)
hooks/post-receive
--
MPICH primary repository
More information about the commits
mailing list