commits
Threads by month
- ----- 2026 -----
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
August 2015
- 1 participants
- 51 discussions
[mpich] MPICH primary repository branch, master, updated. v3.2b4-102-ga79f688
by noreply@mpich.org 11 Aug '15
by noreply@mpich.org 11 Aug '15
11 Aug '15
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 a79f6888751553bb7804b6858ebfd8d5f0df4851 (commit)
via 70b0e0d7ccee74aaff912c99419476bec14e2e82 (commit)
via 688f9f9e24b042cff5de99904325a384d8e46c1d (commit)
via 98d4b47ab463e3371c372e6621a72ca244d547bf (commit)
from 4551de14b1d752a9c7be49df4a9e70776addd02f (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/a79f6888751553bb7804b6858ebfd8d5f…
commit a79f6888751553bb7804b6858ebfd8d5f0df4851
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Tue Aug 11 14:14:02 2015 -0500
Add Progress_activate/de-activate_hook routines.
Here we add Progress_activate/de-activate_hook routines,
which activate / de-activate a progress hook specified by
corresponding id.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_impl.h b/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_impl.h
index a3b4d81..bef6b72 100644
--- a/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_impl.h
+++ b/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_impl.h
@@ -52,6 +52,8 @@ int MPIDI_CH3I_Progress_init(void);
int MPIDI_CH3I_Progress_finalize(void);
int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*), int *id);
int MPIDI_CH3I_Progress_deregister_hook(int id);
+int MPIDI_CH3I_Progress_activate_hook(int id);
+int MPIDI_CH3I_Progress_deactivate_hook(int id);
int MPIDI_CH3I_Shm_send_progress(void);
int MPIDI_CH3I_Complete_sendq_with_error(MPIDI_VC_t * vc);
diff --git a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
index 8ece505..e65f82c 100644
--- a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
@@ -86,8 +86,14 @@ static qn_ent_t *qn_head = NULL;
#define MAX_PROGRESS_HOOKS 16
typedef int (*progress_func_ptr_t) (int* made_progress);
-static progress_func_ptr_t progress_hooks[MAX_PROGRESS_HOOKS] = { NULL };
-static int total_progress_hook_cnt = 0; /* Keep track of how many progress hooks are currently registered */
+
+typedef struct progress_hook_slot {
+ progress_func_ptr_t func_ptr;
+ int active;
+} progress_hook_slot_t;
+
+static progress_hook_slot_t progress_hooks[MAX_PROGRESS_HOOKS];
+static int total_progress_hook_cnt = 0; /* Keep track of how many progress hooks are currently activated */
#ifdef HAVE_SIGNAL
static void sigusr1_handler(int sig)
@@ -301,12 +307,9 @@ int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*), int *id)
MPIU_THREAD_CS_ENTER(MPIDCOMM,);
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] == NULL) {
- progress_hooks[i] = progress_fn;
-
- total_progress_hook_cnt++;
- MPIU_Assert(total_progress_hook_cnt <= MAX_PROGRESS_HOOKS);
-
+ if (progress_hooks[i].func_ptr == NULL) {
+ progress_hooks[i].func_ptr = progress_fn;
+ progress_hooks[i].active = FALSE;
break;
}
}
@@ -340,16 +343,72 @@ int MPIDI_CH3I_Progress_deregister_hook(int id)
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_DEREGISTER_HOOK);
MPIU_THREAD_CS_ENTER(MPIDCOMM,);
- MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS && progress_hooks[id] != NULL);
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS && progress_hooks[id].func_ptr != NULL);
+
+ progress_hooks[id].func_ptr = NULL;
+ progress_hooks[id].active = FALSE;
+
+ fn_exit:
+ MPIU_THREAD_CS_EXIT(MPIDCOMM,);
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_DEREGISTER_HOOK);
+ return mpi_errno;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDI_CH3I_Progress_activate_hook
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIDI_CH3I_Progress_activate_hook(int id)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_ACTIVATE_HOOK);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_ACTIVATE_HOOK);
+ MPIU_THREAD_CS_ENTER(MPIDCOMM,);
+
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS &&
+ progress_hooks[id].active == FALSE && progress_hooks[id].func_ptr != NULL);
+ progress_hooks[id].active = TRUE;
- progress_hooks[id] = NULL;
+ total_progress_hook_cnt++;
+ MPIU_Assert(total_progress_hook_cnt <= MAX_PROGRESS_HOOKS);
+
+ fn_exit:
+ MPIU_THREAD_CS_EXIT(MPIDCOMM,);
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_ACTIVATE_HOOK);
+ return mpi_errno;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDI_CH3I_Progress_deactivate_hook
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIDI_CH3I_Progress_deactivate_hook(int id)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_DEACTIVATE_HOOK);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_DEACTIVATE_HOOK);
+ MPIU_THREAD_CS_ENTER(MPIDCOMM,);
+
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS &&
+ progress_hooks[id].active == TRUE && progress_hooks[id].func_ptr != NULL);
+ progress_hooks[id].active = FALSE;
total_progress_hook_cnt--;
MPIU_Assert(total_progress_hook_cnt >= 0);
fn_exit:
MPIU_THREAD_CS_EXIT(MPIDCOMM,);
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_DEREGISTER_HOOK);
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_DEACTIVATE_HOOK);
return mpi_errno;
fn_fail:
@@ -542,8 +601,9 @@ int MPIDI_CH3I_Progress (MPID_Progress_state *progress_state, int is_blocking)
called_progress_hook_cnt = 0;
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] != NULL) {
- mpi_errno = progress_hooks[i](&made_progress);
+ if (progress_hooks[i].active == TRUE) {
+ MPIU_Assert(progress_hooks[i].func_ptr != NULL);
+ mpi_errno = progress_hooks[i].func_ptr(&made_progress);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
if (made_progress)
MPIDI_CH3_Progress_signal_completion();
@@ -894,6 +954,7 @@ int MPID_nem_handle_pkt(MPIDI_VC_t *vc, char *buf, MPIDI_msg_sz_t buflen)
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIDI_CH3I_Progress_init(void)
{
+ int i;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_INIT);
@@ -942,6 +1003,12 @@ int MPIDI_CH3I_Progress_init(void)
prev_sighandler = NULL;
#endif
+ /* Initialize progress hook slots */
+ for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
+ progress_hooks[i].func_ptr = NULL;
+ progress_hooks[i].active = FALSE;
+ }
+
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_INIT);
return mpi_errno;
diff --git a/src/mpid/ch3/channels/sock/include/mpidi_ch3_impl.h b/src/mpid/ch3/channels/sock/include/mpidi_ch3_impl.h
index be1783a..27f09a8 100644
--- a/src/mpid/ch3/channels/sock/include/mpidi_ch3_impl.h
+++ b/src/mpid/ch3/channels/sock/include/mpidi_ch3_impl.h
@@ -74,6 +74,8 @@ int MPIDI_CH3I_Progress_init(void);
int MPIDI_CH3I_Progress_finalize(void);
int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*), int *id);
int MPIDI_CH3I_Progress_deregister_hook(int id);
+int MPIDI_CH3I_Progress_activate_hook(int id);
+int MPIDI_CH3I_Progress_deactivate_hook(int id);
int MPIDI_CH3I_VC_post_connect(MPIDI_VC_t *);
/* Shared memory window atomic/accumulate mutex implementation */
diff --git a/src/mpid/ch3/channels/sock/src/ch3_progress.c b/src/mpid/ch3/channels/sock/src/ch3_progress.c
index 154eb9c..77236b1 100644
--- a/src/mpid/ch3/channels/sock/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/sock/src/ch3_progress.c
@@ -47,8 +47,14 @@ static int adjust_iov(MPID_IOV ** iovp, int * countp, MPIU_Size_t nb);
#define MAX_PROGRESS_HOOKS 16
typedef int (*progress_func_ptr_t) (int* made_progress);
-static progress_func_ptr_t progress_hooks[MAX_PROGRESS_HOOKS] = { NULL };
-static int total_progress_hook_cnt = 0; /* Keep track of how many progress hooks are currently registered */
+
+typedef struct progress_hook_slot {
+ progress_func_ptr_t func_ptr;
+ int active;
+} progress_hook_slot_t;
+
+static progress_hook_slot_t progress_hooks[MAX_PROGRESS_HOOKS];
+static int total_progress_hook_cnt = 0; /* Keep track of how many progress hooks are currently activated */
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3i_Progress_test
@@ -94,8 +100,9 @@ static int MPIDI_CH3i_Progress_test(void)
called_progress_hook_cnt = 0;
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] != NULL) {
- mpi_errno = progress_hooks[i](&made_progress);
+ if (progress_hooks[i].active == TRUE) {
+ MPIU_Assert(progress_hooks[i].func_ptr != NULL);
+ mpi_errno = progress_hooks[i].func_ptr(&made_progress);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
called_progress_hook_cnt++;
@@ -196,8 +203,9 @@ static int MPIDI_CH3i_Progress_wait(MPID_Progress_state * progress_state)
called_progress_hook_cnt = 0;
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] != NULL) {
- mpi_errno = progress_hooks[i](&made_progress);
+ if (progress_hooks[i].active == TRUE) {
+ MPIU_Assert(progress_hooks[i].func_ptr != NULL);
+ mpi_errno = progress_hooks[i].func_ptr(&made_progress);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
if (made_progress) {
MPIDI_CH3_Progress_signal_completion();
@@ -312,6 +320,7 @@ int MPIDI_CH3_Connection_terminate(MPIDI_VC_t * vc)
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIDI_CH3I_Progress_init(void)
{
+ int i;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_INIT);
@@ -346,6 +355,12 @@ int MPIDI_CH3I_Progress_init(void)
/* Initialize the code to handle incoming packets */
mpi_errno = MPIDI_CH3_PktHandler_Init( pktArray, MPIDI_CH3_PKT_END_CH3+1 );
if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
+
+ /* Initialize progress hook slots */
+ for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
+ progress_hooks[i].func_ptr = NULL;
+ progress_hooks[i].active = FALSE;
+ }
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_INIT);
@@ -977,12 +992,9 @@ int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*), int *id)
MPIU_THREAD_CS_ENTER(MPIDCOMM,);
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] == NULL) {
- progress_hooks[i] = progress_fn;
-
- total_progress_hook_cnt++;
- MPIU_Assert(total_progress_hook_cnt <= MAX_PROGRESS_HOOKS);
-
+ if (progress_hooks[i].func_ptr == NULL) {
+ progress_hooks[i].func_ptr = progress_fn;
+ progress_hooks[i].active = FALSE;
break;
}
}
@@ -1016,16 +1028,71 @@ int MPIDI_CH3I_Progress_deregister_hook(int id)
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_DEREGISTER_HOOK);
MPIU_THREAD_CS_ENTER(MPIDCOMM,);
- MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS && progress_hooks[id] != NULL);
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS && progress_hooks[id].func_ptr != NULL);
+
+ progress_hooks[id].func_ptr = NULL;
+ progress_hooks[id].active = FALSE;
+
+ fn_exit:
+ MPIU_THREAD_CS_EXIT(MPIDCOMM,);
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_DEREGISTER_HOOK);
+ return mpi_errno;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+#undef FUNCNAME
+#define FUNCNAME MPIDI_CH3I_Progress_activate_hook
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIDI_CH3I_Progress_activate_hook(int id)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_ACTIVATE_HOOK);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_ACTIVATE_HOOK);
+ MPIU_THREAD_CS_ENTER(MPIDCOMM,);
+
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS &&
+ progress_hooks[id].active == FALSE && progress_hooks[id].func_ptr != NULL);
+ progress_hooks[id].active = TRUE;
+
+ total_progress_hook_cnt++;
+ MPIU_Assert(total_progress_hook_cnt <= MAX_PROGRESS_HOOKS);
+
+ fn_exit:
+ MPIU_THREAD_CS_EXIT(MPIDCOMM,);
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_ACTIVATE_HOOK);
+ return mpi_errno;
- progress_hooks[id] = NULL;
+ fn_fail:
+ goto fn_exit;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDI_CH3I_Progress_deactivate_hook
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIDI_CH3I_Progress_deactivate_hook(int id)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_DEACTIVATE_HOOK);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_DEACTIVATE_HOOK);
+ MPIU_THREAD_CS_ENTER(MPIDCOMM,);
+
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS &&
+ progress_hooks[id].active == TRUE && progress_hooks[id].func_ptr != NULL);
+ progress_hooks[id].active = FALSE;
total_progress_hook_cnt--;
MPIU_Assert(total_progress_hook_cnt >= 0);
fn_exit:
MPIU_THREAD_CS_EXIT(MPIDCOMM,);
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_DEREGISTER_HOOK);
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_DEACTIVATE_HOOK);
return mpi_errno;
fn_fail:
diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index 9843824..f233116 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -120,6 +120,11 @@ static inline int MPIDI_CH3I_Win_set_active(MPID_Win * win_ptr)
if (win_ptr->active == FALSE) {
win_ptr->active = TRUE;
+ if (MPIDI_RMA_Win_active_list_head == NULL) {
+ /* This is the first active window, activate RMA progress */
+ MPID_Progress_activate_hook(MPIDI_CH3I_RMA_Progress_hook_id);
+ }
+
MPL_DL_DELETE(MPIDI_RMA_Win_inactive_list_head, win_ptr);
MPL_DL_APPEND(MPIDI_RMA_Win_active_list_head, win_ptr);
}
@@ -143,6 +148,11 @@ static inline int MPIDI_CH3I_Win_set_inactive(MPID_Win * win_ptr)
win_ptr->active = FALSE;
MPL_DL_DELETE(MPIDI_RMA_Win_active_list_head, win_ptr);
MPL_DL_APPEND(MPIDI_RMA_Win_inactive_list_head, win_ptr);
+
+ if (MPIDI_RMA_Win_active_list_head == NULL) {
+ /* This is the last active window, de-activate RMA progress */
+ MPID_Progress_deactivate_hook(MPIDI_CH3I_RMA_Progress_hook_id);
+ }
}
fn_exit:
diff --git a/src/mpid/ch3/include/mpidimpl.h b/src/mpid/ch3/include/mpidimpl.h
index 1d238e3..fcf5f33 100644
--- a/src/mpid/ch3/include/mpidimpl.h
+++ b/src/mpid/ch3/include/mpidimpl.h
@@ -1940,8 +1940,12 @@ int MPIDI_CH3_Req_handler_rma_op_complete(MPID_Request *);
int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*), int *id);
int MPIDI_CH3I_Progress_deregister_hook(int id);
+int MPIDI_CH3I_Progress_activate_hook(int id);
+int MPIDI_CH3I_Progress_deactivate_hook(int id);
#define MPID_Progress_register_hook(fn_, id_) MPIDI_CH3I_Progress_register_hook(fn_, id_)
#define MPID_Progress_deregister_hook(id_) MPIDI_CH3I_Progress_deregister_hook(id_)
+#define MPID_Progress_activate_hook(id_) MPIDI_CH3I_Progress_activate_hook(id_)
+#define MPID_Progress_deactivate_hook(id_) MPIDI_CH3I_Progress_deactivate_hook(id_)
#endif /* !defined(MPICH_MPIDIMPL_H_INCLUDED) */
diff --git a/src/mpid/common/hcoll/hcoll_init.c b/src/mpid/common/hcoll/hcoll_init.c
index 23f9680..5a8184c 100644
--- a/src/mpid/common/hcoll/hcoll_init.c
+++ b/src/mpid/common/hcoll/hcoll_init.c
@@ -25,6 +25,7 @@ int hcoll_destroy(void *param ATTRIBUTE((unused)))
{
if (1 == hcoll_initialized) {
hcoll_finalize();
+ MPID_Progress_deactivate_hook(hcoll_progress_hook_id);
MPID_Progress_deregister_hook(hcoll_progress_hook_id);
}
hcoll_initialized = 0;
@@ -87,6 +88,8 @@ int hcoll_initialize(void)
mpi_errno = MPID_Progress_register_hook(hcoll_do_progress,
&hcoll_progress_hook_id);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+
+ MPID_Progress_activate_hook(hcoll_progress_hook_id);
}
MPIR_Add_finalize(hcoll_destroy, 0, 0);
diff --git a/src/mpid/common/sched/mpid_sched.c b/src/mpid/common/sched/mpid_sched.c
index 8098d37..f4865e5 100644
--- a/src/mpid/common/sched/mpid_sched.c
+++ b/src/mpid/common/sched/mpid_sched.c
@@ -415,6 +415,8 @@ int MPID_Sched_start(MPID_Sched_t *sp, MPID_Comm *comm, int tag, MPID_Request **
mpi_errno = MPID_Progress_register_hook(MPIDU_Sched_progress,
&nbc_progress_hook_id);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+
+ MPID_Progress_activate_hook(nbc_progress_hook_id);
}
MPL_DL_APPEND(all_schedules.head, s);
@@ -944,8 +946,10 @@ int MPIDU_Sched_progress(int *made_progress)
int mpi_errno;
mpi_errno = MPIDU_Sched_progress_state(&all_schedules, made_progress);
- if (!mpi_errno && all_schedules.head == NULL)
+ if (!mpi_errno && all_schedules.head == NULL) {
+ MPID_Progress_deactivate_hook(nbc_progress_hook_id);
MPID_Progress_deregister_hook(nbc_progress_hook_id);
+ }
return mpi_errno;
}
diff --git a/src/mpid/pamid/include/mpidimpl.h b/src/mpid/pamid/include/mpidimpl.h
index 3a9e78c..3e131e4 100644
--- a/src/mpid/pamid/include/mpidimpl.h
+++ b/src/mpid/pamid/include/mpidimpl.h
@@ -187,7 +187,11 @@ MPI_Aint MPID_Aint_diff(MPI_Aint addr1, MPI_Aint addr2);
int MPIDI_Progress_register_hook(int (*progress_fn)(int*), int *id);
int MPIDI_Progress_deregister_hook(int id);
+int MPIDI_Progress_activate_hook(int id);
+int MPIDI_Progress_deactivate_hook(int id);
#define MPID_Progress_register_hook(fn_, id_) MPIDI_Progress_register_hook(fn_, id_)
#define MPID_Progress_deregister_hook(id_) MPIDI_Progress_deregister_hook(id_)
+#define MPID_Progress_activate_hook(id_) MPIDI_Progress_activate_hook(id_)
+#define MPID_Progress_deactivate_hook(id_) MPIDI_Progress_deactivate_hook(id_)
#endif
diff --git a/src/mpid/pamid/src/mpid_progress.c b/src/mpid/pamid/src/mpid_progress.c
index f470563..72668bb 100644
--- a/src/mpid/pamid/src/mpid_progress.c
+++ b/src/mpid/pamid/src/mpid_progress.c
@@ -23,8 +23,14 @@
#define MAX_PROGRESS_HOOKS 16
typedef int (*progress_func_ptr_t) (int* made_progress);
-static progress_func_ptr_t progress_hooks[MAX_PROGRESS_HOOKS] = { NULL };
-static int total_progress_hook_cnt = 0; /* Keep track of how many progress hooks are currently registered */
+
+typedef struct progress_hook_slot {
+ progress_func_ptr_t func_ptr;
+ int active;
+} progress_hook_slot_t;
+
+static progress_hook_slot_t progress_hooks[MAX_PROGRESS_HOOKS];
+static int total_progress_hook_cnt = 0; /* Keep track of how many progress hooks are currently activated */
#undef FUNCNAME
#define FUNCNAME MPIDI_Progress_register_hook
@@ -40,12 +46,9 @@ int MPIDI_Progress_register_hook(int (*progress_fn)(int*), int *id)
MPIU_THREAD_CS_ENTER(ASYNC,);
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] == NULL) {
- progress_hooks[i] = progress_fn;
-
- total_progress_hook_cnt++;
- MPIU_Assert(total_progress_hook_cnt <= MAX_PROGRESS_HOOKS);
-
+ if (progress_hooks[i].func_ptr == NULL) {
+ progress_hooks[i].func_ptr = progress_fn;
+ progress_hooks[i].active = FALSE;
break;
}
}
@@ -79,16 +82,71 @@ int MPIDI_Progress_deregister_hook(int id)
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_PROGRESS_DEREGISTER_HOOK);
MPIU_THREAD_CS_ENTER(ASYNC,);
- MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS && progress_hooks[id] != NULL);
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS && progress_hooks[id].func_ptr != NULL);
+
+ progress_hooks[id].func_ptr = NULL;
+ progress_hooks[id].active = FALSE;
+
+ fn_exit:
+ MPIU_THREAD_CS_EXIT(ASYNC,);
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_PROGRESS_DEREGISTER_HOOK);
+ return mpi_errno;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+#undef FUNCNAME
+#define FUNCNAME MPIDI_CH3I_Progress_activate_hook
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIDI_CH3I_Progress_activate_hook(int id)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_ACTIVATE_HOOK);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_ACTIVATE_HOOK);
+ MPIU_THREAD_CS_ENTER(MPIDCOMM,);
+
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS &&
+ progress_hooks[id].active == FALSE && progress_hooks[id].func_ptr != NULL);
+ progress_hooks[id].active = TRUE;
- progress_hooks[id] = NULL;
+ total_progress_hook_cnt++;
+ MPIU_Assert(total_progress_hook_cnt <= MAX_PROGRESS_HOOKS);
+
+ fn_exit:
+ MPIU_THREAD_CS_EXIT(MPIDCOMM,);
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_ACTIVATE_HOOK);
+ return mpi_errno;
+
+ fn_fail:
+ goto fn_exit;
+}
+
+
+#undef FUNCNAME
+#define FUNCNAME MPIDI_CH3I_Progress_deactivate_hook
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIDI_CH3I_Progress_deactivate_hook(int id)
+{
+ int mpi_errno = MPI_SUCCESS;
+ MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_DEACTIVATE_HOOK);
+
+ MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_DEACTIVATE_HOOK);
+ MPIU_THREAD_CS_ENTER(MPIDCOMM,);
+
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS &&
+ progress_hooks[id].active == TRUE && progress_hooks[id].func_ptr != NULL);
+ progress_hooks[id].active = FALSE;
total_progress_hook_cnt--;
MPIU_Assert(total_progress_hook_cnt >= 0);
fn_exit:
- MPIU_THREAD_CS_EXIT(ASYNC,);
- MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_PROGRESS_DEREGISTER_HOOK);
+ MPIU_THREAD_CS_EXIT(MPIDCOMM,);
+ MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_DEACTIVATE_HOOK);
return mpi_errno;
fn_fail:
@@ -106,6 +164,7 @@ MPIDI_Progress_init()
* function is ignored if async progress is disabled.
*/
pamix_progress_function progress_fn = MPIDI_Progress_async_poll;
+ uintptr_t i;
#if (MPIU_THREAD_GRANULARITY == MPIU_THREAD_GRANULARITY_PER_OBJECT)
/* In the "per object" mpich lock mode the only possible progress functions
@@ -145,7 +204,6 @@ MPIDI_Progress_init()
TRACE_ERR("Async advance beginning...\n");
/* Enable async progress on all contexts.*/
- uintptr_t i;
for (i=0; i<MPIDI_Process.avail_contexts; ++i)
{
PAMIX_Progress_register(MPIDI_Context[i],
@@ -157,6 +215,13 @@ MPIDI_Progress_init()
}
TRACE_ERR("Async advance enabled\n");
}
+
+ /* Initialize progress hook slots */
+ for (i = 0; i < MAX_PROGRESS_HOOKS; i++)
+ {
+ progress_hooks[i].func_ptr = NULL;
+ progress_hooks[i].active = FALSE;
+ }
}
void
@@ -241,8 +306,9 @@ MPIDI_Progress_async_poll (pami_context_t context, void *cookie)
{
called_progress_hook_cnt = 0;
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] != NULL) {
- progress_hooks[i](&made_progress);
+ if (progress_hooks[i].active == TRUE) {
+ MPIU_Assert(progress_hooks[i].func_ptr != NULL);
+ progress_hooks[i].func_ptr(&made_progress);
called_progress_hook_cnt++;
if (called_progress_hook_cnt == total_progress_hook_cnt)
@@ -277,8 +343,9 @@ MPIDI_Progress_async_poll_perobj (pami_context_t context, void *cookie)
int called_progress_hook_cnt = 0;
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] != NULL) {
- progress_hooks[i](&made_progress);
+ if (progress_hooks[i].active == TRUE) {
+ MPIU_Assert(progress_hooks[i].func_ptr != NULL);
+ progress_hooks[i].func_ptr(&made_progress);
called_progress_hook_cnt++;
if (called_progress_hook_cnt == total_progress_hook_cnt)
http://git.mpich.org/mpich.git/commitdiff/70b0e0d7ccee74aaff912c99419476bec…
commit 70b0e0d7ccee74aaff912c99419476bec14e2e82
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Tue Aug 11 14:11:13 2015 -0500
Move RMA progress_register/de-register_hook to Win_init/free.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index 6e32af3..9843824 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -109,8 +109,6 @@ MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_rmaqueue_alloc);
&(win_ptr_)->slots[(rank_) % (win_ptr_)->num_slots] : \
&(win_ptr_)->slots[(rank_)])
-static int rma_progress_hook_id = 0;
-
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3I_Win_set_active
#undef FCNAME
@@ -122,15 +120,6 @@ static inline int MPIDI_CH3I_Win_set_active(MPID_Win * win_ptr)
if (win_ptr->active == FALSE) {
win_ptr->active = TRUE;
- /* If this is the first active window, register RMA progress */
- if (MPIDI_RMA_Win_active_list_head == NULL) {
- mpi_errno = MPID_Progress_register_hook(MPIDI_CH3I_RMA_Make_progress_global,
- &rma_progress_hook_id);
- if (mpi_errno) {
- MPIU_ERR_POP(mpi_errno);
- }
- }
-
MPL_DL_DELETE(MPIDI_RMA_Win_inactive_list_head, win_ptr);
MPL_DL_APPEND(MPIDI_RMA_Win_active_list_head, win_ptr);
}
@@ -154,14 +143,6 @@ static inline int MPIDI_CH3I_Win_set_inactive(MPID_Win * win_ptr)
win_ptr->active = FALSE;
MPL_DL_DELETE(MPIDI_RMA_Win_active_list_head, win_ptr);
MPL_DL_APPEND(MPIDI_RMA_Win_inactive_list_head, win_ptr);
-
- /* This is the last active window, de-register RMA progress */
- if (MPIDI_RMA_Win_active_list_head == NULL) {
- mpi_errno = MPID_Progress_deregister_hook(rma_progress_hook_id);
- if (mpi_errno != MPI_SUCCESS) {
- MPIU_ERR_POP(mpi_errno);
- }
- }
}
fn_exit:
diff --git a/src/mpid/ch3/include/mpidpre.h b/src/mpid/ch3/include/mpidpre.h
index 81ca4b4..19df355 100644
--- a/src/mpid/ch3/include/mpidpre.h
+++ b/src/mpid/ch3/include/mpidpre.h
@@ -352,6 +352,7 @@ typedef struct MPIDI_Win_basic_info {
extern struct MPID_Win *MPIDI_RMA_Win_active_list_head, *MPIDI_RMA_Win_inactive_list_head;
extern int MPIDI_CH3I_RMA_Active_req_cnt;
+extern int MPIDI_CH3I_RMA_Progress_hook_id;
#ifdef MPIDI_CH3_WIN_DECL
#define MPID_DEV_WIN_DECL \
diff --git a/src/mpid/ch3/src/mpid_rma.c b/src/mpid/ch3/src/mpid_rma.c
index e3c0e54..e12b81f 100644
--- a/src/mpid/ch3/src/mpid_rma.c
+++ b/src/mpid/ch3/src/mpid_rma.c
@@ -48,6 +48,9 @@ MPID_Win *MPIDI_RMA_Win_active_list_head = NULL, *MPIDI_RMA_Win_inactive_list_he
* internal requests in RMA infrastructure. */
int MPIDI_CH3I_RMA_Active_req_cnt = 0;
+/* This variable stores the index of RMA progress hook in progress hook array */
+int MPIDI_CH3I_RMA_Progress_hook_id = 0;
+
static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model, MPID_Info * info,
MPID_Comm * comm_ptr, MPID_Win ** win_ptr);
@@ -357,6 +360,15 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
&((*win_ptr)->target_lock_entry_pool_start[i]));
}
+ if (MPIDI_RMA_Win_inactive_list_head == NULL && MPIDI_RMA_Win_active_list_head == NULL) {
+ /* this is the first window, register RMA progress hook */
+ mpi_errno = MPID_Progress_register_hook(MPIDI_CH3I_RMA_Make_progress_global,
+ &MPIDI_CH3I_RMA_Progress_hook_id);
+ if (mpi_errno) {
+ MPIU_ERR_POP(mpi_errno);
+ }
+ }
+
MPL_DL_APPEND(MPIDI_RMA_Win_inactive_list_head, (*win_ptr));
if (MPIDI_CH3U_Win_hooks.win_init != NULL) {
diff --git a/src/mpid/ch3/src/mpidi_rma.c b/src/mpid/ch3/src/mpidi_rma.c
index 495d5b3..a114c3c 100644
--- a/src/mpid/ch3/src/mpidi_rma.c
+++ b/src/mpid/ch3/src/mpidi_rma.c
@@ -193,6 +193,14 @@ int MPID_Win_free(MPID_Win ** win_ptr)
MPIU_Assert((*win_ptr)->active == FALSE);
MPL_DL_DELETE(MPIDI_RMA_Win_inactive_list_head, (*win_ptr));
+ if (MPIDI_RMA_Win_inactive_list_head == NULL && MPIDI_RMA_Win_inactive_list_head == NULL) {
+ /* this is the last window, de-register RMA progress hook */
+ mpi_errno = MPID_Progress_deregister_hook(MPIDI_CH3I_RMA_Progress_hook_id);
+ if (mpi_errno != MPI_SUCCESS) {
+ MPIU_ERR_POP(mpi_errno);
+ }
+ }
+
comm_ptr = (*win_ptr)->comm_ptr;
mpi_errno = MPIR_Comm_free_impl(comm_ptr);
if (mpi_errno)
http://git.mpich.org/mpich.git/commitdiff/688f9f9e24b042cff5de99904325a384d…
commit 688f9f9e24b042cff5de99904325a384d8e46c1d
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Tue Aug 11 12:45:09 2015 -0500
Modify Proress_register/deregister_hook to return/pass id argument.
By doing this, we can use the id to activate/de-activate each
progress hook by O(1) operation, avoid going over the entire
progress hook slots everytime.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_impl.h b/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_impl.h
index c00133e..a3b4d81 100644
--- a/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_impl.h
+++ b/src/mpid/ch3/channels/nemesis/include/mpidi_ch3_impl.h
@@ -50,8 +50,8 @@ extern struct MPID_Request *MPIDI_CH3I_shm_active_send;
int MPIDI_CH3I_Shm_supported(void);
int MPIDI_CH3I_Progress_init(void);
int MPIDI_CH3I_Progress_finalize(void);
-int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*));
-int MPIDI_CH3I_Progress_deregister_hook(int (*progress_fn)(int*));
+int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*), int *id);
+int MPIDI_CH3I_Progress_deregister_hook(int id);
int MPIDI_CH3I_Shm_send_progress(void);
int MPIDI_CH3I_Complete_sendq_with_error(MPIDI_VC_t * vc);
diff --git a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
index 380fd45..8ece505 100644
--- a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
@@ -291,7 +291,7 @@ int MPIDI_CH3I_Shm_send_progress(void)
#define FUNCNAME MPIDI_CH3I_Progress_register_hook
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*))
+int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*), int *id)
{
int mpi_errno = MPI_SUCCESS;
int i;
@@ -317,6 +317,8 @@ int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*))
MPI_ERR_INTERN, "**progresshookstoomany", 0 );
}
+ (*id) = i;
+
fn_exit:
MPIU_THREAD_CS_EXIT(MPIDCOMM,);
MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_REGISTER_HOOK);
@@ -330,25 +332,20 @@ int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*))
#define FUNCNAME MPIDI_CH3I_Progress_deregister_hook
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIDI_CH3I_Progress_deregister_hook(int (*progress_fn)(int*))
+int MPIDI_CH3I_Progress_deregister_hook(int id)
{
int mpi_errno = MPI_SUCCESS;
- int i;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_DEREGISTER_HOOK);
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_DEREGISTER_HOOK);
MPIU_THREAD_CS_ENTER(MPIDCOMM,);
- for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] == progress_fn) {
- progress_hooks[i] = NULL;
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS && progress_hooks[id] != NULL);
- total_progress_hook_cnt--;
- MPIU_Assert(total_progress_hook_cnt >= 0);
+ progress_hooks[id] = NULL;
- break;
- }
- }
+ total_progress_hook_cnt--;
+ MPIU_Assert(total_progress_hook_cnt >= 0);
fn_exit:
MPIU_THREAD_CS_EXIT(MPIDCOMM,);
diff --git a/src/mpid/ch3/channels/sock/include/mpidi_ch3_impl.h b/src/mpid/ch3/channels/sock/include/mpidi_ch3_impl.h
index f1bc05d..be1783a 100644
--- a/src/mpid/ch3/channels/sock/include/mpidi_ch3_impl.h
+++ b/src/mpid/ch3/channels/sock/include/mpidi_ch3_impl.h
@@ -72,8 +72,8 @@
channel interface */
int MPIDI_CH3I_Progress_init(void);
int MPIDI_CH3I_Progress_finalize(void);
-int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*));
-int MPIDI_CH3I_Progress_deregister_hook(int (*progress_fn)(int*));
+int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*), int *id);
+int MPIDI_CH3I_Progress_deregister_hook(int id);
int MPIDI_CH3I_VC_post_connect(MPIDI_VC_t *);
/* Shared memory window atomic/accumulate mutex implementation */
diff --git a/src/mpid/ch3/channels/sock/src/ch3_progress.c b/src/mpid/ch3/channels/sock/src/ch3_progress.c
index 230620a..154eb9c 100644
--- a/src/mpid/ch3/channels/sock/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/sock/src/ch3_progress.c
@@ -967,7 +967,7 @@ int MPIDI_CH3I_Progress( int blocking, MPID_Progress_state *state )
#define FUNCNAME MPIDI_CH3I_Progress_register_hook
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*))
+int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*), int *id)
{
int mpi_errno = MPI_SUCCESS;
int i;
@@ -993,6 +993,8 @@ int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*))
MPI_ERR_INTERN, "**progresshookstoomany", 0 );
}
+ (*id) = i;
+
fn_exit:
MPIU_THREAD_CS_EXIT(MPIDCOMM,);
MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3I_PROGRESS_REGISTER_HOOK);
@@ -1006,25 +1008,20 @@ int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*))
#define FUNCNAME MPIDI_CH3I_Progress_deregister_hook
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIDI_CH3I_Progress_deregister_hook(int (*progress_fn)(int*))
+int MPIDI_CH3I_Progress_deregister_hook(int id)
{
int mpi_errno = MPI_SUCCESS;
- int i;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_DEREGISTER_HOOK);
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_DEREGISTER_HOOK);
MPIU_THREAD_CS_ENTER(MPIDCOMM,);
- for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] == progress_fn) {
- progress_hooks[i] = NULL;
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS && progress_hooks[id] != NULL);
- total_progress_hook_cnt--;
- MPIU_Assert(total_progress_hook_cnt >= 0);
+ progress_hooks[id] = NULL;
- break;
- }
- }
+ total_progress_hook_cnt--;
+ MPIU_Assert(total_progress_hook_cnt >= 0);
fn_exit:
MPIU_THREAD_CS_EXIT(MPIDCOMM,);
diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index bc598ea..6e32af3 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -109,6 +109,7 @@ MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_rmaqueue_alloc);
&(win_ptr_)->slots[(rank_) % (win_ptr_)->num_slots] : \
&(win_ptr_)->slots[(rank_)])
+static int rma_progress_hook_id = 0;
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3I_Win_set_active
@@ -123,7 +124,8 @@ static inline int MPIDI_CH3I_Win_set_active(MPID_Win * win_ptr)
/* If this is the first active window, register RMA progress */
if (MPIDI_RMA_Win_active_list_head == NULL) {
- mpi_errno = MPID_Progress_register_hook(MPIDI_CH3I_RMA_Make_progress_global);
+ mpi_errno = MPID_Progress_register_hook(MPIDI_CH3I_RMA_Make_progress_global,
+ &rma_progress_hook_id);
if (mpi_errno) {
MPIU_ERR_POP(mpi_errno);
}
@@ -155,7 +157,7 @@ static inline int MPIDI_CH3I_Win_set_inactive(MPID_Win * win_ptr)
/* This is the last active window, de-register RMA progress */
if (MPIDI_RMA_Win_active_list_head == NULL) {
- mpi_errno = MPID_Progress_deregister_hook(MPIDI_CH3I_RMA_Make_progress_global);
+ mpi_errno = MPID_Progress_deregister_hook(rma_progress_hook_id);
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_POP(mpi_errno);
}
diff --git a/src/mpid/ch3/include/mpidimpl.h b/src/mpid/ch3/include/mpidimpl.h
index 06cb0e4..1d238e3 100644
--- a/src/mpid/ch3/include/mpidimpl.h
+++ b/src/mpid/ch3/include/mpidimpl.h
@@ -1938,10 +1938,10 @@ int MPIDI_CH3_Req_handler_rma_op_complete(MPID_Request *);
} while (0)
-int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*));
-int MPIDI_CH3I_Progress_deregister_hook(int (*progress_fn)(int*));
+int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*), int *id);
+int MPIDI_CH3I_Progress_deregister_hook(int id);
-#define MPID_Progress_register_hook(fn_) MPIDI_CH3I_Progress_register_hook(fn_)
-#define MPID_Progress_deregister_hook(fn_) MPIDI_CH3I_Progress_deregister_hook(fn_)
+#define MPID_Progress_register_hook(fn_, id_) MPIDI_CH3I_Progress_register_hook(fn_, id_)
+#define MPID_Progress_deregister_hook(id_) MPIDI_CH3I_Progress_deregister_hook(id_)
#endif /* !defined(MPICH_MPIDIMPL_H_INCLUDED) */
diff --git a/src/mpid/common/hcoll/hcoll_init.c b/src/mpid/common/hcoll/hcoll_init.c
index ee1a364..23f9680 100644
--- a/src/mpid/common/hcoll/hcoll_init.c
+++ b/src/mpid/common/hcoll/hcoll_init.c
@@ -2,6 +2,8 @@
static int hcoll_initialized = 0;
static int hcoll_comm_world_initialized = 0;
+static int hcoll_progress_hook_id = 0;
+
int hcoll_enable = 1;
int hcoll_enable_barrier = 1;
int hcoll_enable_bcast = 1;
@@ -23,7 +25,7 @@ int hcoll_destroy(void *param ATTRIBUTE((unused)))
{
if (1 == hcoll_initialized) {
hcoll_finalize();
- MPID_Progress_deregister_hook(hcoll_do_progress);
+ MPID_Progress_deregister_hook(hcoll_progress_hook_id);
}
hcoll_initialized = 0;
return 0;
@@ -82,7 +84,8 @@ int hcoll_initialize(void)
if (!hcoll_initialized) {
hcoll_initialized = 1;
- mpi_errno = MPID_Progress_register_hook(hcoll_do_progress);
+ mpi_errno = MPID_Progress_register_hook(hcoll_do_progress,
+ &hcoll_progress_hook_id);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
MPIR_Add_finalize(hcoll_destroy, 0, 0);
diff --git a/src/mpid/common/sched/mpid_sched.c b/src/mpid/common/sched/mpid_sched.c
index a6e7037..8098d37 100644
--- a/src/mpid/common/sched/mpid_sched.c
+++ b/src/mpid/common/sched/mpid_sched.c
@@ -54,6 +54,8 @@ struct MPIDU_Sched_state {
/* holds on to all incomplete schedules on which progress should be made */
struct MPIDU_Sched_state all_schedules = {NULL};
+static int nbc_progress_hook_id = 0;
+
/* returns TRUE if any schedules are currently pending completion by the
* progress engine, FALSE otherwise */
#undef FUNCNAME
@@ -410,7 +412,8 @@ int MPID_Sched_start(MPID_Sched_t *sp, MPID_Comm *comm, int tag, MPID_Request **
/* finally, enqueue in the list of all pending schedules so that the
* progress engine can make progress on it */
if (all_schedules.head == NULL) {
- mpi_errno = MPID_Progress_register_hook(MPIDU_Sched_progress);
+ mpi_errno = MPID_Progress_register_hook(MPIDU_Sched_progress,
+ &nbc_progress_hook_id);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
MPL_DL_APPEND(all_schedules.head, s);
@@ -942,7 +945,7 @@ int MPIDU_Sched_progress(int *made_progress)
mpi_errno = MPIDU_Sched_progress_state(&all_schedules, made_progress);
if (!mpi_errno && all_schedules.head == NULL)
- MPID_Progress_deregister_hook(MPIDU_Sched_progress);
+ MPID_Progress_deregister_hook(nbc_progress_hook_id);
return mpi_errno;
}
diff --git a/src/mpid/pamid/include/mpidimpl.h b/src/mpid/pamid/include/mpidimpl.h
index fabc9d4..3a9e78c 100644
--- a/src/mpid/pamid/include/mpidimpl.h
+++ b/src/mpid/pamid/include/mpidimpl.h
@@ -185,9 +185,9 @@ MPIDI_Win_set_info(MPID_Win *win,
MPI_Aint MPID_Aint_add(MPI_Aint base, MPI_Aint disp);
MPI_Aint MPID_Aint_diff(MPI_Aint addr1, MPI_Aint addr2);
-int MPIDI_Progress_register_hook(int (*progress_fn)(int*));
-int MPIDI_Progress_deregister_hook(int (*progress_fn)(int*));
+int MPIDI_Progress_register_hook(int (*progress_fn)(int*), int *id);
+int MPIDI_Progress_deregister_hook(int id);
-#define MPID_Progress_register_hook(fn_) MPIDI_Progress_register_hook(fn_)
-#define MPID_Progress_deregister_hook(fn_) MPIDI_Progress_deregister_hook(fn_)
+#define MPID_Progress_register_hook(fn_, id_) MPIDI_Progress_register_hook(fn_, id_)
+#define MPID_Progress_deregister_hook(id_) MPIDI_Progress_deregister_hook(id_)
#endif
diff --git a/src/mpid/pamid/src/mpid_progress.c b/src/mpid/pamid/src/mpid_progress.c
index 07111a3..f470563 100644
--- a/src/mpid/pamid/src/mpid_progress.c
+++ b/src/mpid/pamid/src/mpid_progress.c
@@ -30,7 +30,7 @@ static int total_progress_hook_cnt = 0; /* Keep track of how many progress hooks
#define FUNCNAME MPIDI_Progress_register_hook
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIDI_Progress_register_hook(int (*progress_fn)(int*))
+int MPIDI_Progress_register_hook(int (*progress_fn)(int*), int *id)
{
int mpi_errno = MPI_SUCCESS;
int i;
@@ -56,6 +56,8 @@ int MPIDI_Progress_register_hook(int (*progress_fn)(int*))
MPI_ERR_INTERN, "**progresshookstoomany", 0 );
}
+ (*id) = i;
+
fn_exit:
MPIU_THREAD_CS_EXIT(ASYNC,);
MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_PROGRESS_REGISTER_HOOK);
@@ -69,25 +71,20 @@ int MPIDI_Progress_register_hook(int (*progress_fn)(int*))
#define FUNCNAME MPIDI_Progress_deregister_hook
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIDI_Progress_deregister_hook(int (*progress_fn)(int*))
+int MPIDI_Progress_deregister_hook(int id)
{
int mpi_errno = MPI_SUCCESS;
- int i;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_PROGRESS_DEREGISTER_HOOK);
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_PROGRESS_DEREGISTER_HOOK);
MPIU_THREAD_CS_ENTER(ASYNC,);
- for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
- if (progress_hooks[i] == progress_fn) {
- progress_hooks[i] = NULL;
+ MPIU_Assert(id >= 0 && id < MAX_PROGRESS_HOOKS && progress_hooks[id] != NULL);
- total_progress_hook_cnt--;
- MPIU_Assert(total_progress_hook_cnt >= 0);
+ progress_hooks[id] = NULL;
- break;
- }
- }
+ total_progress_hook_cnt--;
+ MPIU_Assert(total_progress_hook_cnt >= 0);
fn_exit:
MPIU_THREAD_CS_EXIT(ASYNC,);
http://git.mpich.org/mpich.git/commitdiff/98d4b47ab463e3371c372e6621a72ca24…
commit 98d4b47ab463e3371c372e6621a72ca244d547bf
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Tue Aug 11 10:41:02 2015 -0500
Add missed optimization for sock and pamid.
In 4551de14b1d752a9c7be49df4a9e70776addd02f, we added a counter
in nemesis to keep track of how many progress hooks are currently
registered. Here we do the same optimizaton for sock and pamid.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/channels/sock/src/ch3_progress.c b/src/mpid/ch3/channels/sock/src/ch3_progress.c
index ded4e10..230620a 100644
--- a/src/mpid/ch3/channels/sock/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/sock/src/ch3_progress.c
@@ -48,6 +48,7 @@ static int adjust_iov(MPID_IOV ** iovp, int * countp, MPIU_Size_t nb);
#define MAX_PROGRESS_HOOKS 16
typedef int (*progress_func_ptr_t) (int* made_progress);
static progress_func_ptr_t progress_hooks[MAX_PROGRESS_HOOKS] = { NULL };
+static int total_progress_hook_cnt = 0; /* Keep track of how many progress hooks are currently registered */
#undef FUNCNAME
#define FUNCNAME MPIDI_CH3i_Progress_test
@@ -59,6 +60,7 @@ static int MPIDI_CH3i_Progress_test(void)
int mpi_errno = MPI_SUCCESS;
int made_progress;
int i;
+ int called_progress_hook_cnt;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3I_PROGRESS_TEST);
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3I_PROGRESS_TEST);
@@ -90,10 +92,15 @@ static int MPIDI_CH3i_Progress_test(void)
}
# endif
+ called_progress_hook_cnt = 0;
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] != NULL) {
mpi_errno = progress_hooks[i](&made_progress);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+
+ called_progress_hook_cnt++;
+ if (called_progress_hook_cnt == total_progress_hook_cnt)
+ break;
}
}
@@ -185,7 +192,9 @@ static int MPIDI_CH3i_Progress_wait(MPID_Progress_state * progress_state)
{
int made_progress = FALSE;
int i;
+ int called_progress_hook_cnt;
+ called_progress_hook_cnt = 0;
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] != NULL) {
mpi_errno = progress_hooks[i](&made_progress);
@@ -194,6 +203,10 @@ static int MPIDI_CH3i_Progress_wait(MPID_Progress_state * progress_state)
MPIDI_CH3_Progress_signal_completion();
break; /* break the for loop */
}
+
+ called_progress_hook_cnt++;
+ if (called_progress_hook_cnt == total_progress_hook_cnt)
+ break;
}
}
if (made_progress) break; /* break the do loop */
@@ -966,6 +979,10 @@ int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*))
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] == NULL) {
progress_hooks[i] = progress_fn;
+
+ total_progress_hook_cnt++;
+ MPIU_Assert(total_progress_hook_cnt <= MAX_PROGRESS_HOOKS);
+
break;
}
}
@@ -1001,6 +1018,10 @@ int MPIDI_CH3I_Progress_deregister_hook(int (*progress_fn)(int*))
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] == progress_fn) {
progress_hooks[i] = NULL;
+
+ total_progress_hook_cnt--;
+ MPIU_Assert(total_progress_hook_cnt >= 0);
+
break;
}
}
diff --git a/src/mpid/pamid/src/mpid_progress.c b/src/mpid/pamid/src/mpid_progress.c
index f4294f7..07111a3 100644
--- a/src/mpid/pamid/src/mpid_progress.c
+++ b/src/mpid/pamid/src/mpid_progress.c
@@ -24,6 +24,7 @@
#define MAX_PROGRESS_HOOKS 16
typedef int (*progress_func_ptr_t) (int* made_progress);
static progress_func_ptr_t progress_hooks[MAX_PROGRESS_HOOKS] = { NULL };
+static int total_progress_hook_cnt = 0; /* Keep track of how many progress hooks are currently registered */
#undef FUNCNAME
#define FUNCNAME MPIDI_Progress_register_hook
@@ -41,6 +42,10 @@ int MPIDI_Progress_register_hook(int (*progress_fn)(int*))
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] == NULL) {
progress_hooks[i] = progress_fn;
+
+ total_progress_hook_cnt++;
+ MPIU_Assert(total_progress_hook_cnt <= MAX_PROGRESS_HOOKS);
+
break;
}
}
@@ -76,6 +81,10 @@ int MPIDI_Progress_deregister_hook(int (*progress_fn)(int*))
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] == progress_fn) {
progress_hooks[i] = NULL;
+
+ total_progress_hook_cnt--;
+ MPIU_Assert(total_progress_hook_cnt >= 0);
+
break;
}
}
@@ -223,6 +232,7 @@ MPIDI_Progress_async_poll (pami_context_t context, void *cookie)
pami_result_t rc;
int loop_count=100;
int i, made_progress;
+ int called_progress_hook_cnt;
/* In the "global" mpich lock mode all application threads must acquire the
* ALLFUNC global lock upon entry to the API. The async progress thread
@@ -232,9 +242,14 @@ MPIDI_Progress_async_poll (pami_context_t context, void *cookie)
*/
if (MPIU_THREAD_CS_TRY(ALLFUNC,)) /* (0==try_acquire(0)) */
{
+ called_progress_hook_cnt = 0;
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] != NULL) {
progress_hooks[i](&made_progress);
+
+ called_progress_hook_cnt++;
+ if (called_progress_hook_cnt == total_progress_hook_cnt)
+ break;
}
}
@@ -262,10 +277,15 @@ MPIDI_Progress_async_poll_perobj (pami_context_t context, void *cookie)
pami_result_t rc;
int loop_count=100;
int i, made_progress;
+ int called_progress_hook_cnt = 0;
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] != NULL) {
progress_hooks[i](&made_progress);
+
+ called_progress_hook_cnt++;
+ if (called_progress_hook_cnt == total_progress_hook_cnt)
+ break;
}
}
-----------------------------------------------------------------------
Summary of changes:
.../ch3/channels/nemesis/include/mpidi_ch3_impl.h | 6 +-
src/mpid/ch3/channels/nemesis/src/ch3_progress.c | 108 ++++++++++++++----
.../ch3/channels/sock/include/mpidi_ch3_impl.h | 6 +-
src/mpid/ch3/channels/sock/src/ch3_progress.c | 117 +++++++++++++++++---
src/mpid/ch3/include/mpid_rma_oplist.h | 15 +--
src/mpid/ch3/include/mpidimpl.h | 14 ++-
src/mpid/ch3/include/mpidpre.h | 1 +
src/mpid/ch3/src/mpid_rma.c | 12 ++
src/mpid/ch3/src/mpidi_rma.c | 8 ++
src/mpid/common/hcoll/hcoll_init.c | 10 ++-
src/mpid/common/sched/mpid_sched.c | 13 ++-
src/mpid/pamid/include/mpidimpl.h | 14 ++-
src/mpid/pamid/src/mpid_progress.c | 118 +++++++++++++++++---
13 files changed, 357 insertions(+), 85 deletions(-)
hooks/post-receive
--
MPICH primary repository
1
0
[mpich] MPICH primary repository branch, master, updated. v3.2b4-98-g4551de1
by noreply@mpich.org 10 Aug '15
by noreply@mpich.org 10 Aug '15
10 Aug '15
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 4551de14b1d752a9c7be49df4a9e70776addd02f (commit)
from 6f020c71b5f6349b3b616280ba9c24ed7988de40 (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/4551de14b1d752a9c7be49df4a9e70776…
commit 4551de14b1d752a9c7be49df4a9e70776addd02f
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Sun Aug 9 22:19:50 2015 -0500
Keep track of how many progress hooks are currently registered.
Here we add a counter to keep track of how many progress hooks
currently registered. Therefore, when we trigger progress hooks,
inside progress engine, we do not need to check all MAX_PROGRESS_HOOKS
number of slots.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
index 1dfbcdc..380fd45 100644
--- a/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
+++ b/src/mpid/ch3/channels/nemesis/src/ch3_progress.c
@@ -87,6 +87,7 @@ static qn_ent_t *qn_head = NULL;
#define MAX_PROGRESS_HOOKS 16
typedef int (*progress_func_ptr_t) (int* made_progress);
static progress_func_ptr_t progress_hooks[MAX_PROGRESS_HOOKS] = { NULL };
+static int total_progress_hook_cnt = 0; /* Keep track of how many progress hooks are currently registered */
#ifdef HAVE_SIGNAL
static void sigusr1_handler(int sig)
@@ -302,6 +303,10 @@ int MPIDI_CH3I_Progress_register_hook(int (*progress_fn)(int*))
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] == NULL) {
progress_hooks[i] = progress_fn;
+
+ total_progress_hook_cnt++;
+ MPIU_Assert(total_progress_hook_cnt <= MAX_PROGRESS_HOOKS);
+
break;
}
}
@@ -337,6 +342,10 @@ int MPIDI_CH3I_Progress_deregister_hook(int (*progress_fn)(int*))
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] == progress_fn) {
progress_hooks[i] = NULL;
+
+ total_progress_hook_cnt--;
+ MPIU_Assert(total_progress_hook_cnt >= 0);
+
break;
}
}
@@ -434,6 +443,7 @@ int MPIDI_CH3I_Progress (MPID_Progress_state *progress_state, int is_blocking)
int in_fbox = 0;
MPIDI_VC_t *vc;
int i;
+ int called_progress_hook_cnt = 0;
do /* receive progress */
{
@@ -533,12 +543,17 @@ int MPIDI_CH3I_Progress (MPID_Progress_state *progress_state, int is_blocking)
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
}
+ called_progress_hook_cnt = 0;
for (i = 0; i < MAX_PROGRESS_HOOKS; i++) {
if (progress_hooks[i] != NULL) {
mpi_errno = progress_hooks[i](&made_progress);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
if (made_progress)
MPIDI_CH3_Progress_signal_completion();
+
+ called_progress_hook_cnt++;
+ if (called_progress_hook_cnt == total_progress_hook_cnt)
+ break;
}
}
-----------------------------------------------------------------------
Summary of changes:
src/mpid/ch3/channels/nemesis/src/ch3_progress.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
hooks/post-receive
--
MPICH primary repository
1
0
[mpich] MPICH primary repository branch, master, updated. v3.2b4-97-g6f020c7
by noreply@mpich.org 10 Aug '15
by noreply@mpich.org 10 Aug '15
10 Aug '15
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 6f020c71b5f6349b3b616280ba9c24ed7988de40 (commit)
via 7da26cd82a0826c4581b4e357a66eb1cbee6c8bc (commit)
via e204ed26d4c07e5b6f6b14f0f32b1a47c6cc72e9 (commit)
via 9c17714a7fe3b4233cc50962e71c6ca7527d521b (commit)
from 40b1483fb31d9207644783a2574b08149dfa594b (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/6f020c71b5f6349b3b616280ba9c24ed7…
commit 6f020c71b5f6349b3b616280ba9c24ed7988de40
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Mon Aug 10 16:46:19 2015 -0500
Increase time limit of some GACC-based RMA tests to 4 min.
In 40b1483fb31d9207644783a2574b08149dfa594b, we reduced the value
of MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD to 64K by measuring with
an one-to-all benchmark involving PUT operations on MXM. This effects
the performance of some GACC-based tests. Here we increase the time
limit of those tests to 4 min.
The default value of MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD is just
a reference value according the one-to-all PUT tests. In a real
application, user should tune the value depending on different
operations and communication patterns.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/test/mpi/rma/testlist.in b/test/mpi/rma/testlist.in
index c824afd..de7b025 100644
--- a/test/mpi/rma/testlist.in
+++ b/test/mpi/rma/testlist.in
@@ -32,10 +32,10 @@ lock_dt 2
lock_dt_flush 2
lock_dt_flushlocal 2
lockall_dt 4
-lockall_dt_flush 4
-lockall_dt_flushall 4
-lockall_dt_flushlocal 4
-lockall_dt_flushlocalall 4
+lockall_dt_flush 4 timeLimit=240
+lockall_dt_flushall 4 timeLimit=240
+lockall_dt_flushlocal 4 timeLimit=240
+lockall_dt_flushlocalall 4 timeLimit=240
lock_contention_dt 4
transpose4 2
fetchandadd 7
http://git.mpich.org/mpich.git/commitdiff/7da26cd82a0826c4581b4e357a66eb1cb…
commit 7da26cd82a0826c4581b4e357a66eb1cbee6c8bc
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Mon Aug 10 14:47:53 2015 -0500
Bug-fix on RMA working with asynchronous thread.
In RMA operation routines, when the total number of active internal
requests hits the upper bound, we let the process to poke the progress
engine in a while loop until the number of active requests is reduced.
However, when ASYNC_PROGRESS is on, this can cause the deadlock situation
in the main thread. Because poking progress engine is a nonblocking call,
it will not yield CPU to async thread. If the async thread already starts
receiving the last packet before main thread starts poking the progress
engine, then main thread will not receive any more packets, which makes
the while loop endlessly running. Here we fix this issue by replacing
nonblocking progress engine call with blocking progress engine call.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/src/ch3u_rma_ops.c b/src/mpid/ch3/src/ch3u_rma_ops.c
index 91df74b..95f153f 100644
--- a/src/mpid/ch3/src/ch3u_rma_ops.c
+++ b/src/mpid/ch3/src/ch3u_rma_ops.c
@@ -194,7 +194,7 @@ int MPIDI_CH3I_Put(const void *origin_addr, int origin_count, MPI_Datatype
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- mpi_errno = poke_progress_engine();
+ mpi_errno = wait_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
}
@@ -363,7 +363,7 @@ int MPIDI_CH3I_Get(void *origin_addr, int origin_count, MPI_Datatype
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- mpi_errno = poke_progress_engine();
+ mpi_errno = wait_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
}
@@ -574,7 +574,7 @@ int MPIDI_CH3I_Accumulate(const void *origin_addr, int origin_count, MPI_Datatyp
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- mpi_errno = poke_progress_engine();
+ mpi_errno = wait_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
}
@@ -826,7 +826,7 @@ int MPIDI_CH3I_Get_accumulate(const void *origin_addr, int origin_count,
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- mpi_errno = poke_progress_engine();
+ mpi_errno = wait_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
}
@@ -1073,7 +1073,7 @@ int MPID_Compare_and_swap(const void *origin_addr, const void *compare_addr,
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- mpi_errno = poke_progress_engine();
+ mpi_errno = wait_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
}
@@ -1215,7 +1215,7 @@ int MPID_Fetch_and_op(const void *origin_addr, void *result_addr,
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- mpi_errno = poke_progress_engine();
+ mpi_errno = wait_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
}
http://git.mpich.org/mpich.git/commitdiff/e204ed26d4c07e5b6f6b14f0f32b1a47c…
commit e204ed26d4c07e5b6f6b14f0f32b1a47c6cc72e9
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Mon Aug 10 14:40:59 2015 -0500
Add an assert to check MPIDI_CH3I_RMA_Active_req_cnt.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/src/ch3u_handle_op_req.c b/src/mpid/ch3/src/ch3u_handle_op_req.c
index 5b8af99..6e6283f 100644
--- a/src/mpid/ch3/src/ch3u_handle_op_req.c
+++ b/src/mpid/ch3/src/ch3u_handle_op_req.c
@@ -29,6 +29,7 @@ int MPIDI_CH3_Req_handler_rma_op_complete(MPID_Request * sreq)
MPID_Win_get_ptr(sreq->dev.source_win_handle, win_ptr);
MPIU_Assert(win_ptr != NULL);
MPIDI_CH3I_RMA_Active_req_cnt--;
+ MPIU_Assert(MPIDI_CH3I_RMA_Active_req_cnt >= 0);
if (sreq->dev.request_handle != MPI_REQUEST_NULL) {
/* get user request */
http://git.mpich.org/mpich.git/commitdiff/9c17714a7fe3b4233cc50962e71c6ca75…
commit 9c17714a7fe3b4233cc50962e71c6ca7527d521b
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Mon Aug 10 14:06:17 2015 -0500
Delete redundant function call.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index 4355d9d..bc598ea 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -517,12 +517,6 @@ static inline int MPIDI_CH3I_Win_get_op(MPID_Win * win_ptr, MPIDI_RMA_Op_t ** e)
if (new_ptr != NULL)
break;
- MPIR_T_PVAR_TIMER_START(RMA, rma_rmaqueue_alloc);
- new_ptr = MPIDI_CH3I_Win_op_alloc(win_ptr);
- MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_alloc);
- if (new_ptr != NULL)
- break;
-
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_aggressive(win_ptr);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
-----------------------------------------------------------------------
Summary of changes:
src/mpid/ch3/include/mpid_rma_oplist.h | 6 ------
src/mpid/ch3/src/ch3u_handle_op_req.c | 1 +
src/mpid/ch3/src/ch3u_rma_ops.c | 12 ++++++------
test/mpi/rma/testlist.in | 8 ++++----
4 files changed, 11 insertions(+), 16 deletions(-)
hooks/post-receive
--
MPICH primary repository
1
0
[mpich] MPICH primary repository branch, master, updated. v3.2b4-93-g40b1483
by noreply@mpich.org 09 Aug '15
by noreply@mpich.org 09 Aug '15
09 Aug '15
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 40b1483fb31d9207644783a2574b08149dfa594b (commit)
via 40050ca60d1ae09645903366b051673d1795fbf2 (commit)
via bcb3ad54366c7efb15ab9d0c6cc2d26cfaaf7753 (commit)
from bead85d38e01c7baf66c36aa6372a1272eab0176 (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/40b1483fb31d9207644783a2574b08149…
commit 40b1483fb31d9207644783a2574b08149dfa594b
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Sun Aug 9 15:14:33 2015 -0500
Reduce default value of MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD.
The original default value of MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD
is too high and can cause the internal resources to be used up when
all processes within one node have lots of internal requests. Here
we reduce this default value.
We set the value by meansuing one-to-all communication between MXM
nodes, when one origin process issues operations to 8 targets. The
performance achieves steady state when the origin processes issues
~16K operations to each target, which means the network is saturated
at 16K operations. Here, instead of setting value as 16K*8, we set
the default value as 64K, trying to keep the resources used by
requests as small as possible. Note that in future after we add the
support for hardware RDMA operations to RMA infrastructure, the
pressure on request resources should be reduced a lot.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index 0e78149..4361ccd 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -14,7 +14,7 @@ cvars:
- name : MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD
category : CH3
type : int
- default : 2097152
+ default : 65536
class : none
verbosity : MPI_T_VERBOSITY_USER_BASIC
scope : MPI_T_SCOPE_ALL_EQ
http://git.mpich.org/mpich.git/commitdiff/40050ca60d1ae09645903366b051673d1…
commit 40050ca60d1ae09645903366b051673d1795fbf2
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Sun Aug 9 15:12:58 2015 -0500
Make active_req_cnt as a global variable.
Here we use variable 'active_req_cnt' to keep track of internal requests
used by RMA infrastructure, and prevent them from using up resources.
This counter should be defined as a global variable for all windows,
not a per-window variable, here we fix this.
Note that here we cannot make the assert check on this variable in ending
synchronization calls anymore. However, since we check variable
'num_pkts_wait_for_local_completion' per target in the ending synchronization
calls, it should be OK.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/include/mpidpre.h b/src/mpid/ch3/include/mpidpre.h
index 45490c4..81ca4b4 100644
--- a/src/mpid/ch3/include/mpidpre.h
+++ b/src/mpid/ch3/include/mpidpre.h
@@ -332,9 +332,6 @@ typedef struct MPIDI_Win_basic_info {
int num_targets_with_pending_net_ops; /* keep track of number of \
targets that has non-empty \
net pending op list. */ \
- int active_req_cnt; /* keep track of number of active requests in \
- current epoch, i.e., number of issued but \
- incomplete RMA operations. */ \
int *start_ranks_in_win_grp; \
int start_grp_size; \
int lock_all_assert; \
@@ -354,6 +351,8 @@ typedef struct MPIDI_Win_basic_info {
extern struct MPID_Win *MPIDI_RMA_Win_active_list_head, *MPIDI_RMA_Win_inactive_list_head;
+extern int MPIDI_CH3I_RMA_Active_req_cnt;
+
#ifdef MPIDI_CH3_WIN_DECL
#define MPID_DEV_WIN_DECL \
MPIDI_DEV_WIN_DECL \
diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index 6ffd034..630ea70 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -691,7 +691,7 @@ static inline int check_and_set_req_completion(MPID_Win * win_ptr, MPIDI_RMA_Tar
(*op_completed) = TRUE;
}
else {
- win_ptr->active_req_cnt += incomplete_req_cnt;
+ MPIDI_CH3I_RMA_Active_req_cnt += incomplete_req_cnt;
target->num_pkts_wait_for_local_completion += incomplete_req_cnt;
}
diff --git a/src/mpid/ch3/src/ch3u_handle_op_req.c b/src/mpid/ch3/src/ch3u_handle_op_req.c
index 269089f..5b8af99 100644
--- a/src/mpid/ch3/src/ch3u_handle_op_req.c
+++ b/src/mpid/ch3/src/ch3u_handle_op_req.c
@@ -28,7 +28,7 @@ int MPIDI_CH3_Req_handler_rma_op_complete(MPID_Request * sreq)
/* get window, decrement active request cnt on window */
MPID_Win_get_ptr(sreq->dev.source_win_handle, win_ptr);
MPIU_Assert(win_ptr != NULL);
- win_ptr->active_req_cnt--;
+ MPIDI_CH3I_RMA_Active_req_cnt--;
if (sreq->dev.request_handle != MPI_REQUEST_NULL) {
/* get user request */
diff --git a/src/mpid/ch3/src/ch3u_rma_ops.c b/src/mpid/ch3/src/ch3u_rma_ops.c
index 65a2eb0..91df74b 100644
--- a/src/mpid/ch3/src/ch3u_rma_ops.c
+++ b/src/mpid/ch3/src/ch3u_rma_ops.c
@@ -192,8 +192,8 @@ int MPIDI_CH3I_Put(const void *origin_addr, int origin_count, MPI_Datatype
MPIU_ERR_POP(mpi_errno);
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
- win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- while (win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
mpi_errno = poke_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
@@ -361,8 +361,8 @@ int MPIDI_CH3I_Get(void *origin_addr, int origin_count, MPI_Datatype
MPIU_ERR_POP(mpi_errno);
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
- win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- while (win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
mpi_errno = poke_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
@@ -572,8 +572,8 @@ int MPIDI_CH3I_Accumulate(const void *origin_addr, int origin_count, MPI_Datatyp
MPIU_ERR_POP(mpi_errno);
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
- win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- while (win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
mpi_errno = poke_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
@@ -824,8 +824,8 @@ int MPIDI_CH3I_Get_accumulate(const void *origin_addr, int origin_count,
MPIU_ERR_POP(mpi_errno);
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
- win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- while (win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
mpi_errno = poke_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
@@ -1071,8 +1071,8 @@ int MPID_Compare_and_swap(const void *origin_addr, const void *compare_addr,
MPIU_ERR_POP(mpi_errno);
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
- win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- while (win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
mpi_errno = poke_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
@@ -1213,8 +1213,8 @@ int MPID_Fetch_and_op(const void *origin_addr, void *result_addr,
MPIU_ERR_POP(mpi_errno);
if (MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD >= 0 &&
- win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
- while (win_ptr->active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
+ while (MPIDI_CH3I_RMA_Active_req_cnt >= MPIR_CVAR_CH3_RMA_ACTIVE_REQ_THRESHOLD) {
mpi_errno = poke_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index 5aa39f2..0e78149 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -352,7 +352,7 @@ static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * targ
}
if (op_completed == FALSE) {
- if (win_ptr->active_req_cnt > MPIR_CVAR_CH3_RMA_POKE_PROGRESS_REQ_THRESHOLD) {
+ if (MPIDI_CH3I_RMA_Active_req_cnt > MPIR_CVAR_CH3_RMA_POKE_PROGRESS_REQ_THRESHOLD) {
mpi_errno = poke_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index 19dca35..9782422 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -680,8 +680,6 @@ int MPID_Win_fence(int assert, MPID_Win * win_ptr)
}
finish_fence:
- MPIU_Assert(win_ptr->active_req_cnt == 0);
-
/* Ensure ordering of load/store operations. */
if (win_ptr->shm_allocated == TRUE) {
OPA_read_write_barrier();
@@ -935,8 +933,6 @@ int MPID_Win_start(MPID_Group * group_ptr, int assert, MPID_Win * win_ptr)
win_ptr->states.access_state = MPIDI_RMA_PSCW_GRANTED;
}
- MPIU_Assert(win_ptr->active_req_cnt == 0);
-
/* Ensure ordering of load/store operations. */
if (win_ptr->shm_allocated == TRUE) {
OPA_read_write_barrier();
@@ -1023,8 +1019,6 @@ int MPID_Win_complete(MPID_Win * win_ptr)
MPIU_Free(win_ptr->start_ranks_in_win_grp);
win_ptr->start_ranks_in_win_grp = NULL;
- MPIU_Assert(win_ptr->active_req_cnt == 0);
-
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_WIN_COMPLETE);
return mpi_errno;
@@ -1561,8 +1555,6 @@ int MPID_Win_lock_all(int assert, MPID_Win * win_ptr)
}
}
- MPIU_Assert(win_ptr->active_req_cnt == 0);
-
/* Ensure ordering of load/store operations. */
if (win_ptr->shm_allocated == TRUE) {
OPA_read_write_barrier();
@@ -1700,8 +1692,6 @@ int MPID_Win_unlock_all(MPID_Win * win_ptr)
/* reset lock_all assert on window. */
win_ptr->lock_all_assert = 0;
- MPIU_Assert(win_ptr->active_req_cnt == 0);
-
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_WIN_UNLOCK_ALL);
return mpi_errno;
@@ -1738,8 +1728,6 @@ int MPID_Win_flush_all(MPID_Win * win_ptr)
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
- MPIU_Assert(win_ptr->active_req_cnt == 0);
-
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPIDI_STATE_MPID_WIN_FLUSH_ALL);
return mpi_errno;
@@ -1776,8 +1764,6 @@ int MPID_Win_flush_local_all(MPID_Win * win_ptr)
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
- MPIU_Assert(win_ptr->active_req_cnt == 0);
-
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_WIN_FLUSH_LOCAL_ALL);
return mpi_errno;
diff --git a/src/mpid/ch3/src/mpid_rma.c b/src/mpid/ch3/src/mpid_rma.c
index 025fbba..e3c0e54 100644
--- a/src/mpid/ch3/src/mpid_rma.c
+++ b/src/mpid/ch3/src/mpid_rma.c
@@ -43,6 +43,11 @@ MPIU_THREADSAFE_INIT_DECL(initRMAoptions);
MPID_Win *MPIDI_RMA_Win_active_list_head = NULL, *MPIDI_RMA_Win_inactive_list_head = NULL;
+/* This variable keeps track of number of active RMA requests, i.e., total number of issued
+ * but incomplete RMA operations. We use this variable to control the resources used up by
+ * internal requests in RMA infrastructure. */
+int MPIDI_CH3I_RMA_Active_req_cnt = 0;
+
static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model, MPID_Info * info,
MPID_Comm * comm_ptr, MPID_Win ** win_ptr);
@@ -289,7 +294,6 @@ static int win_init(MPI_Aint size, int disp_unit, int create_flavor, int model,
(*win_ptr)->states.access_state = MPIDI_RMA_NONE;
(*win_ptr)->states.exposure_state = MPIDI_RMA_NONE;
(*win_ptr)->num_targets_with_pending_net_ops = 0;
- (*win_ptr)->active_req_cnt = 0;
(*win_ptr)->start_ranks_in_win_grp = NULL;
(*win_ptr)->start_grp_size = 0;
(*win_ptr)->lock_all_assert = 0;
http://git.mpich.org/mpich.git/commitdiff/bcb3ad54366c7efb15ab9d0c6cc2d26cf…
commit bcb3ad54366c7efb15ab9d0c6cc2d26cfaaf7753
Author: Pavan Balaji <balaji(a)anl.gov>
Date: Sat Aug 8 01:51:41 2015 -0500
RMA code Cleanup.
Simplify the code of checking window state to a macro.
Signed-off-by: Xin Zhao <xinzhao3(a)illinois.edu>
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index f07bb1a..5aa39f2 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -47,46 +47,18 @@ cvars:
static inline int check_and_switch_target_state(MPID_Win * win_ptr, MPIDI_RMA_Target_t * target,
int *is_able_to_issue, int *made_progress);
-static inline int check_and_switch_window_state(MPID_Win * win_ptr, int *is_able_to_issue);
static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * target,
int *made_progress);
static inline int issue_ops_win(MPID_Win * win_ptr, int *made_progress);
-/* check if we can switch window-wide state: FENCE_ISSUED, PSCW_ISSUED, LOCK_ALL_ISSUED */
-#undef FUNCNAME
-#define FUNCNAME check_and_switch_window_state
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-static inline int check_and_switch_window_state(MPID_Win * win_ptr, int *is_able_to_issue)
-{
- int mpi_errno = MPI_SUCCESS;
- MPIDI_STATE_DECL(MPID_STATE_CHECK_AND_SWITCH_WINDOW_STATE);
-
- MPIDI_RMA_FUNC_ENTER(MPID_STATE_CHECK_AND_SWITCH_WINDOW_STATE);
-
- (*is_able_to_issue) = 0;
-
- switch (win_ptr->states.access_state) {
- case MPIDI_RMA_PER_TARGET:
- case MPIDI_RMA_LOCK_ALL_CALLED:
- case MPIDI_RMA_FENCE_GRANTED:
- case MPIDI_RMA_PSCW_GRANTED:
- case MPIDI_RMA_LOCK_ALL_GRANTED:
- (*is_able_to_issue) = 1;
- break;
-
- default:
- break;
- } /* end of switch */
- fn_exit:
- MPIDI_RMA_FUNC_EXIT(MPID_STATE_CHECK_AND_SWITCH_WINDOW_STATE);
- return mpi_errno;
- /* --BEGIN ERROR HANDLING-- */
- fn_fail:
- goto fn_exit;
- /* --END ERROR HANDLING-- */
-}
+/* This macro checks if window state is ready for issuing RMA operations. */
+#define WIN_READY(win_) \
+ ((win_)->states.access_state == MPIDI_RMA_PER_TARGET || \
+ (win_)->states.access_state == MPIDI_RMA_LOCK_ALL_CALLED || \
+ (win_)->states.access_state == MPIDI_RMA_FENCE_GRANTED || \
+ (win_)->states.access_state == MPIDI_RMA_PSCW_GRANTED || \
+ (win_)->states.access_state == MPIDI_RMA_LOCK_ALL_GRANTED)
#undef FUNCNAME
@@ -608,11 +580,8 @@ int MPIDI_CH3I_RMA_Make_progress_target(MPID_Win * win_ptr, int target_rank, int
* is registered / executed before NBC progress, it will cause the progress engine
* to re-entrant RMA progress endlessly. */
- /* check window state */
- mpi_errno = check_and_switch_window_state(win_ptr, &is_able_to_issue);
- if (mpi_errno != MPI_SUCCESS)
- MPIU_ERR_POP(mpi_errno);
- if (!is_able_to_issue) {
+ /* check window state, if it is not ready, poke the progress engine */
+ if (!WIN_READY(win_ptr)) {
mpi_errno = poke_progress_engine();
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
@@ -658,7 +627,6 @@ int MPIDI_CH3I_RMA_Make_progress_target(MPID_Win * win_ptr, int target_rank, int
int MPIDI_CH3I_RMA_Make_progress_win(MPID_Win * win_ptr, int *made_progress)
{
int mpi_errno = MPI_SUCCESS;
- int is_able_to_issue = 0;
int temp_progress = 0;
(*made_progress) = 0;
@@ -671,11 +639,8 @@ int MPIDI_CH3I_RMA_Make_progress_win(MPID_Win * win_ptr, int *made_progress)
* is registered / executed before NBC progress, it will cause the progress engine
* to re-entrant RMA progress endlessly. */
- /* check and try to switch window state */
- mpi_errno = check_and_switch_window_state(win_ptr, &is_able_to_issue);
- if (mpi_errno != MPI_SUCCESS)
- MPIU_ERR_POP(mpi_errno);
- if (!is_able_to_issue) {
+ /* check and try to switch window state, if it is not ready, poke the progress engine */
+ if (!WIN_READY(win_ptr)) {
mpi_errno = poke_progress_engine();
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
@@ -711,18 +676,13 @@ int MPIDI_CH3I_RMA_Make_progress_global(int *made_progress)
for (win_ptr = MPIDI_RMA_Win_active_list_head; win_ptr; win_ptr = win_ptr->next) {
int temp_progress = 0;
- int is_able_to_issue = 0;
if (win_ptr->states.access_state == MPIDI_RMA_NONE)
continue;
/* check and try to switch window state */
- mpi_errno = check_and_switch_window_state(win_ptr, &is_able_to_issue);
- if (mpi_errno != MPI_SUCCESS)
- MPIU_ERR_POP(mpi_errno);
- if (!is_able_to_issue) {
+ if (!WIN_READY(win_ptr))
continue;
- }
mpi_errno = issue_ops_win(win_ptr, &temp_progress);
if (mpi_errno != MPI_SUCCESS)
-----------------------------------------------------------------------
Summary of changes:
src/mpid/ch3/include/mpidpre.h | 5 +-
src/mpid/ch3/include/mpidrma.h | 2 +-
src/mpid/ch3/src/ch3u_handle_op_req.c | 2 +-
src/mpid/ch3/src/ch3u_rma_ops.c | 24 ++++++------
src/mpid/ch3/src/ch3u_rma_progress.c | 68 +++++++--------------------------
src/mpid/ch3/src/ch3u_rma_sync.c | 14 -------
src/mpid/ch3/src/mpid_rma.c | 6 ++-
7 files changed, 35 insertions(+), 86 deletions(-)
hooks/post-receive
--
MPICH primary repository
1
0
[mpich] MPICH primary repository branch, master, updated. v3.2b4-90-gbead85d
by noreply@mpich.org 09 Aug '15
by noreply@mpich.org 09 Aug '15
09 Aug '15
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 bead85d38e01c7baf66c36aa6372a1272eab0176 (commit)
via 022928ff7314f8fddfd3c0e913b11310e2be547a (commit)
via 68b26e3c7d3ba336554f3bd8bf6cf138313180cb (commit)
from 18ddb4c38036d92a2f7181eccc6e403299f81efd (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/bead85d38e01c7baf66c36aa6372a1272…
commit bead85d38e01c7baf66c36aa6372a1272eab0176
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Fri Aug 7 12:58:45 2015 -0500
Use counter num_ops_flush_not_issued to control issuing of FLUSH messages.
Here we use counter 'num_ops_flush_not_issued' to count number of operations
that are issued out but no FLUSH message issued afterwards yet to detect
their remote completion. When we reach the tail of the pending list, if
this counter is non-zero, we will issue a FLUSH message and reset the
counter to zero; if the counter is zero, which means there is no operation
that needs detecting remote completion, then we do not need to issue FLUSH
message at all.
Originally we use a flag 'put_acc_issued' to achieve the similiar purpose,
but that is not a clean design and miss some cases. This counter is a better
design on saving FLUSH messages as many as possible.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index ab7aca9..4355d9d 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -36,6 +36,7 @@ MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_rmaqueue_alloc);
(target_)->num_pkts_wait_for_local_completion == 0) { \
local_completed_ = 1; \
if ((target_)->sync.sync_flag == MPIDI_RMA_SYNC_NONE && \
+ (target_)->num_ops_flush_not_issued == 0 && \
(target_)->sync.outstanding_acks == 0) \
remote_completed_ = 1; \
} \
@@ -265,12 +266,12 @@ static inline MPIDI_RMA_Target_t *MPIDI_CH3I_Win_target_alloc(MPID_Win * win_ptr
e->lock_type = MPID_LOCK_NONE;
e->lock_mode = 0;
e->win_complete_flag = 0;
- e->put_acc_issued = 0;
e->sync.sync_flag = MPIDI_RMA_SYNC_NONE;
e->sync.outstanding_acks = 0;
e->num_pkts_wait_for_local_completion = 0;
+ e->num_ops_flush_not_issued = 0;
return e;
}
diff --git a/src/mpid/ch3/include/mpid_rma_types.h b/src/mpid/ch3/include/mpid_rma_types.h
index 251fe11..4e3b9e4 100644
--- a/src/mpid/ch3/include/mpid_rma_types.h
+++ b/src/mpid/ch3/include/mpid_rma_types.h
@@ -74,8 +74,6 @@ typedef struct MPIDI_RMA_Target {
int lock_type; /* NONE, SHARED, EXCLUSIVE */
int lock_mode; /* e.g., MODE_NO_CHECK */
int win_complete_flag;
- int put_acc_issued; /* indicate if PUT/ACC is issued in this epoch
- * after the previous synchronization calls. */
/* The target structure is free to be cleaned up when all of the
* following conditions hold true:
@@ -96,6 +94,9 @@ typedef struct MPIDI_RMA_Target {
/* number of packets that are waiting for local completion */
int num_pkts_wait_for_local_completion;
+ /* number of operations that does not have a FLUSH issued afterwards */
+ int num_ops_flush_not_issued;
+
MPIDI_RMA_Pool_type_t pool_type;
} MPIDI_RMA_Target_t;
diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index a879cda..6ffd034 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -751,7 +751,10 @@ static inline int handle_lock_ack_with_op(MPID_Win * win_ptr,
target->next_op_to_issue = op->next;
if (target->next_op_to_issue == NULL) {
- if (op_flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH || op_flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
+ if (((target->sync.sync_flag == MPIDI_RMA_SYNC_FLUSH) &&
+ (op_flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH)) ||
+ ((target->sync.sync_flag == MPIDI_RMA_SYNC_UNLOCK) &&
+ (op_flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK))) {
/* We are done with ending sync, unset target's sync_flag. */
target->sync.sync_flag = MPIDI_RMA_SYNC_NONE;
}
@@ -868,8 +871,6 @@ static inline int MPIDI_CH3I_RMA_Handle_ack(MPID_Win * win_ptr, int target_rank)
t->sync.outstanding_acks--;
MPIU_Assert(t->sync.outstanding_acks >= 0);
- t->put_acc_issued = 0; /* reset PUT_ACC_FLAG after FLUSH is completed */
-
fn_exit:
return mpi_errno;
fn_fail:
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index 26d8cf4..f07bb1a 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -177,9 +177,11 @@ static inline int check_and_switch_target_state(MPID_Win * win_ptr, MPIDI_RMA_Ta
if (target->win_complete_flag) {
if (target->pending_net_ops_list_head == NULL) {
MPIDI_CH3_Pkt_flags_t flags = MPIDI_CH3_PKT_FLAG_NONE;
- if (target->sync.sync_flag == MPIDI_RMA_SYNC_FLUSH && target->put_acc_issued) {
+ if (target->sync.sync_flag == MPIDI_RMA_SYNC_FLUSH &&
+ target->num_ops_flush_not_issued > 0) {
flags |= MPIDI_CH3_PKT_FLAG_RMA_FLUSH;
target->sync.outstanding_acks++;
+ target->num_ops_flush_not_issued = 0;
}
mpi_errno = send_decr_at_cnt_msg(target->target_rank, win_ptr, flags);
@@ -195,9 +197,10 @@ static inline int check_and_switch_target_state(MPID_Win * win_ptr, MPIDI_RMA_Ta
else if (target->sync.sync_flag == MPIDI_RMA_SYNC_FLUSH) {
if (target->pending_net_ops_list_head == NULL) {
if (target->target_rank != rank) {
- if (target->put_acc_issued) {
+ if (target->num_ops_flush_not_issued > 0) {
target->sync.outstanding_acks++;
+ target->num_ops_flush_not_issued = 0;
mpi_errno = send_flush_msg(target->target_rank, win_ptr);
if (mpi_errno != MPI_SUCCESS)
@@ -220,15 +223,12 @@ static inline int check_and_switch_target_state(MPID_Win * win_ptr, MPIDI_RMA_Ta
}
else {
MPIDI_CH3_Pkt_flags_t flag = MPIDI_CH3_PKT_FLAG_NONE;
- if (!target->put_acc_issued) {
- /* We did not issue PUT/ACC since the last
- * synchronization call, therefore here we
- * don't need ACK back */
-
+ if (target->num_ops_flush_not_issued == 0) {
flag = MPIDI_CH3_PKT_FLAG_RMA_UNLOCK_NO_ACK;
}
else {
target->sync.outstanding_acks++;
+ target->num_ops_flush_not_issued = 0;
}
mpi_errno = send_unlock_msg(target->target_rank, win_ptr, flag);
if (mpi_errno != MPI_SUCCESS)
@@ -295,6 +295,8 @@ static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * targ
break;
}
+ target->num_ops_flush_not_issued++;
+
flags = MPIDI_CH3_PKT_FLAG_NONE;
if (first_op) {
@@ -312,9 +314,14 @@ static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * targ
first_op = 0;
}
- /* piggyback FLUSH on every OP if ordered flush is not guaranteed. */
- if (!MPIDI_CH3U_Win_pkt_orderings.am_flush_ordered)
+ /* piggyback FLUSH on current OP if one of the following
+ * conditions meet:
+ * (1) ordered flush is not guaranteed;
+ * (2) operation is a READ op (GET, GACC, FOP, CAS) */
+ if ((!MPIDI_CH3U_Win_pkt_orderings.am_flush_ordered) ||
+ MPIDI_CH3I_RMA_PKT_IS_READ_OP(curr_op->pkt)) {
flags |= MPIDI_CH3_PKT_FLAG_RMA_FLUSH;
+ }
if (curr_op->next == NULL) {
/* piggyback on last OP. */
@@ -335,8 +342,10 @@ static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * targ
/* only increase ack counter when FLUSH or UNLOCK flag is set,
* but without LOCK piggyback. */
if (((flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH)
- || (flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK)))
+ || (flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK))) {
target->sync.outstanding_acks++;
+ target->num_ops_flush_not_issued = 0;
+ }
mpi_errno = issue_rma_op(curr_op, win_ptr, target, flags);
if (mpi_errno != MPI_SUCCESS)
@@ -344,11 +353,6 @@ static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * targ
(*made_progress) = 1;
- if (!MPIDI_CH3I_RMA_PKT_IS_READ_OP(curr_op->pkt)) {
- target->put_acc_issued = 1; /* set PUT_ACC_FLAG when sending
- * PUT/ACC operation. */
- }
-
if (flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_SHARED ||
flags & MPIDI_CH3_PKT_FLAG_RMA_LOCK_EXCLUSIVE) {
/* If this operation is piggybacked with LOCK,
@@ -361,7 +365,10 @@ static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * targ
target->next_op_to_issue = curr_op->next;
if (target->next_op_to_issue == NULL) {
- if (flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH || flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK) {
+ if (((target->sync.sync_flag == MPIDI_RMA_SYNC_FLUSH) &&
+ (flags & MPIDI_CH3_PKT_FLAG_RMA_FLUSH)) ||
+ ((target->sync.sync_flag == MPIDI_RMA_SYNC_UNLOCK) &&
+ (flags & MPIDI_CH3_PKT_FLAG_RMA_UNLOCK))) {
/* We are done with ending sync, unset target's sync_flag. */
target->sync.sync_flag = MPIDI_RMA_SYNC_NONE;
}
http://git.mpich.org/mpich.git/commitdiff/022928ff7314f8fddfd3c0e913b11310e…
commit 022928ff7314f8fddfd3c0e913b11310e2be547a
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Fri Aug 7 09:20:22 2015 -0500
Free RMA op object immediately after it is issued out.
Originally we maintain RMA operations after they are
issued out in order to detect the local completion of
those operations, since operation structure will be
freed in the request completion cb when operation is
locally completed. However, we do not need to maintain
operation structure at all after the operation is
issued out, instead, we can just use a counter to keep
track of number of operations that are waiting for
local completion, and decrement that counter in the
request completion cb.
In this patch, we delete all the code that related
to maintain ssued but incomplete operation structure.
Therefore, operation objects exist only when synchronization
is not finished and operations stay in the pending list.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/include/mpid_rma_oplist.h b/src/mpid/ch3/include/mpid_rma_oplist.h
index 4961571..ab7aca9 100644
--- a/src/mpid/ch3/include/mpid_rma_oplist.h
+++ b/src/mpid/ch3/include/mpid_rma_oplist.h
@@ -10,7 +10,6 @@
#include "mpl_utlist.h"
#include "mpid_rma_types.h"
-int MPIDI_CH3I_RMA_Free_ops_before_completion(MPID_Win * win_ptr);
int MPIDI_CH3I_RMA_Cleanup_ops_aggressive(MPID_Win * win_ptr);
int MPIDI_CH3I_RMA_Cleanup_target_aggressive(MPID_Win * win_ptr, MPIDI_RMA_Target_t ** target);
int MPIDI_CH3I_RMA_Make_progress_target(MPID_Win * win_ptr, int target_rank, int *made_progress);
@@ -21,28 +20,6 @@ extern MPIDI_RMA_Target_t *global_rma_target_pool_head, *global_rma_target_pool_
MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_rmaqueue_alloc);
-#define MPIDI_CH3I_RMA_Get_issued_list_ptr(target_, op_, list_ptr_, mpi_errno_) \
- do { \
- MPI_Datatype target_datatype_; \
- int is_read_; \
- MPIDI_CH3I_RMA_PKT_IS_READ_OP((op_)->pkt, is_read_); \
- MPIDI_CH3_PKT_RMA_GET_TARGET_DATATYPE((op_)->pkt, target_datatype_, mpi_errno_); \
- if ((target_datatype_ != MPI_DATATYPE_NULL && \
- !MPIR_DATATYPE_IS_PREDEFINED(target_datatype_)) || \
- ((op_)->origin_datatype != MPI_DATATYPE_NULL && \
- !MPIR_DATATYPE_IS_PREDEFINED((op_)->origin_datatype)) || \
- ((op_)->result_datatype != MPI_DATATYPE_NULL && \
- !MPIR_DATATYPE_IS_PREDEFINED((op_)->result_datatype))) { \
- list_ptr_ = &((target_)->issued_dt_op_list_head); \
- } \
- else if (!is_read_) { \
- list_ptr_ = &((target_)->issued_write_op_list_head); \
- } \
- else { \
- list_ptr_ = &((target_)->issued_read_op_list_head); \
- } \
- } while (0)
-
/* This macro returns two flags: local_completed and remote_completed,
* to indicate if the completion is reached on this target. */
#define MPIDI_CH3I_RMA_ops_completion(win_, target_, local_completed_, remote_completed_) \
@@ -56,23 +33,12 @@ MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_rmaqueue_alloc);
(target_)->access_state != MPIDI_RMA_LOCK_ISSUED && \
(target_)->pending_net_ops_list_head == NULL && \
(target_)->pending_user_ops_list_head == NULL && \
- (target_)->issued_read_op_list_head == NULL && \
- (target_)->issued_write_op_list_head == NULL && \
- (target_)->issued_dt_op_list_head == NULL) { \
+ (target_)->num_pkts_wait_for_local_completion == 0) { \
local_completed_ = 1; \
if ((target_)->sync.sync_flag == MPIDI_RMA_SYNC_NONE && \
(target_)->sync.outstanding_acks == 0) \
remote_completed_ = 1; \
} \
- \
- if (((target_)->sync.upgrade_flush_local && !remote_completed_) || \
- (!(target_)->sync.upgrade_flush_local && !local_completed_)) { \
- local_completed_ = 0; \
- } \
- else { \
- local_completed_ = 1; \
- } \
- \
} while (0)
@@ -117,19 +83,13 @@ MPIR_T_PVAR_DOUBLE_TIMER_DECL_EXTERN(RMA, rma_rmaqueue_alloc);
\
for (i_ = 0; i_ < (win_ptr_)->num_slots; i_++) { \
for (win_target_ = (win_ptr_)->slots[i_].target_list_head; win_target_;) { \
- int local_ = 0, remote_ = 0; \
+ int local_ = 0, remote_ ATTRIBUTE((unused)) = 0; \
\
- if (win_target_->sync.upgrade_flush_local) \
- total_remote_cnt_++; \
- else \
- total_local_cnt_++; \
+ total_local_cnt_++; \
\
MPIDI_CH3I_RMA_ops_completion((win_ptr_), win_target_, local_, remote_); \
\
- if (win_target_->sync.upgrade_flush_local) \
- remote_completed_targets_ += remote_; \
- else \
- local_completed_targets_ += local_; \
+ local_completed_targets_ += local_; \
\
win_target_ = win_target_->next; \
} \
@@ -242,8 +202,6 @@ static inline MPIDI_RMA_Op_t *MPIDI_CH3I_Win_op_alloc(MPID_Win * win_ptr)
e->origin_datatype = MPI_DATATYPE_NULL;
e->result_datatype = MPI_DATATYPE_NULL;
- e->ref_cnt = 0;
-
return e;
}
@@ -298,9 +256,6 @@ static inline MPIDI_RMA_Target_t *MPIDI_CH3I_Win_target_alloc(MPID_Win * win_ptr
MPL_DL_DELETE(win_ptr->target_pool_head, e);
}
- e->issued_read_op_list_head = NULL;
- e->issued_write_op_list_head = NULL;
- e->issued_dt_op_list_head = NULL;
e->pending_net_ops_list_head = NULL;
e->pending_user_ops_list_head = NULL;
e->next_op_to_issue = NULL;
@@ -314,7 +269,8 @@ static inline MPIDI_RMA_Target_t *MPIDI_CH3I_Win_target_alloc(MPID_Win * win_ptr
e->sync.sync_flag = MPIDI_RMA_SYNC_NONE;
e->sync.outstanding_acks = 0;
- e->sync.upgrade_flush_local = 0;
+
+ e->num_pkts_wait_for_local_completion = 0;
return e;
}
@@ -332,9 +288,6 @@ static inline int MPIDI_CH3I_Win_target_free(MPID_Win * win_ptr, MPIDI_RMA_Targe
/* We enqueue elements to the right pool, so when they get freed
* at window free time, they won't conflict with the global pool
* or other windows */
- MPIU_Assert(e->issued_read_op_list_head == NULL);
- MPIU_Assert(e->issued_write_op_list_head == NULL);
- MPIU_Assert(e->issued_dt_op_list_head == NULL);
MPIU_Assert(e->pending_net_ops_list_head == NULL);
MPIU_Assert(e->pending_user_ops_list_head == NULL);
@@ -569,16 +522,6 @@ static inline int MPIDI_CH3I_Win_get_op(MPID_Win * win_ptr, MPIDI_RMA_Op_t ** e)
if (new_ptr != NULL)
break;
- mpi_errno = MPIDI_CH3I_RMA_Free_ops_before_completion(win_ptr);
- if (mpi_errno != MPI_SUCCESS)
- MPIU_ERR_POP(mpi_errno);
-
- MPIR_T_PVAR_TIMER_START(RMA, rma_rmaqueue_alloc);
- new_ptr = MPIDI_CH3I_Win_op_alloc(win_ptr);
- MPIR_T_PVAR_TIMER_END(RMA, rma_rmaqueue_alloc);
- if (new_ptr != NULL)
- break;
-
mpi_errno = MPIDI_CH3I_RMA_Cleanup_ops_aggressive(win_ptr);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
diff --git a/src/mpid/ch3/include/mpid_rma_types.h b/src/mpid/ch3/include/mpid_rma_types.h
index 3014c0a..251fe11 100644
--- a/src/mpid/ch3/include/mpid_rma_types.h
+++ b/src/mpid/ch3/include/mpid_rma_types.h
@@ -61,13 +61,9 @@ typedef struct MPIDI_RMA_Op {
MPID_Request *ureq;
- int ref_cnt;
} MPIDI_RMA_Op_t;
typedef struct MPIDI_RMA_Target {
- struct MPIDI_RMA_Op *issued_read_op_list_head;
- struct MPIDI_RMA_Op *issued_write_op_list_head;
- struct MPIDI_RMA_Op *issued_dt_op_list_head;
struct MPIDI_RMA_Op *pending_net_ops_list_head; /* pending operations that are waiting for network events */
struct MPIDI_RMA_Op *pending_user_ops_list_head; /* pending operations that are waiting for user events */
struct MPIDI_RMA_Op *next_op_to_issue;
@@ -95,10 +91,11 @@ typedef struct MPIDI_RMA_Target {
/* packets sent out that we are expecting an ack for */
int outstanding_acks;
- /* Marked when FLUSH_LOCAL is upgraded to FLUSH */
- int upgrade_flush_local;
} sync;
+ /* number of packets that are waiting for local completion */
+ int num_pkts_wait_for_local_completion;
+
MPIDI_RMA_Pool_type_t pool_type;
} MPIDI_RMA_Target_t;
diff --git a/src/mpid/ch3/include/mpidpre.h b/src/mpid/ch3/include/mpidpre.h
index 6390bbc..45490c4 100644
--- a/src/mpid/ch3/include/mpidpre.h
+++ b/src/mpid/ch3/include/mpidpre.h
@@ -450,7 +450,7 @@ typedef struct MPIDI_Request {
* and freed when release request. */
MPIDI_msg_sz_t ext_hdr_sz;
- struct MPIDI_RMA_Op *rma_op_ptr;
+ struct MPIDI_RMA_Target *rma_target_ptr;
MPIDI_REQUEST_SEQNUM
diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index 4f5ea28..a879cda 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -644,6 +644,7 @@ static inline int check_and_set_req_completion(MPID_Win * win_ptr, MPIDI_RMA_Tar
MPIDI_RMA_Op_t * rma_op, int *op_completed)
{
int i, mpi_errno = MPI_SUCCESS;
+ int incomplete_req_cnt = 0;
MPID_Request **req = NULL;
MPIDI_STATE_DECL(MPID_STATE_CHECK_AND_SET_REQ_COMPLETION);
@@ -667,12 +668,12 @@ static inline int check_and_set_req_completion(MPID_Win * win_ptr, MPIDI_RMA_Tar
else {
(*req)->request_completed_cb = MPIDI_CH3_Req_handler_rma_op_complete;
(*req)->dev.source_win_handle = win_ptr->handle;
- (*req)->dev.rma_op_ptr = rma_op;
+ (*req)->dev.rma_target_ptr = target;
- rma_op->ref_cnt++;
+ incomplete_req_cnt++;
if (rma_op->ureq != NULL) {
- MPID_cc_set(&(rma_op->ureq->cc), rma_op->ref_cnt);
+ MPID_cc_set(&(rma_op->ureq->cc), incomplete_req_cnt);
(*req)->dev.request_handle = rma_op->ureq->handle;
}
@@ -680,31 +681,22 @@ static inline int check_and_set_req_completion(MPID_Win * win_ptr, MPIDI_RMA_Tar
}
}
- if (rma_op->ref_cnt == 0) {
+ if (incomplete_req_cnt == 0) {
if (rma_op->ureq != NULL) {
mpi_errno = MPID_Request_complete(rma_op->ureq);
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_POP(mpi_errno);
}
}
- MPIDI_CH3I_RMA_Ops_free_elem(win_ptr, &(target->pending_net_ops_list_head), rma_op);
-
(*op_completed) = TRUE;
}
else {
- MPIDI_RMA_Op_t **list_ptr = NULL;
-
- MPIDI_CH3I_RMA_Get_issued_list_ptr(target, rma_op, list_ptr, mpi_errno);
- if (mpi_errno != MPI_SUCCESS) {
- MPIU_ERR_POP(mpi_errno);
- }
-
- MPL_DL_DELETE(target->pending_net_ops_list_head, rma_op);
- MPL_DL_APPEND((*list_ptr), rma_op);
-
- win_ptr->active_req_cnt += rma_op->ref_cnt;
+ win_ptr->active_req_cnt += incomplete_req_cnt;
+ target->num_pkts_wait_for_local_completion += incomplete_req_cnt;
}
+ MPIDI_CH3I_RMA_Ops_free_elem(win_ptr, &(target->pending_net_ops_list_head), rma_op);
+
if (target->pending_net_ops_list_head == NULL) {
win_ptr->num_targets_with_pending_net_ops--;
MPIU_Assert(win_ptr->num_targets_with_pending_net_ops >= 0);
diff --git a/src/mpid/ch3/src/ch3u_handle_op_req.c b/src/mpid/ch3/src/ch3u_handle_op_req.c
index 3288c57..269089f 100644
--- a/src/mpid/ch3/src/ch3u_handle_op_req.c
+++ b/src/mpid/ch3/src/ch3u_handle_op_req.c
@@ -14,14 +14,17 @@
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPIDI_CH3_Req_handler_rma_op_complete(MPID_Request * sreq)
{
- int i, mpi_errno = MPI_SUCCESS;
+ int mpi_errno = MPI_SUCCESS;
MPID_Request *ureq = NULL;
- MPIDI_RMA_Op_t *op = NULL;
MPID_Win *win_ptr = NULL;
MPIDI_STATE_DECL(MPID_STATE_MPIDI_CH3_REQ_HANDLER_RMA_OP_COMPLETE);
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_CH3_REQ_HANDLER_RMA_OP_COMPLETE);
+ if (sreq->dev.rma_target_ptr != NULL) {
+ (sreq->dev.rma_target_ptr)->num_pkts_wait_for_local_completion--;
+ }
+
/* get window, decrement active request cnt on window */
MPID_Win_get_ptr(sreq->dev.source_win_handle, win_ptr);
MPIU_Assert(win_ptr != NULL);
@@ -36,50 +39,6 @@ int MPIDI_CH3_Req_handler_rma_op_complete(MPID_Request * sreq)
}
}
- op = sreq->dev.rma_op_ptr;
- /* Note: if rma_op_ptr is NULL, it means the operation
- * is freed before the completion. */
- if (op != NULL) {
- /* Mark this request as NULL in the operation struct,
- * so that when operation is freed before completion,
- * the operation do not need to try to notify this
- * request which is already completed. */
- if (op->reqs_size == 1) {
- MPIU_Assert(op->single_req->handle == sreq->handle);
- op->single_req = NULL;
- }
- else {
- for (i = 0; i < op->reqs_size; i++) {
- if (op->multi_reqs[i] == NULL)
- continue;
- else if (op->multi_reqs[i]->handle == sreq->handle) {
- op->multi_reqs[i] = NULL;
- break;
- }
- }
- }
-
- op->ref_cnt--;
- MPIU_Assert(op->ref_cnt >= 0);
- if (op->ref_cnt == 0) {
- MPIDI_RMA_Target_t *target = NULL;
- MPIDI_RMA_Op_t **list_ptr = NULL;
-
- mpi_errno = MPIDI_CH3I_Win_find_target(win_ptr, op->target_rank, &target);
- if (mpi_errno != MPI_SUCCESS) {
- MPIU_ERR_POP(mpi_errno);
- }
- MPIU_Assert(target != NULL);
-
- MPIDI_CH3I_RMA_Get_issued_list_ptr(target, op, list_ptr, mpi_errno);
- if (mpi_errno != MPI_SUCCESS) {
- MPIU_ERR_POP(mpi_errno);
- }
-
- MPIDI_CH3I_RMA_Ops_free_elem(win_ptr, list_ptr, op);
- }
- }
-
fn_exit:
MPIDI_FUNC_EXIT(MPID_STATE_MPIDI_CH3_REQ_HANDLER_RMA_OP_COMPLETE);
return mpi_errno;
diff --git a/src/mpid/ch3/src/ch3u_request.c b/src/mpid/ch3/src/ch3u_request.c
index 94dbb91..fe7bfd3 100644
--- a/src/mpid/ch3/src/ch3u_request.c
+++ b/src/mpid/ch3/src/ch3u_request.c
@@ -100,7 +100,7 @@ MPID_Request * MPID_Request_create(void)
req->dev.tmpbuf = NULL;
req->dev.ext_hdr_ptr = NULL;
req->dev.ext_hdr_sz = 0;
- req->dev.rma_op_ptr = NULL;
+ req->dev.rma_target_ptr = NULL;
req->dev.request_handle = MPI_REQUEST_NULL;
#ifdef MPIDI_CH3_REQUEST_INIT
MPIDI_CH3_REQUEST_INIT(req);
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index e344c3d..26d8cf4 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -447,105 +447,6 @@ static inline int issue_ops_win(MPID_Win * win_ptr, int *made_progress)
#undef FUNCNAME
-#define FUNCNAME MPIDI_CH3I_RMA_Free_ops_before_completion
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIDI_CH3I_RMA_Free_ops_before_completion(MPID_Win * win_ptr)
-{
- MPIDI_RMA_Op_t *curr_op = NULL;
- MPIDI_RMA_Target_t *curr_target = NULL;
- MPIDI_RMA_Op_t **op_list_head = NULL;
- int read_flag = 0;
- int i, made_progress = 0;
- int mpi_errno = MPI_SUCCESS;
-
- /* make nonblocking progress once */
- mpi_errno = MPIDI_CH3I_RMA_Make_progress_win(win_ptr, &made_progress);
- if (mpi_errno != MPI_SUCCESS)
- MPIU_ERR_POP(mpi_errno);
-
- if (win_ptr->states.access_state == MPIDI_RMA_FENCE_ISSUED ||
- win_ptr->states.access_state == MPIDI_RMA_PSCW_ISSUED ||
- win_ptr->states.access_state == MPIDI_RMA_LOCK_ALL_ISSUED)
- goto fn_exit;
-
- /* find targets that have operations */
- for (i = 0; i < win_ptr->num_slots; i++) {
- if (win_ptr->slots[i].target_list_head != NULL) {
- curr_target = win_ptr->slots[i].target_list_head;
- while (curr_target != NULL) {
- if (curr_target->issued_read_op_list_head != NULL ||
- curr_target->issued_write_op_list_head != NULL) {
- if (win_ptr->states.access_state == MPIDI_RMA_PER_TARGET ||
- win_ptr->states.access_state == MPIDI_RMA_LOCK_ALL_CALLED) {
- if (curr_target->access_state == MPIDI_RMA_LOCK_GRANTED)
- break;
- }
- else {
- break;
- }
- }
- curr_target = curr_target->next;
- }
- if (curr_target != NULL)
- break;
- }
- }
-
- if (curr_target == NULL)
- goto fn_exit;
-
- /* After we do this, all following Win_flush_local
- * must do a Win_flush instead. */
- curr_target->sync.upgrade_flush_local = 1;
-
- op_list_head = &curr_target->issued_read_op_list_head;
- read_flag = 1;
-
- curr_op = *op_list_head;
-
- /* free all ops in the list since we do not need to maintain them anymore */
- while (1) {
- if (curr_op != NULL) {
- /* Here we mark the operation pointer in the request
- * as NULL, so that when request is completed, it will
- * not try to free this operation. */
- if (curr_op->reqs_size == 1) {
- MPIU_Assert(curr_op->single_req != NULL);
- curr_op->single_req->dev.rma_op_ptr = NULL;
- }
- else {
- MPIU_Assert(curr_op->reqs_size > 1);
- MPIU_Assert(curr_op->multi_reqs != NULL);
- for (i = 0; i < curr_op->reqs_size; i++) {
- if (curr_op->multi_reqs[i] != NULL) {
- curr_op->multi_reqs[i]->dev.rma_op_ptr = NULL;
- }
- }
- }
- MPIDI_CH3I_RMA_Ops_free_elem(win_ptr, op_list_head, curr_op);
- }
- else {
- if (read_flag == 1) {
- op_list_head = &curr_target->issued_write_op_list_head;
- read_flag = 0;
- }
- else {
- /* we reach the tail of write_op_list, break out. */
- break;
- }
- }
- curr_op = *op_list_head;
- }
-
- fn_exit:
- return mpi_errno;
- fn_fail:
- goto fn_exit;
-}
-
-
-#undef FUNCNAME
#define FUNCNAME MPIDI_CH3I_RMA_Cleanup_ops_aggressive
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
diff --git a/src/mpid/ch3/src/ch3u_rma_sync.c b/src/mpid/ch3/src/ch3u_rma_sync.c
index 92fbccd..19dca35 100644
--- a/src/mpid/ch3/src/ch3u_rma_sync.c
+++ b/src/mpid/ch3/src/ch3u_rma_sync.c
@@ -343,15 +343,8 @@ static inline int flush_local_all(MPID_Win * win_ptr)
for (i = 0; i < win_ptr->num_slots; i++) {
curr_target = win_ptr->slots[i].target_list_head;
while (curr_target != NULL) {
- if (curr_target->sync.upgrade_flush_local) {
- if (curr_target->sync.sync_flag < MPIDI_RMA_SYNC_FLUSH) {
- curr_target->sync.sync_flag = MPIDI_RMA_SYNC_FLUSH;
- }
- }
- else {
- if (curr_target->sync.sync_flag < MPIDI_RMA_SYNC_FLUSH_LOCAL) {
- curr_target->sync.sync_flag = MPIDI_RMA_SYNC_FLUSH_LOCAL;
- }
+ if (curr_target->sync.sync_flag < MPIDI_RMA_SYNC_FLUSH_LOCAL) {
+ curr_target->sync.sync_flag = MPIDI_RMA_SYNC_FLUSH_LOCAL;
}
curr_target = curr_target->next;
@@ -1418,11 +1411,6 @@ int MPID_Win_flush(int dest, MPID_Win * win_ptr)
MPIU_ERR_POP(mpi_errno);
}
- if (target != NULL && target->sync.upgrade_flush_local) {
- /* reset upgrade_flush_local flag in target to 0 */
- target->sync.upgrade_flush_local = 0;
- }
-
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_WIN_FLUSH);
return mpi_errno;
@@ -1460,35 +1448,28 @@ int MPID_Win_flush_local(int dest, MPID_Win * win_ptr)
}
if (dest == MPI_PROC_NULL)
- goto finish_flush_local;
+ goto fn_exit;
mpi_errno = MPIDI_CH3I_Win_find_target(win_ptr, dest, &target);
if (mpi_errno != MPI_SUCCESS)
MPIU_ERR_POP(mpi_errno);
if (target == NULL)
- goto finish_flush_local;
+ goto fn_exit;
if (rank == dest)
- goto finish_flush_local;
+ goto fn_exit;
if (win_ptr->shm_allocated) {
MPIDI_VC_t *orig_vc = NULL, *target_vc = NULL;
MPIDI_Comm_get_vc(win_ptr->comm_ptr, dest, &target_vc);
MPIDI_Comm_get_vc(win_ptr->comm_ptr, rank, &orig_vc);
if (orig_vc->node_id == target_vc->node_id)
- goto finish_flush_local;
+ goto fn_exit;
}
/* Set sync_flag in sync struct. */
- if (target->sync.upgrade_flush_local) {
- if (target->sync.sync_flag < MPIDI_RMA_SYNC_FLUSH) {
- target->sync.sync_flag = MPIDI_RMA_SYNC_FLUSH;
- }
- }
- else {
- if (target->sync.sync_flag < MPIDI_RMA_SYNC_FLUSH_LOCAL)
- target->sync.sync_flag = MPIDI_RMA_SYNC_FLUSH_LOCAL;
- }
+ if (target->sync.sync_flag < MPIDI_RMA_SYNC_FLUSH_LOCAL)
+ target->sync.sync_flag = MPIDI_RMA_SYNC_FLUSH_LOCAL;
/* Issue out all operations. */
mpi_errno = MPIDI_CH3I_RMA_Make_progress_target(win_ptr, dest, &made_progress);
@@ -1506,12 +1487,6 @@ int MPID_Win_flush_local(int dest, MPID_Win * win_ptr)
}
} while (!local_completed);
- finish_flush_local:
- if (target != NULL) {
- /* reset upgrade_flush_local flag in target to 0 */
- target->sync.upgrade_flush_local = 0;
- }
-
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_WIN_FLUSH_LOCAL);
return mpi_errno;
@@ -1743,8 +1718,6 @@ int MPID_Win_unlock_all(MPID_Win * win_ptr)
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_Win_flush_all(MPID_Win * win_ptr)
{
- int i;
- MPIDI_RMA_Target_t *curr_target = NULL;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPIDI_STATE_MPID_WIN_FLUSH_ALL);
@@ -1767,15 +1740,6 @@ int MPID_Win_flush_all(MPID_Win * win_ptr)
MPIU_Assert(win_ptr->active_req_cnt == 0);
- /* reset upgrade_flush_local flag in target to 0 */
- for (i = 0; i < win_ptr->num_slots; i++) {
- curr_target = win_ptr->slots[i].target_list_head;
- while (curr_target != NULL) {
- curr_target->sync.upgrade_flush_local = 0;
- curr_target = curr_target->next;
- }
- }
-
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPIDI_STATE_MPID_WIN_FLUSH_ALL);
return mpi_errno;
@@ -1792,8 +1756,6 @@ int MPID_Win_flush_all(MPID_Win * win_ptr)
#define FCNAME MPIU_QUOTE(FUNCNAME)
int MPID_Win_flush_local_all(MPID_Win * win_ptr)
{
- int i;
- MPIDI_RMA_Target_t *curr_target = NULL;
int mpi_errno = MPI_SUCCESS;
MPIDI_STATE_DECL(MPID_STATE_MPID_WIN_FLUSH_LOCAL_ALL);
@@ -1816,15 +1778,6 @@ int MPID_Win_flush_local_all(MPID_Win * win_ptr)
MPIU_Assert(win_ptr->active_req_cnt == 0);
- /* reset upgrade_flush_local flag in target to 0 */
- for (i = 0; i < win_ptr->num_slots; i++) {
- curr_target = win_ptr->slots[i].target_list_head;
- while (curr_target != NULL) {
- curr_target->sync.upgrade_flush_local = 0;
- curr_target = curr_target->next;
- }
- }
-
fn_exit:
MPIDI_RMA_FUNC_EXIT(MPID_STATE_MPID_WIN_FLUSH_LOCAL_ALL);
return mpi_errno;
http://git.mpich.org/mpich.git/commitdiff/68b26e3c7d3ba336554f3bd8bf6cf1383…
commit 68b26e3c7d3ba336554f3bd8bf6cf138313180cb
Author: Xin Zhao <xinzhao3(a)illinois.edu>
Date: Fri Aug 7 12:53:55 2015 -0500
Simplify macros for RMA op.
Signed-off-by: Pavan Balaji <balaji(a)anl.gov>
diff --git a/src/mpid/ch3/include/mpidpkt.h b/src/mpid/ch3/include/mpidpkt.h
index 05780e4..5dc1001 100644
--- a/src/mpid/ch3/include/mpidpkt.h
+++ b/src/mpid/ch3/include/mpidpkt.h
@@ -613,36 +613,21 @@ MPIDI_CH3_PKT_DEFS
/* This macro judges if the RMA operation is a read operation,
* which means, it will triffer the issuing of response data from
* the target to the origin */
-#define MPIDI_CH3I_RMA_PKT_IS_READ_OP(pkt_, is_read_op_) \
- do { \
- if ((pkt_).type == MPIDI_CH3_PKT_GET_ACCUM_IMMED || \
- (pkt_).type == MPIDI_CH3_PKT_GET_ACCUM || \
- (pkt_).type == MPIDI_CH3_PKT_FOP_IMMED || \
- (pkt_).type == MPIDI_CH3_PKT_FOP || \
- (pkt_).type == MPIDI_CH3_PKT_CAS_IMMED || \
- (pkt_).type == MPIDI_CH3_PKT_GET) { \
- is_read_op_ = TRUE; \
- } \
- else { \
- is_read_op_ = FALSE; \
- } \
- } while (0)
-
+#define MPIDI_CH3I_RMA_PKT_IS_READ_OP(pkt_) \
+ ((pkt_).type == MPIDI_CH3_PKT_GET_ACCUM_IMMED || \
+ (pkt_).type == MPIDI_CH3_PKT_GET_ACCUM || \
+ (pkt_).type == MPIDI_CH3_PKT_FOP_IMMED || \
+ (pkt_).type == MPIDI_CH3_PKT_FOP || \
+ (pkt_).type == MPIDI_CH3_PKT_CAS_IMMED || \
+ (pkt_).type == MPIDI_CH3_PKT_GET)
/* This macro judges if the RMA operation is a immed operation */
-#define MPIDI_CH3I_RMA_PKT_IS_IMMED_OP(pkt_, is_immed_op_) \
- do { \
- if ((pkt_).type == MPIDI_CH3_PKT_GET_ACCUM_IMMED || \
- (pkt_).type == MPIDI_CH3_PKT_FOP_IMMED || \
- (pkt_).type == MPIDI_CH3_PKT_CAS_IMMED || \
- (pkt_).type == MPIDI_CH3_PKT_PUT_IMMED || \
- (pkt_).type == MPIDI_CH3_PKT_ACCUMULATE_IMMED) { \
- is_immed_op_ = TRUE; \
- } \
- else { \
- is_immed_op_ = FALSE; \
- } \
- } while (0)
+#define MPIDI_CH3I_RMA_PKT_IS_IMMED_OP(pkt_) \
+ ((pkt_).type == MPIDI_CH3_PKT_GET_ACCUM_IMMED || \
+ (pkt_).type == MPIDI_CH3_PKT_FOP_IMMED || \
+ (pkt_).type == MPIDI_CH3_PKT_CAS_IMMED || \
+ (pkt_).type == MPIDI_CH3_PKT_PUT_IMMED || \
+ (pkt_).type == MPIDI_CH3_PKT_ACCUMULATE_IMMED)
typedef struct MPIDI_CH3_Pkt_put {
MPIDI_CH3_Pkt_type_t type;
diff --git a/src/mpid/ch3/include/mpidrma.h b/src/mpid/ch3/include/mpidrma.h
index 05d563a..4f5ea28 100644
--- a/src/mpid/ch3/include/mpidrma.h
+++ b/src/mpid/ch3/include/mpidrma.h
@@ -326,7 +326,6 @@ static inline int enqueue_lock_origin(MPID_Win * win_ptr, MPIDI_VC_t * vc,
MPIDI_CH3_Pkt_flags_t flag;
MPI_Win source_win_handle;
MPI_Request request_handle;
- int is_immed_op = FALSE;
int lock_discarded = 0, data_discarded = 0;
int mpi_errno = MPI_SUCCESS;
@@ -343,8 +342,8 @@ static inline int enqueue_lock_origin(MPID_Win * win_ptr, MPIDI_VC_t * vc,
lock_discarded = 1;
}
- MPIDI_CH3I_RMA_PKT_IS_IMMED_OP((*pkt), is_immed_op);
- if (is_immed_op || pkt->type == MPIDI_CH3_PKT_LOCK || pkt->type == MPIDI_CH3_PKT_GET) {
+ if (MPIDI_CH3I_RMA_PKT_IS_IMMED_OP(*pkt) || pkt->type == MPIDI_CH3_PKT_LOCK ||
+ pkt->type == MPIDI_CH3_PKT_GET) {
/* return bytes of data processed in this pkt handler */
(*buflen) = sizeof(MPIDI_CH3_Pkt_t);
@@ -425,12 +424,10 @@ static inline int enqueue_lock_origin(MPID_Win * win_ptr, MPIDI_VC_t * vc,
MPIDI_CH3_Pkt_t new_pkt;
MPIDI_CH3_Pkt_lock_t *lock_pkt = &new_pkt.lock;
MPI_Win target_win_handle;
- int is_read_op = FALSE;
- MPIDI_CH3I_RMA_PKT_IS_READ_OP((*pkt), is_read_op);
MPIDI_CH3_PKT_RMA_GET_TARGET_WIN_HANDLE((*pkt), target_win_handle, mpi_errno);
- if (!is_read_op) {
+ if (!MPIDI_CH3I_RMA_PKT_IS_READ_OP(*pkt)) {
MPIDI_CH3_PKT_RMA_GET_SOURCE_WIN_HANDLE((*pkt), source_win_handle, mpi_errno);
request_handle = MPI_REQUEST_NULL;
}
@@ -525,8 +522,6 @@ static inline int enqueue_lock_origin(MPID_Win * win_ptr, MPIDI_VC_t * vc,
MPIU_ERR_POP(mpi_errno);
}
else {
- int is_read_op = FALSE;
-
if (lock_discarded)
flag = MPIDI_CH3_PKT_FLAG_RMA_LOCK_DISCARDED;
else if (data_discarded)
@@ -534,8 +529,7 @@ static inline int enqueue_lock_origin(MPID_Win * win_ptr, MPIDI_VC_t * vc,
else
flag = MPIDI_CH3_PKT_FLAG_RMA_LOCK_QUEUED_DATA_QUEUED;
- MPIDI_CH3I_RMA_PKT_IS_READ_OP((*pkt), is_read_op);
- if (!is_read_op) {
+ if (!MPIDI_CH3I_RMA_PKT_IS_READ_OP(*pkt)) {
MPIDI_CH3_PKT_RMA_GET_SOURCE_WIN_HANDLE((*pkt), source_win_handle, mpi_errno);
request_handle = MPI_REQUEST_NULL;
}
diff --git a/src/mpid/ch3/src/ch3u_rma_progress.c b/src/mpid/ch3/src/ch3u_rma_progress.c
index dc4324d..e344c3d 100644
--- a/src/mpid/ch3/src/ch3u_rma_progress.c
+++ b/src/mpid/ch3/src/ch3u_rma_progress.c
@@ -288,7 +288,6 @@ static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * targ
curr_op = target->next_op_to_issue;
while (curr_op != NULL) {
int op_completed = FALSE;
- int is_read_op = FALSE;
if (target->access_state == MPIDI_RMA_LOCK_ISSUED) {
/* It is possible that the previous OP+LOCK changes
@@ -345,8 +344,7 @@ static inline int issue_ops_target(MPID_Win * win_ptr, MPIDI_RMA_Target_t * targ
(*made_progress) = 1;
- MPIDI_CH3I_RMA_PKT_IS_READ_OP(curr_op->pkt, is_read_op);
- if (!is_read_op) {
+ if (!MPIDI_CH3I_RMA_PKT_IS_READ_OP(curr_op->pkt)) {
target->put_acc_issued = 1; /* set PUT_ACC_FLAG when sending
* PUT/ACC operation. */
}
-----------------------------------------------------------------------
Summary of changes:
src/mpid/ch3/include/mpid_rma_oplist.h | 72 ++---------------
src/mpid/ch3/include/mpid_rma_types.h | 14 ++--
src/mpid/ch3/include/mpidpkt.h | 41 +++-------
src/mpid/ch3/include/mpidpre.h | 2 +-
src/mpid/ch3/include/mpidrma.h | 47 ++++-------
src/mpid/ch3/src/ch3u_handle_op_req.c | 51 +-----------
src/mpid/ch3/src/ch3u_request.c | 2 +-
src/mpid/ch3/src/ch3u_rma_progress.c | 140 +++++--------------------------
src/mpid/ch3/src/ch3u_rma_sync.c | 63 ++-------------
9 files changed, 82 insertions(+), 350 deletions(-)
hooks/post-receive
--
MPICH primary repository
1
0
[mpich] MPICH primary repository branch, master, updated. v3.2b4-87-g18ddb4c
by noreply@mpich.org 07 Aug '15
by noreply@mpich.org 07 Aug '15
07 Aug '15
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 18ddb4c38036d92a2f7181eccc6e403299f81efd (commit)
via 288ab3820c94663571df02099764bcdcb3cdb4eb (commit)
via 141f5de2d13a5b013353822266382b814c260031 (commit)
via ba43e9490fd384a5689ffb55365f02ccfd6c04be (commit)
via f9439c801ed29b7614f0d05bb4e5f10ace94d1c9 (commit)
from 0d6f27fb0333f17358552d1ea1c8acd803d678de (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/18ddb4c38036d92a2f7181eccc6e40329…
commit 18ddb4c38036d92a2f7181eccc6e403299f81efd
Author: Pavan Balaji <balaji(a)anl.gov>
Date: Thu Aug 6 23:41:02 2015 -0500
Convert camelcase variables to underscore format.
No reviewer.
diff --git a/src/mpi/comm/contextid.c b/src/mpi/comm/contextid.c
index ae2978f..3de7511 100644
--- a/src/mpi/comm/contextid.c
+++ b/src/mpi/comm/contextid.c
@@ -280,16 +280,16 @@ static volatile int eager_in_use = 0;
* single-threaded case, it is always 0. */
static volatile int mask_in_use = 0;
-/* In multi-threaded case, lowestContextId is used to prioritize access when
- * multiple threads are contending for the mask, lowestTag is used to break
+/* In multi-threaded case, lowest_context_id is used to prioritize access when
+ * multiple threads are contending for the mask, lowest_tag is used to break
* ties when MPI_Comm_create_group is invoked my multiple threads on the same
- * parent communicator. In single-threaded case, lowestContextId is always
- * set to parent context id in sched_cb_gcn_copy_mask and lowestTag is not
+ * parent communicator. In single-threaded case, lowest_context_id is always
+ * set to parent context id in sched_cb_gcn_copy_mask and lowest_tag is not
* used.
*/
#define MPIR_MAXID (1 << 30)
-static volatile int lowestContextId = MPIR_MAXID;
-static volatile int lowestTag = -1;
+static volatile int lowest_context_id = MPIR_MAXID;
+static volatile int lowest_tag = -1;
#undef FUNCNAME
#define FUNCNAME MPIR_Get_contextid_sparse
@@ -343,8 +343,8 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr
MPIU_DBG_MSG_FMT(COMM, VERBOSE, (MPIU_DBG_FDEST,
"Entering; shared state is %d:%d:%d, my ctx id is %d, tag=%d",
- mask_in_use, lowestContextId, lowestTag, comm_ptr->context_id,
- tag));
+ mask_in_use, lowest_context_id, lowest_tag,
+ comm_ptr->context_id, tag));
while (*context_id == 0) {
/* We lock only around access to the mask (except in the global locking
@@ -368,7 +368,7 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr
* context ID space doesn't matter. Set the mask to "all available". */
memset(local_mask, 0xff, MPIR_MAX_CONTEXT_MASK * sizeof(int));
own_mask = 0;
- /* don't need to touch mask_in_use/lowestContextId b/c our thread
+ /* don't need to touch mask_in_use/lowest_context_id b/c our thread
* doesn't ever need to "win" the mask */
}
@@ -395,20 +395,20 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr
}
else {
- /* lowestTag breaks ties when contextIds are the same (happens only
+ /* lowest_tag breaks ties when context IDs are the same (happens only
* in calls to MPI_Comm_create_group. */
- if (comm_ptr->context_id < lowestContextId ||
- (comm_ptr->context_id == lowestContextId && tag < lowestTag)) {
- lowestContextId = comm_ptr->context_id;
- lowestTag = tag;
+ if (comm_ptr->context_id < lowest_context_id ||
+ (comm_ptr->context_id == lowest_context_id && tag < lowest_tag)) {
+ lowest_context_id = comm_ptr->context_id;
+ lowest_tag = tag;
}
- if (mask_in_use || !(comm_ptr->context_id == lowestContextId && tag == lowestTag) ||
+ if (mask_in_use || !(comm_ptr->context_id == lowest_context_id && tag == lowest_tag) ||
(comm_ptr->idup_count && seqnum != comm_ptr->idup_next_seqnum)) {
memset(local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
own_mask = 0;
- MPIU_DBG_MSG_D(COMM, VERBOSE, "In in-use, set lowestContextId to %d",
- lowestContextId);
+ MPIU_DBG_MSG_D(COMM, VERBOSE, "In in-use, set lowest_context_id to %d",
+ lowest_context_id);
}
else {
int i;
@@ -492,9 +492,9 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr
if (*context_id > 0) {
/* If we were the lowest context id, reset the value to
* allow the other threads to compete for the mask */
- if (lowestContextId == comm_ptr->context_id && lowestTag == tag) {
- lowestContextId = MPIR_MAXID;
- lowestTag = -1;
+ if (lowest_context_id == comm_ptr->context_id && lowest_tag == tag) {
+ lowest_context_id = MPIR_MAXID;
+ lowest_tag = -1;
/* Else leave it alone; there is another thread waiting */
}
comm_ptr->idup_curr_seqnum++;
@@ -527,9 +527,9 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr
if (own_mask) {
MPIU_THREAD_CS_ENTER(CONTEXTID,);
mask_in_use = 0;
- if (lowestContextId == comm_ptr->context_id && lowestTag == tag) {
- lowestContextId = MPIR_MAXID;
- lowestTag = -1;
+ if (lowest_context_id == comm_ptr->context_id && lowest_tag == tag) {
+ lowest_context_id = MPIR_MAXID;
+ lowest_tag = -1;
}
MPIU_THREAD_CS_EXIT(CONTEXTID,);
}
@@ -711,8 +711,8 @@ static int sched_cb_gcn_allocate_cid(MPID_Comm * comm, int tag, void *state)
mask_in_use = 0;
if (newctxid > 0) {
- if (lowestContextId == st->comm_ptr->context_id)
- lowestContextId = MPIR_MAXID;
+ if (lowest_context_id == st->comm_ptr->context_id)
+ lowest_context_id = MPIR_MAXID;
}
}
@@ -767,18 +767,18 @@ static int sched_cb_gcn_copy_mask(MPID_Comm * comm, int tag, void *state)
}
else {
- if (st->comm_ptr->context_id < lowestContextId) {
- lowestContextId = st->comm_ptr->context_id;
+ if (st->comm_ptr->context_id < lowest_context_id) {
+ lowest_context_id = st->comm_ptr->context_id;
}
/* If one of the following conditions happens, set local_mask to zero
* so sched_cb_gcn_allocate_cid can not find a valid id and will retry:
* 1. mask is used by other threads;
- * 2. the current MPI_COMM_IDUP operation does not has the lowestContextId;
+ * 2. the current MPI_COMM_IDUP operation does not has the lowest_context_id;
* 3. for the case that multiple communicators duplicating from the
* same communicator at the same time, the sequence number of the
* current MPI_COMM_IDUP operation is not the smallest. */
- if (mask_in_use || (st->comm_ptr->context_id != lowestContextId)
+ if (mask_in_use || (st->comm_ptr->context_id != lowest_context_id)
|| (st->comm_ptr->idup_count > 1 && st->seqnum != st->comm_ptr->idup_next_seqnum)) {
memset(st->local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
st->own_mask = 0;
http://git.mpich.org/mpich.git/commitdiff/288ab3820c94663571df02099764bcdcb…
commit 288ab3820c94663571df02099764bcdcb3cdb4eb
Author: Pavan Balaji <balaji(a)anl.gov>
Date: Thu Aug 6 23:19:21 2015 -0500
Get rid of the old MPIR_Get_contextid function.
MPIR_Get_contextid simply calls MPIR_Get_contextid_sparse. Get rid of
the pointless wrapper function.
No reviewer.
diff --git a/src/include/mpiimpl.h b/src/include/mpiimpl.h
index d314fbc..cdf3866 100644
--- a/src/include/mpiimpl.h
+++ b/src/include/mpiimpl.h
@@ -1427,7 +1427,6 @@ extern MPID_Comm MPID_Comm_direct[];
with the other comm routines (src/mpi/comm, in mpicomm.h). However,
to create a new communicator after a spawn or connect-accept operation,
the device may need to create a new contextid */
-int MPIR_Get_contextid( MPID_Comm *, MPIR_Context_id_t *context_id );
int MPIR_Get_contextid_sparse(MPID_Comm *comm_ptr, MPIR_Context_id_t *context_id, int ignore_id);
int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr, int tag, MPIR_Context_id_t *context_id, int ignore_id);
void MPIR_Free_contextid( MPIR_Context_id_t );
diff --git a/src/mpi/comm/comm_create.c b/src/mpi/comm/comm_create.c
index 23c109d..c1c2400 100644
--- a/src/mpi/comm/comm_create.c
+++ b/src/mpi/comm/comm_create.c
@@ -208,7 +208,7 @@ int MPIR_Comm_create_intra(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
/* Creating the context id is collective over the *input* communicator,
so it must be created before we decide if this process is a
member of the group */
- /* In the multi-threaded case, MPIR_Get_contextid assumes that the
+ /* In the multi-threaded case, MPIR_Get_contextid_sparse assumes that the
calling routine already holds the single criticial section */
mpi_errno = MPIR_Get_contextid_sparse( comm_ptr, &new_context_id,
group_ptr->rank == MPI_UNDEFINED );
@@ -308,12 +308,12 @@ PMPI_LOCAL int MPIR_Comm_create_inter(MPID_Comm *comm_ptr, MPID_Group *group_ptr
Creating the context id is collective over the *input* communicator,
so it must be created before we decide if this process is a
member of the group */
- /* In the multi-threaded case, MPIR_Get_contextid assumes that the
+ /* In the multi-threaded case, MPIR_Get_contextid_sparse assumes that the
calling routine already holds the single criticial section */
if (!comm_ptr->local_comm) {
MPIR_Setup_intercomm_localcomm( comm_ptr );
}
- mpi_errno = MPIR_Get_contextid( comm_ptr->local_comm, &new_context_id );
+ mpi_errno = MPIR_Get_contextid_sparse( comm_ptr->local_comm, &new_context_id, FALSE );
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_Assert(new_context_id != 0);
MPIU_Assert(new_context_id != comm_ptr->recvcontext_id);
diff --git a/src/mpi/comm/comm_split.c b/src/mpi/comm/comm_split.c
index bdbaa01..ac5ec6f 100644
--- a/src/mpi/comm/comm_split.c
+++ b/src/mpi/comm/comm_split.c
@@ -246,7 +246,7 @@ int MPIR_Comm_split_impl(MPID_Comm *comm_ptr, int color, int key, MPID_Comm **ne
be used by each (disjoint) collections of processes. The
processes whose color is MPI_UNDEFINED will not influence the
resulting context id (by passing ignore_id==TRUE). */
- /* In the multi-threaded case, MPIR_Get_contextid assumes that the
+ /* In the multi-threaded case, MPIR_Get_contextid_sparse assumes that the
calling routine already holds the single criticial section */
mpi_errno = MPIR_Get_contextid_sparse(local_comm_ptr, &new_context_id, !in_newcomm);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
diff --git a/src/mpi/comm/commutil.c b/src/mpi/comm/commutil.c
index b48acd6..22e929c 100644
--- a/src/mpi/comm/commutil.c
+++ b/src/mpi/comm/commutil.c
@@ -740,7 +740,7 @@ int MPIR_Comm_copy(MPID_Comm * comm_ptr, int size, MPID_Comm ** outcomm_ptr)
MPIU_ERR_POP(mpi_errno);
}
else {
- mpi_errno = MPIR_Get_contextid(comm_ptr, &new_context_id);
+ mpi_errno = MPIR_Get_contextid_sparse(comm_ptr, &new_context_id, FALSE);
new_recvcontext_id = new_context_id;
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
diff --git a/src/mpi/comm/contextid.c b/src/mpi/comm/contextid.c
index 6937b57..ae2978f 100644
--- a/src/mpi/comm/contextid.c
+++ b/src/mpi/comm/contextid.c
@@ -266,35 +266,6 @@ static int find_and_allocate_context_id(uint32_t local_mask[])
return context_id;
}
-/* Older, simpler interface. Allocates a context ID collectively over the given
- * communicator. */
-#undef FUNCNAME
-#define FUNCNAME MPIR_Get_contextid
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id)
-{
- int mpi_errno = MPI_SUCCESS;
- mpi_errno = MPIR_Get_contextid_sparse(comm_ptr, context_id, FALSE);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPIU_Assert(*context_id != MPIR_INVALID_CONTEXT_ID);
-
- /* --BEGIN ERROR HANDLING-- */
- if (*context_id == 0) {
- int nfree = -1;
- int ntotal = -1;
- context_mask_stats(&nfree, &ntotal);
- MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
- "**toomanycomm", "**toomanycomm %d %d %d",
- nfree, ntotal, /*ignore_id= */ 0);
- }
- /* --END ERROR HANDLING-- */
- fn_fail:
- return mpi_errno;
-}
-
-
/* EAGER CONTEXT ID ALLOCATION: Attempt to allocate the context ID during the
* initial synchronization step. If eager protocol fails, threads fall back to
* the base algorithm.
@@ -1080,7 +1051,7 @@ int MPIR_Get_intercomm_contextid(MPID_Comm * comm_ptr, MPIR_Context_id_t * conte
MPIU_ERR_POP(mpi_errno);
}
- mpi_errno = MPIR_Get_contextid(comm_ptr->local_comm, &mycontext_id);
+ mpi_errno = MPIR_Get_contextid_sparse(comm_ptr->local_comm, &mycontext_id, FALSE);
if (mpi_errno)
MPIU_ERR_POP(mpi_errno);
MPIU_Assert(mycontext_id != 0);
diff --git a/src/mpi/comm/intercomm_create.c b/src/mpi/comm/intercomm_create.c
index 01770f0..73b0ed8 100644
--- a/src/mpi/comm/intercomm_create.c
+++ b/src/mpi/comm/intercomm_create.c
@@ -231,10 +231,10 @@ int MPIR_Intercomm_create_impl(MPID_Comm *local_comm_ptr, int local_leader,
*/
MPIU_DBG_MSG_FMT(COMM,VERBOSE, (MPIU_DBG_FDEST,"About to get contextid (local_size=%d) on rank %d",
local_comm_ptr->local_size, local_comm_ptr->rank ));
- /* In the multi-threaded case, MPIR_Get_contextid assumes that the
+ /* In the multi-threaded case, MPIR_Get_contextid_sparse assumes that the
calling routine already holds the single criticial section */
/* TODO: Make sure this is tag-safe */
- mpi_errno = MPIR_Get_contextid( local_comm_ptr, &recvcontext_id );
+ mpi_errno = MPIR_Get_contextid_sparse( local_comm_ptr, &recvcontext_id, FALSE );
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_Assert(recvcontext_id != 0);
MPIU_DBG_MSG_FMT(COMM,VERBOSE, (MPIU_DBG_FDEST,"Got contextid=%d", recvcontext_id));
diff --git a/src/mpi/comm/intercomm_merge.c b/src/mpi/comm/intercomm_merge.c
index 0a16b06..48d7064 100644
--- a/src/mpi/comm/intercomm_merge.c
+++ b/src/mpi/comm/intercomm_merge.c
@@ -169,10 +169,10 @@ int MPIR_Intercomm_merge_impl(MPID_Comm *comm_ptr, int high, MPID_Comm **new_int
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* printf( "About to get context id \n" ); fflush( stdout ); */
- /* In the multi-threaded case, MPIR_Get_contextid assumes that the
+ /* In the multi-threaded case, MPIR_Get_contextid_sparse assumes that the
calling routine already holds the single criticial section */
new_context_id = 0;
- mpi_errno = MPIR_Get_contextid( (*new_intracomm_ptr), &new_context_id );
+ mpi_errno = MPIR_Get_contextid_sparse( (*new_intracomm_ptr), &new_context_id, FALSE );
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
MPIU_Assert(new_context_id != 0);
diff --git a/src/mpi/comm/mpicomm.h b/src/mpi/comm/mpicomm.h
index 1be457d..17b2437 100644
--- a/src/mpi/comm/mpicomm.h
+++ b/src/mpi/comm/mpicomm.h
@@ -5,9 +5,4 @@
*/
/* Function prototypes for communicator helper functions */
-/* The MPIR_Get_contextid and void MPIR_Free_contextid routines are in
- mpiimpl.h so that the device may use them */
-/* int MPIR_Get_contextid( MPID_Comm *, MPIR_Context_id_t * ); */
int MPIR_Get_intercomm_contextid( MPID_Comm *, MPIR_Context_id_t *, MPIR_Context_id_t * );
-/* void MPIR_Free_contextid( MPIR_Context_id_t ); */
-
diff --git a/src/mpid/ch3/src/ch3u_port.c b/src/mpid/ch3/src/ch3u_port.c
index 9a4aa93..29a1f6c 100644
--- a/src/mpid/ch3/src/ch3u_port.c
+++ b/src/mpid/ch3/src/ch3u_port.c
@@ -351,7 +351,7 @@ int MPIDI_Comm_connect(const char *port_name, MPID_Info *info, int root,
MPIDI_FUNC_ENTER(MPID_STATE_MPIDI_COMM_CONNECT);
/* Get the context ID here because we need to send it to the remote side */
- mpi_errno = MPIR_Get_contextid( comm_ptr, &recvcontext_id );
+ mpi_errno = MPIR_Get_contextid_sparse( comm_ptr, &recvcontext_id, FALSE );
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
rank = comm_ptr->rank;
@@ -951,7 +951,7 @@ int MPIDI_Comm_accept(const char *port_name, MPID_Info *info, int root,
if (mpi_errno != MPI_SUCCESS) {
MPIU_ERR_POP(mpi_errno);
}
- mpi_errno = MPIR_Get_contextid( comm_ptr, &(*newcomm)->recvcontext_id );
+ mpi_errno = MPIR_Get_contextid_sparse( comm_ptr, &(*newcomm)->recvcontext_id, FALSE );
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
/* FIXME why is this commented out? */
/* (*newcomm)->context_id = (*newcomm)->recvcontext_id; */
http://git.mpich.org/mpich.git/commitdiff/141f5de2d13a5b013353822266382b814…
commit 141f5de2d13a5b013353822266382b814c260031
Author: Pavan Balaji <balaji(a)anl.gov>
Date: Thu Aug 6 22:57:38 2015 -0500
Remove function namespacing for static functions.
No reviewer.
diff --git a/src/mpi/comm/commutil.c b/src/mpi/comm/commutil.c
index 7ed49e9..b48acd6 100644
--- a/src/mpi/comm/commutil.c
+++ b/src/mpi/comm/commutil.c
@@ -1113,10 +1113,10 @@ int MPIR_Comm_apply_hints(MPID_Comm * comm_ptr, MPID_Info * info_ptr)
}
#undef FUNCNAME
-#define FUNCNAME MPIR_Comm_free_hint_handles
+#define FUNCNAME free_hint_handles
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int MPIR_Comm_free_hint_handles(void *ignore)
+static int free_hint_handles(void *ignore)
{
int mpi_errno = MPI_SUCCESS;
struct MPIR_Comm_hint_fn_elt *curr_hint = NULL, *tmp = NULL;
@@ -1153,7 +1153,7 @@ int MPIR_Comm_register_hint(const char *hint_key, MPIR_Comm_hint_fn_t fn, void *
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_COMM_REGISTER_HINT);
if (MPID_hint_fns == NULL) {
- MPIR_Add_finalize(MPIR_Comm_free_hint_handles, NULL, MPIR_FINALIZE_CALLBACK_PRIO - 1);
+ MPIR_Add_finalize(free_hint_handles, NULL, MPIR_FINALIZE_CALLBACK_PRIO - 1);
}
hint_elt = MPIU_Malloc(sizeof(struct MPIR_Comm_hint_fn_elt));
diff --git a/src/mpi/comm/contextid.c b/src/mpi/comm/contextid.c
index ea0fed7..6937b57 100644
--- a/src/mpi/comm/contextid.c
+++ b/src/mpi/comm/contextid.c
@@ -45,7 +45,7 @@ static int initialize_context_mask = 1;
/* utility function to pretty print a context ID for debugging purposes, see
* mpiimpl.h for more info on the various fields */
#ifdef USE_DBG_LOGGING
-static void MPIR_Comm_dump_context_id(MPIR_Context_id_t context_id, char *out_str, int len)
+static void dump_context_id(MPIR_Context_id_t context_id, char *out_str, int len)
{
int subcomm_type = MPID_CONTEXT_READ_FIELD(SUBCOMM, context_id);
const char *subcomm_type_name = NULL;
@@ -90,8 +90,7 @@ static void MPIR_Comm_dump_context_id(MPIR_Context_id_t context_id, char *out_st
(possibly "extern") copy of the prototype in their own code in order to call
this routine.
*/
-char *MPIR_ContextMaskToStr(void);
-char *MPIR_ContextMaskToStr(void)
+static char *context_mask_to_str(void)
{
static char bufstr[MPIR_MAX_CONTEXT_MASK * 8 + 1];
int i;
@@ -121,8 +120,7 @@ char *MPIR_ContextMaskToStr(void)
*
* The routine is non-static in order to permit "in the field debugging". We
* provide a prototype here to keep the compiler happy. */
-void MPIR_ContextMaskStats(int *free_ids, int *total_ids);
-void MPIR_ContextMaskStats(int *free_ids, int *total_ids)
+static void context_mask_stats(int *free_ids, int *total_ids)
{
if (free_ids) {
int i, j;
@@ -144,7 +142,7 @@ void MPIR_ContextMaskStats(int *free_ids, int *total_ids)
}
#ifdef MPICH_DEBUG_HANDLEALLOC
-static int MPIU_CheckContextIDsOnFinalize(void *context_mask_ptr)
+static int check_context_ids_on_finalize(void *context_mask_ptr)
{
int i;
uint32_t *mask = context_mask_ptr;
@@ -160,7 +158,7 @@ static int MPIU_CheckContextIDsOnFinalize(void *context_mask_ptr)
}
#endif
-static void MPIR_Init_contextid(void)
+static void context_id_init(void)
{
int i;
@@ -180,14 +178,13 @@ static void MPIR_Init_contextid(void)
#ifdef MPICH_DEBUG_HANDLEALLOC
/* check for context ID leaks in MPI_Finalize. Use (_PRIO-1) to make sure
* that we run after MPID_Finalize. */
- MPIR_Add_finalize(MPIU_CheckContextIDsOnFinalize, context_mask,
- MPIR_FINALIZE_CALLBACK_PRIO - 1);
+ MPIR_Add_finalize(check_context_ids_on_finalize, context_mask, MPIR_FINALIZE_CALLBACK_PRIO - 1);
#endif
}
/* Return the context id corresponding to the first set bit in the mask.
Return 0 if no bit found. This function does _not_ alter local_mask. */
-static int MPIR_Locate_context_bit(uint32_t local_mask[])
+static int locate_context_bit(uint32_t local_mask[])
{
int i, j, context_id = 0;
for (i = 0; i < MPIR_MAX_CONTEXT_MASK; i++) {
@@ -235,7 +232,7 @@ static int MPIR_Locate_context_bit(uint32_t local_mask[])
/* Allocates a context ID from the given mask by clearing the bit
* corresponding to the the given id. Returns 0 on failure, id on
* success. */
-static int MPIR_Allocate_context_bit(uint32_t mask[], MPIR_Context_id_t id)
+static int allocate_context_bit(uint32_t mask[], MPIR_Context_id_t id)
{
int raw_prefix, idx, bitpos;
raw_prefix = MPID_CONTEXT_READ_FIELD(PREFIX, id);
@@ -259,12 +256,12 @@ static int MPIR_Allocate_context_bit(uint32_t mask[], MPIR_Context_id_t id)
* context_mask if allocation was successful.
*
* Returns 0 on failure. Returns the allocated context ID on success. */
-static int MPIR_Find_and_allocate_context_id(uint32_t local_mask[])
+static int find_and_allocate_context_id(uint32_t local_mask[])
{
MPIR_Context_id_t context_id;
- context_id = MPIR_Locate_context_bit(local_mask);
+ context_id = locate_context_bit(local_mask);
if (context_id != 0) {
- context_id = MPIR_Allocate_context_bit(context_mask, context_id);
+ context_id = allocate_context_bit(context_mask, context_id);
}
return context_id;
}
@@ -287,7 +284,7 @@ int MPIR_Get_contextid(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id)
if (*context_id == 0) {
int nfree = -1;
int ntotal = -1;
- MPIR_ContextMaskStats(&nfree, &ntotal);
+ context_mask_stats(&nfree, &ntotal);
MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
"**toomanycomm", "**toomanycomm %d %d %d",
nfree, ntotal, /*ignore_id= */ 0);
@@ -384,7 +381,7 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr
MPIU_THREAD_CS_ENTER(CONTEXTID,);
if (initialize_context_mask) {
- MPIR_Init_contextid();
+ context_id_init();
}
if (eager_nelem < 0) {
@@ -493,13 +490,13 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr
if (ignore_id) {
/* we don't care what the value was, but make sure that everyone
* who did care agreed on a value */
- *context_id = MPIR_Locate_context_bit(local_mask);
+ *context_id = locate_context_bit(local_mask);
/* used later in out-of-context ids check and outer while loop condition */
}
else if (own_eager_mask) {
/* There is a chance that we've found a context id */
/* Find_and_allocate_context_id updates the context_mask if it finds a match */
- *context_id = MPIR_Find_and_allocate_context_id(local_mask);
+ *context_id = find_and_allocate_context_id(local_mask);
MPIU_DBG_MSG_D(COMM, VERBOSE, "Context id is now %hd", *context_id);
own_eager_mask = 0;
@@ -516,7 +513,7 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr
else if (own_mask) {
/* There is a chance that we've found a context id */
/* Find_and_allocate_context_id updates the context_mask if it finds a match */
- *context_id = MPIR_Find_and_allocate_context_id(local_mask);
+ *context_id = find_and_allocate_context_id(local_mask);
MPIU_DBG_MSG_D(COMM, VERBOSE, "Context id is now %hd", *context_id);
mask_in_use = 0;
@@ -566,7 +563,7 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr
MPIU_THREAD_CS_EXIT(CONTEXTID,);
}
- MPIR_ContextMaskStats(&nfree, &ntotal);
+ context_mask_stats(&nfree, &ntotal);
if (ignore_id)
minfree = INT_MAX;
else
@@ -604,7 +601,7 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr
fn_exit:
if (ignore_id)
*context_id = MPIR_INVALID_CONTEXT_ID;
- MPIU_DBG_MSG_S(COMM, VERBOSE, "Context mask = %s", MPIR_ContextMaskToStr());
+ MPIU_DBG_MSG_S(COMM, VERBOSE, "Context mask = %s", context_mask_to_str());
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_CONTEXTID);
return mpi_errno;
@@ -722,7 +719,7 @@ static int sched_cb_gcn_allocate_cid(MPID_Comm * comm, int tag, void *state)
MPIR_Context_id_t newctxid;
if (st->own_eager_mask) {
- newctxid = MPIR_Find_and_allocate_context_id(st->local_mask);
+ newctxid = find_and_allocate_context_id(st->local_mask);
if (st->ctx0)
*st->ctx0 = newctxid;
if (st->ctx1)
@@ -732,7 +729,7 @@ static int sched_cb_gcn_allocate_cid(MPID_Comm * comm, int tag, void *state)
eager_in_use = 0;
}
else if (st->own_mask) {
- newctxid = MPIR_Find_and_allocate_context_id(st->local_mask);
+ newctxid = find_and_allocate_context_id(st->local_mask);
if (st->ctx0)
*st->ctx0 = newctxid;
@@ -896,7 +893,7 @@ static int sched_get_cid_nonblock(MPID_Comm * comm_ptr, MPID_Comm * newcomm,
MPIU_CHKPMEM_DECL(1);
if (initialize_context_mask) {
- MPIR_Init_contextid();
+ context_id_init();
}
MPIU_CHKPMEM_MALLOC(st, struct gcn_state *, sizeof(struct gcn_state), mpi_errno, "gcn_state");
@@ -1154,7 +1151,7 @@ void MPIR_Free_contextid(MPIR_Context_id_t context_id)
if (MPID_CONTEXT_READ_FIELD(IS_LOCALCOMM, context_id)) {
#ifdef USE_DBG_LOGGING
char dump_str[1024];
- MPIR_Comm_dump_context_id(context_id, dump_str, sizeof(dump_str));
+ dump_context_id(context_id, dump_str, sizeof(dump_str));
MPIU_DBG_MSG_S(COMM, VERBOSE, "skipping localcomm id: %s", dump_str);
#endif
goto fn_exit;
@@ -1171,9 +1168,9 @@ void MPIR_Free_contextid(MPIR_Context_id_t context_id)
if ((context_mask[idx] & (0x1 << bitpos)) != 0) {
#ifdef USE_DBG_LOGGING
char dump_str[1024];
- MPIR_Comm_dump_context_id(context_id, dump_str, sizeof(dump_str));
+ dump_context_id(context_id, dump_str, sizeof(dump_str));
MPIU_DBG_MSG_S(COMM, VERBOSE, "context dump: %s", dump_str);
- MPIU_DBG_MSG_S(COMM, VERBOSE, "context mask = %s", MPIR_ContextMaskToStr());
+ MPIU_DBG_MSG_S(COMM, VERBOSE, "context mask = %s", context_mask_to_str());
#endif
MPID_Abort(0, MPI_ERR_INTERN, 1, "In MPIR_Free_contextid, the context id is not in use");
}
http://git.mpich.org/mpich.git/commitdiff/ba43e9490fd384a5689ffb55365f02ccf…
commit ba43e9490fd384a5689ffb55365f02ccfd6c04be
Author: Pavan Balaji <balaji(a)anl.gov>
Date: Thu Aug 6 22:52:30 2015 -0500
Separate out context ID allocation into a different file.
No reviewer.
diff --git a/src/mpi/comm/Makefile.mk b/src/mpi/comm/Makefile.mk
index cb32747..9fad20f 100644
--- a/src/mpi/comm/Makefile.mk
+++ b/src/mpi/comm/Makefile.mk
@@ -34,6 +34,7 @@ mpi_sources += \
src/mpi/comm/comm_agree.c
mpi_core_sources += \
- src/mpi/comm/commutil.c
+ src/mpi/comm/commutil.c \
+ src/mpi/comm/contextid.c
noinst_HEADERS += src/mpi/comm/mpicomm.h
diff --git a/src/mpi/comm/commutil.c b/src/mpi/comm/commutil.c
index 23af734..7ed49e9 100644
--- a/src/mpi/comm/commutil.c
+++ b/src/mpi/comm/commutil.c
@@ -17,27 +17,6 @@
#define MPID_COMM_PREALLOC 8
#endif
-/*
-=== BEGIN_MPI_T_CVAR_INFO_BLOCK ===
-
-cvars:
- - name : MPIR_CVAR_CTXID_EAGER_SIZE
- category : THREADS
- type : int
- default : 2
- class : device
- verbosity : MPI_T_VERBOSITY_USER_BASIC
- scope : MPI_T_SCOPE_ALL_EQ
- description : >-
- The MPIR_CVAR_CTXID_EAGER_SIZE environment variable allows you to
- specify how many words in the context ID mask will be set aside
- for the eager allocation protocol. If the application is running
- out of context IDs, reducing this value may help.
-
-=== END_MPI_T_CVAR_INFO_BLOCK ===
-*/
-
-
/* Preallocated comm objects */
/* initialized in initthread.c */
MPID_Comm MPID_Comm_builtin[MPID_COMM_N_BUILTIN] = { {0} };
@@ -64,40 +43,6 @@ struct MPIR_Comm_hint_fn_elt {
};
static struct MPIR_Comm_hint_fn_elt *MPID_hint_fns = NULL;
-/* utility function to pretty print a context ID for debugging purposes, see
- * mpiimpl.h for more info on the various fields */
-#ifdef USE_DBG_LOGGING
-static void MPIR_Comm_dump_context_id(MPIR_Context_id_t context_id, char *out_str, int len)
-{
- int subcomm_type = MPID_CONTEXT_READ_FIELD(SUBCOMM, context_id);
- const char *subcomm_type_name = NULL;
-
- switch (subcomm_type) {
- case 0:
- subcomm_type_name = "parent";
- break;
- case 1:
- subcomm_type_name = "intranode";
- break;
- case 2:
- subcomm_type_name = "internode";
- break;
- default:
- MPIU_Assert(FALSE);
- break;
- }
- MPIU_Snprintf(out_str, len,
- "context_id=%d (%#x): DYNAMIC_PROC=%d PREFIX=%#x IS_LOCALCOMM=%d SUBCOMM=%s SUFFIX=%s",
- context_id,
- context_id,
- MPID_CONTEXT_READ_FIELD(DYNAMIC_PROC, context_id),
- MPID_CONTEXT_READ_FIELD(PREFIX, context_id),
- MPID_CONTEXT_READ_FIELD(IS_LOCALCOMM, context_id),
- subcomm_type_name,
- (MPID_CONTEXT_READ_FIELD(SUFFIX, context_id) ? "coll" : "pt2pt"));
-}
-#endif
-
/* FIXME :
Reusing context ids can lead to a race condition if (as is desirable)
MPI_Comm_free does not include a barrier. Consider the following:
@@ -759,1124 +704,6 @@ int MPIR_Comm_is_node_consecutive(MPID_Comm * comm)
}
/*
- * Here are the routines to find a new context id. The algorithm is discussed
- * in detail in the mpich coding document. There are versions for
- * single threaded and multithreaded MPI.
- *
- * Both the threaded and non-threaded routines use the same mask of
- * available context id values.
- */
-static uint32_t context_mask[MPIR_MAX_CONTEXT_MASK];
-static int initialize_context_mask = 1;
-
-/* Create a string that contains the context mask. This is
- used only with the logging interface, and must be used by one thread at
- a time (should this be enforced by the logging interface?).
- Converts the mask to hex and returns a pointer to that string.
-
- Callers should own the context ID critical section, or should be prepared to
- suffer data races in any fine-grained locking configuration.
-
- This routine is no longer static in order to allow advanced users and
- developers to debug context ID problems "in the field". We provide a
- prototype here to keep the compiler happy, but users will need to put a
- (possibly "extern") copy of the prototype in their own code in order to call
- this routine.
- */
-char *MPIR_ContextMaskToStr(void);
-char *MPIR_ContextMaskToStr(void)
-{
- static char bufstr[MPIR_MAX_CONTEXT_MASK * 8 + 1];
- int i;
- int maxset = 0;
-
- for (maxset = MPIR_MAX_CONTEXT_MASK - 1; maxset >= 0; maxset--) {
- if (context_mask[maxset] != 0)
- break;
- }
-
- for (i = 0; i < maxset; i++) {
- MPIU_Snprintf(&bufstr[i * 8], 9, "%.8x", context_mask[i]);
- }
- return bufstr;
-}
-
-/* Returns useful debugging information about the context ID mask bit-vector.
- * This includes the total number of possibly valid IDs (the size of the ID
- * space) and the number of free IDs remaining in the mask. NULL arguments are
- * fine, they will be ignored.
- *
- * This routine is for debugging in very particular situations and does not
- * attempt to control concurrent access to the mask vector.
- *
- * Callers should own the context ID critical section, or should be prepared to
- * suffer data races in any fine-grained locking configuration.
- *
- * The routine is non-static in order to permit "in the field debugging". We
- * provide a prototype here to keep the compiler happy. */
-void MPIR_ContextMaskStats(int *free_ids, int *total_ids);
-void MPIR_ContextMaskStats(int *free_ids, int *total_ids)
-{
- if (free_ids) {
- int i, j;
- *free_ids = 0;
-
- /* if this ever needs to be fast, use a lookup table to do a per-nibble
- * or per-byte lookup of the popcount instead of checking each bit at a
- * time (or just track the count when manipulating the mask and keep
- * that count stored in a variable) */
- for (i = 0; i < MPIR_MAX_CONTEXT_MASK; ++i) {
- for (j = 0; j < sizeof(context_mask[0]) * 8; ++j) {
- *free_ids += (context_mask[i] & (0x1 << j)) >> j;
- }
- }
- }
- if (total_ids) {
- *total_ids = MPIR_MAX_CONTEXT_MASK * sizeof(context_mask[0]) * 8;
- }
-}
-
-#ifdef MPICH_DEBUG_HANDLEALLOC
-static int MPIU_CheckContextIDsOnFinalize(void *context_mask_ptr)
-{
- int i;
- uint32_t *mask = context_mask_ptr;
- /* the predefined communicators should be freed by this point, so we don't
- * need to special case bits 0,1, and 2 */
- for (i = 0; i < MPIR_MAX_CONTEXT_MASK; ++i) {
- if (~mask[i]) {
- /* some bits were still cleared */
- printf("leaked context IDs detected: mask=%p mask[%d]=%#x\n", mask, i, (int) mask[i]);
- }
- }
- return MPI_SUCCESS;
-}
-#endif
-
-static void MPIR_Init_contextid(void)
-{
- int i;
-
- for (i = 1; i < MPIR_MAX_CONTEXT_MASK; i++) {
- context_mask[i] = 0xFFFFFFFF;
- }
- /* The first two values are already used (comm_world, comm_self).
- * The third value is also used for the internal-only copy of
- * comm_world, if needed by mpid. */
-#ifdef MPID_NEEDS_ICOMM_WORLD
- context_mask[0] = 0xFFFFFFF8;
-#else
- context_mask[0] = 0xFFFFFFFC;
-#endif
- initialize_context_mask = 0;
-
-#ifdef MPICH_DEBUG_HANDLEALLOC
- /* check for context ID leaks in MPI_Finalize. Use (_PRIO-1) to make sure
- * that we run after MPID_Finalize. */
- MPIR_Add_finalize(MPIU_CheckContextIDsOnFinalize, context_mask,
- MPIR_FINALIZE_CALLBACK_PRIO - 1);
-#endif
-}
-
-/* Return the context id corresponding to the first set bit in the mask.
- Return 0 if no bit found. This function does _not_ alter local_mask. */
-static int MPIR_Locate_context_bit(uint32_t local_mask[])
-{
- int i, j, context_id = 0;
- for (i = 0; i < MPIR_MAX_CONTEXT_MASK; i++) {
- if (local_mask[i]) {
- /* There is a bit set in this word. */
- register uint32_t val, nval;
- /* The following code finds the highest set bit by recursively
- * checking the top half of a subword for a bit, and incrementing
- * the bit location by the number of bit of the lower sub word if
- * the high subword contains a set bit. The assumption is that
- * full-word bitwise operations and compares against zero are
- * fast */
- val = local_mask[i];
- j = 0;
- nval = val & 0xFFFF0000;
- if (nval) {
- j += 16;
- val = nval;
- }
- nval = val & 0xFF00FF00;
- if (nval) {
- j += 8;
- val = nval;
- }
- nval = val & 0xF0F0F0F0;
- if (nval) {
- j += 4;
- val = nval;
- }
- nval = val & 0xCCCCCCCC;
- if (nval) {
- j += 2;
- val = nval;
- }
- if (val & 0xAAAAAAAA) {
- j += 1;
- }
- context_id = (MPIR_CONTEXT_INT_BITS * i + j) << MPID_CONTEXT_PREFIX_SHIFT;
- return context_id;
- }
- }
- return 0;
-}
-
-/* Allocates a context ID from the given mask by clearing the bit
- * corresponding to the the given id. Returns 0 on failure, id on
- * success. */
-static int MPIR_Allocate_context_bit(uint32_t mask[], MPIR_Context_id_t id)
-{
- int raw_prefix, idx, bitpos;
- raw_prefix = MPID_CONTEXT_READ_FIELD(PREFIX, id);
- idx = raw_prefix / MPIR_CONTEXT_INT_BITS;
- bitpos = raw_prefix % MPIR_CONTEXT_INT_BITS;
-
- /* the bit should not already be cleared (allocated) */
- MPIU_Assert(mask[idx] & (1 << bitpos));
-
- /* clear the bit */
- mask[idx] &= ~(1 << bitpos);
-
- MPIU_DBG_MSG_FMT(COMM, VERBOSE, (MPIU_DBG_FDEST,
- "allocating contextid = %d, (mask=%p, mask[%d], bit %d)",
- id, mask, idx, bitpos));
- return id;
-}
-
-/* Allocates the first available context ID from context_mask based on the available
- * bits given in local_mask. This function will clear the corresponding bit in
- * context_mask if allocation was successful.
- *
- * Returns 0 on failure. Returns the allocated context ID on success. */
-static int MPIR_Find_and_allocate_context_id(uint32_t local_mask[])
-{
- MPIR_Context_id_t context_id;
- context_id = MPIR_Locate_context_bit(local_mask);
- if (context_id != 0) {
- context_id = MPIR_Allocate_context_bit(context_mask, context_id);
- }
- return context_id;
-}
-
-/* Older, simpler interface. Allocates a context ID collectively over the given
- * communicator. */
-#undef FUNCNAME
-#define FUNCNAME MPIR_Get_contextid
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id)
-{
- int mpi_errno = MPI_SUCCESS;
- mpi_errno = MPIR_Get_contextid_sparse(comm_ptr, context_id, FALSE);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPIU_Assert(*context_id != MPIR_INVALID_CONTEXT_ID);
- fn_fail:
- return mpi_errno;
-}
-
-
-/* EAGER CONTEXT ID ALLOCATION: Attempt to allocate the context ID during the
- * initial synchronization step. If eager protocol fails, threads fall back to
- * the base algorithm.
- *
- * They are used to avoid deadlock in multi-threaded case. In single-threaded
- * case, they are not used.
- */
-static volatile int eager_nelem = -1;
-static volatile int eager_in_use = 0;
-
-/* In multi-threaded case, mask_in_use is used to maintain thread safety. In
- * single-threaded case, it is always 0. */
-static volatile int mask_in_use = 0;
-
-/* In multi-threaded case, lowestContextId is used to prioritize access when
- * multiple threads are contending for the mask, lowestTag is used to break
- * ties when MPI_Comm_create_group is invoked my multiple threads on the same
- * parent communicator. In single-threaded case, lowestContextId is always
- * set to parent context id in sched_cb_gcn_copy_mask and lowestTag is not
- * used.
- */
-#define MPIR_MAXID (1 << 30)
-static volatile int lowestContextId = MPIR_MAXID;
-static volatile int lowestTag = -1;
-
-#undef FUNCNAME
-#define FUNCNAME MPIR_Get_contextid_sparse
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid_sparse(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id, int ignore_id)
-{
- return MPIR_Get_contextid_sparse_group(comm_ptr, NULL /*group_ptr */ ,
- MPIR_Process.attrs.tag_ub /*tag */ ,
- context_id, ignore_id);
-}
-
-/* Allocates a new context ID collectively over the given communicator. This
- * routine is "sparse" in the sense that while it is collective, some processes
- * may not care about the value selected context ID.
- *
- * One example of this case is processes who pass MPI_UNDEFINED as the color
- * value to MPI_Comm_split. Such processes should pass ignore_id==TRUE to
- * obtain the best performance and utilization of the context ID space.
- *
- * Processes that pass ignore_id==TRUE will receive
- * (*context_id==MPIR_INVALID_CONTEXT_ID) and should not attempt to use it.
- *
- * If a group pointer is given, the call is _not_ sparse, and only processes
- * in the group should call this routine. That is, it is collective only over
- * the given group.
- */
-#undef FUNCNAME
-#define FUNCNAME MPIR_Get_contextid_sparse_group
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr, int tag,
- MPIR_Context_id_t * context_id, int ignore_id)
-{
- int mpi_errno = MPI_SUCCESS;
- const int ALL_OWN_MASK_FLAG = MPIR_MAX_CONTEXT_MASK;
- uint32_t local_mask[MPIR_MAX_CONTEXT_MASK + 1];
- int own_mask = 0;
- int own_eager_mask = 0;
- mpir_errflag_t errflag = MPIR_ERR_NONE;
- int first_iter = 1;
- int seqnum = 0;
- MPID_MPI_STATE_DECL(MPID_STATE_MPIR_GET_CONTEXTID);
-
- MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_GET_CONTEXTID);
-
- /* Group-collective and ignore_id should never be combined */
- MPIU_Assert(!(group_ptr != NULL && ignore_id));
-
- *context_id = 0;
-
- MPIU_DBG_MSG_FMT(COMM, VERBOSE, (MPIU_DBG_FDEST,
- "Entering; shared state is %d:%d:%d, my ctx id is %d, tag=%d",
- mask_in_use, lowestContextId, lowestTag, comm_ptr->context_id,
- tag));
-
- while (*context_id == 0) {
- /* We lock only around access to the mask (except in the global locking
- * case). If another thread is using the mask, we take a mask of zero. */
- MPIU_THREAD_CS_ENTER(CONTEXTID,);
-
- if (initialize_context_mask) {
- MPIR_Init_contextid();
- }
-
- if (eager_nelem < 0) {
- /* Ensure that at least one word of deadlock-free context IDs is
- * always set aside for the base protocol */
- MPIU_Assert(MPIR_CVAR_CTXID_EAGER_SIZE >= 0 &&
- MPIR_CVAR_CTXID_EAGER_SIZE < MPIR_MAX_CONTEXT_MASK - 1);
- eager_nelem = MPIR_CVAR_CTXID_EAGER_SIZE;
- }
-
- if (ignore_id) {
- /* We are not participating in the resulting communicator, so our
- * context ID space doesn't matter. Set the mask to "all available". */
- memset(local_mask, 0xff, MPIR_MAX_CONTEXT_MASK * sizeof(int));
- own_mask = 0;
- /* don't need to touch mask_in_use/lowestContextId b/c our thread
- * doesn't ever need to "win" the mask */
- }
-
- /* Deadlock avoidance: Only participate in context id loop when all
- * processes have called this routine. On the first iteration, use the
- * "eager" allocation protocol.
- */
- else if (first_iter) {
- memset(local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
- own_eager_mask = 0;
- if (comm_ptr->idup_count)
- seqnum = comm_ptr->idup_curr_seqnum++;
-
-
- /* Attempt to reserve the eager mask segment */
- if (!eager_in_use && eager_nelem > 0) {
- int i;
- for (i = 0; i < eager_nelem; i++)
- local_mask[i] = context_mask[i];
-
- eager_in_use = 1;
- own_eager_mask = 1;
- }
- }
-
- else {
- /* lowestTag breaks ties when contextIds are the same (happens only
- * in calls to MPI_Comm_create_group. */
- if (comm_ptr->context_id < lowestContextId ||
- (comm_ptr->context_id == lowestContextId && tag < lowestTag)) {
- lowestContextId = comm_ptr->context_id;
- lowestTag = tag;
- }
-
- if (mask_in_use || !(comm_ptr->context_id == lowestContextId && tag == lowestTag) ||
- (comm_ptr->idup_count && seqnum != comm_ptr->idup_next_seqnum)) {
- memset(local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
- own_mask = 0;
- MPIU_DBG_MSG_D(COMM, VERBOSE, "In in-use, set lowestContextId to %d",
- lowestContextId);
- }
- else {
- int i;
-
- /* Copy safe mask segment to local_mask */
- for (i = 0; i < eager_nelem; i++)
- local_mask[i] = 0;
- for (i = eager_nelem; i < MPIR_MAX_CONTEXT_MASK; i++)
- local_mask[i] = context_mask[i];
-
- mask_in_use = 1;
- own_mask = 1;
- MPIU_DBG_MSG(COMM, VERBOSE, "Copied local_mask");
- }
- }
- MPIU_THREAD_CS_EXIT(CONTEXTID,);
-
- /* Note: MPIR_MAX_CONTEXT_MASK elements of local_mask are used by the
- * context ID allocation algorithm. The additional element is ignored
- * by the context ID mask access routines and is used as a flag for
- * detecting context ID exhaustion (explained below). */
- if (own_mask || ignore_id)
- local_mask[ALL_OWN_MASK_FLAG] = 1;
- else
- local_mask[ALL_OWN_MASK_FLAG] = 0;
-
- /* Now, try to get a context id */
- MPIU_Assert(comm_ptr->comm_kind == MPID_INTRACOMM);
- /* In the global and brief-global cases, note that this routine will
- * release that global lock when it needs to wait. That will allow
- * other processes to enter the global or brief global critical section.
- */
- if (group_ptr != NULL) {
- int coll_tag = tag | MPIR_Process.tagged_coll_mask; /* Shift tag into the tagged coll space */
- mpi_errno = MPIR_Allreduce_group(MPI_IN_PLACE, local_mask, MPIR_MAX_CONTEXT_MASK + 1,
- MPI_INT, MPI_BAND, comm_ptr, group_ptr, coll_tag,
- &errflag);
- }
- else {
- mpi_errno = MPIR_Allreduce_impl(MPI_IN_PLACE, local_mask, MPIR_MAX_CONTEXT_MASK + 1,
- MPI_INT, MPI_BAND, comm_ptr, &errflag);
- }
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
-
- /* MT FIXME 2/3 cases don't seem to need the CONTEXTID CS, check and
- * narrow this region */
- MPIU_THREAD_CS_ENTER(CONTEXTID,);
- if (ignore_id) {
- /* we don't care what the value was, but make sure that everyone
- * who did care agreed on a value */
- *context_id = MPIR_Locate_context_bit(local_mask);
- /* used later in out-of-context ids check and outer while loop condition */
- }
- else if (own_eager_mask) {
- /* There is a chance that we've found a context id */
- /* Find_and_allocate_context_id updates the context_mask if it finds a match */
- *context_id = MPIR_Find_and_allocate_context_id(local_mask);
- MPIU_DBG_MSG_D(COMM, VERBOSE, "Context id is now %hd", *context_id);
-
- own_eager_mask = 0;
- eager_in_use = 0;
-
- if (*context_id <= 0) {
- /* else we did not find a context id. Give up the mask in case
- * there is another thread (with a lower input context id)
- * waiting for it. We need to ensure that any other threads
- * have the opportunity to run, hence yielding */
- MPIU_THREAD_CS_YIELD(CONTEXTID,);
- }
- }
- else if (own_mask) {
- /* There is a chance that we've found a context id */
- /* Find_and_allocate_context_id updates the context_mask if it finds a match */
- *context_id = MPIR_Find_and_allocate_context_id(local_mask);
- MPIU_DBG_MSG_D(COMM, VERBOSE, "Context id is now %hd", *context_id);
-
- mask_in_use = 0;
-
- if (*context_id > 0) {
- /* If we were the lowest context id, reset the value to
- * allow the other threads to compete for the mask */
- if (lowestContextId == comm_ptr->context_id && lowestTag == tag) {
- lowestContextId = MPIR_MAXID;
- lowestTag = -1;
- /* Else leave it alone; there is another thread waiting */
- }
- comm_ptr->idup_curr_seqnum++;
- }
- else {
- /* else we did not find a context id. Give up the mask in case
- * there is another thread (with a lower input context id)
- * waiting for it. We need to ensure that any other threads
- * have the opportunity to run, hence yielding */
- MPIU_THREAD_CS_YIELD(CONTEXTID,);
- }
- }
- else {
- /* As above, force this thread to yield */
- MPIU_THREAD_CS_YIELD(CONTEXTID,);
- }
- MPIU_THREAD_CS_EXIT(CONTEXTID,);
-
- /* Test for context ID exhaustion: All threads that will participate in
- * the new communicator owned the mask and could not allocate a context
- * ID. This indicates that either some process has no context IDs
- * available, or that some are available, but the allocation cannot
- * succeed because there is no common context ID. */
- if (*context_id == 0 && local_mask[ALL_OWN_MASK_FLAG] == 1) {
- /* --BEGIN ERROR HANDLING-- */
- int nfree = 0;
- int ntotal = 0;
- int minfree;
-
- if (own_mask) {
- MPIU_THREAD_CS_ENTER(CONTEXTID,);
- mask_in_use = 0;
- if (lowestContextId == comm_ptr->context_id && lowestTag == tag) {
- lowestContextId = MPIR_MAXID;
- lowestTag = -1;
- }
- MPIU_THREAD_CS_EXIT(CONTEXTID,);
- }
-
- MPIR_ContextMaskStats(&nfree, &ntotal);
- if (ignore_id)
- minfree = INT_MAX;
- else
- minfree = nfree;
-
- if (group_ptr != NULL) {
- int coll_tag = tag | MPIR_Process.tagged_coll_mask; /* Shift tag into the tagged coll space */
- mpi_errno = MPIR_Allreduce_group(MPI_IN_PLACE, &minfree, 1, MPI_INT, MPI_MIN,
- comm_ptr, group_ptr, coll_tag, &errflag);
- }
- else {
- mpi_errno = MPIR_Allreduce_impl(MPI_IN_PLACE, &minfree, 1, MPI_INT,
- MPI_MIN, comm_ptr, &errflag);
- }
-
- if (minfree > 0) {
- MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
- "**toomanycommfrag", "**toomanycommfrag %d %d %d",
- nfree, ntotal, ignore_id);
- }
- else {
- MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
- "**toomanycomm", "**toomanycomm %d %d %d",
- nfree, ntotal, ignore_id);
- }
- /* --END ERROR HANDLING-- */
- }
-
- first_iter = 0;
- }
- if (seqnum > 0)
- comm_ptr->idup_next_seqnum++;
-
-
- fn_exit:
- if (ignore_id)
- *context_id = MPIR_INVALID_CONTEXT_ID;
- MPIU_DBG_MSG_S(COMM, VERBOSE, "Context mask = %s", MPIR_ContextMaskToStr());
- MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_CONTEXTID);
- return mpi_errno;
-
- /* --BEGIN ERROR HANDLING-- */
- fn_fail:
- /* Release the masks */
- if (own_mask) {
- /* is it safe to access this without holding the CS? */
- mask_in_use = 0;
- }
- goto fn_exit;
- /* --END ERROR HANDLING-- */
-}
-
-struct gcn_state {
- MPIR_Context_id_t *ctx0;
- MPIR_Context_id_t *ctx1;
- int own_mask;
- int own_eager_mask;
- int first_iter;
- int seqnum;
- MPID_Comm *comm_ptr;
- MPID_Comm *comm_ptr_inter;
- MPID_Sched_t s;
- MPID_Comm *new_comm;
- MPID_Comm_kind_t gcn_cid_kind;
- uint32_t local_mask[MPIR_MAX_CONTEXT_MASK];
-};
-
-static int sched_cb_gcn_copy_mask(MPID_Comm * comm, int tag, void *state);
-static int sched_cb_gcn_allocate_cid(MPID_Comm * comm, int tag, void *state);
-static int sched_cb_gcn_bcast(MPID_Comm * comm, int tag, void *state);
-#undef FUNCNAME
-#define FUNCNAME sched_cb_commit_comm
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int sched_cb_commit_comm(MPID_Comm * comm, int tag, void *state)
-{
- int mpi_errno = MPI_SUCCESS;
- struct gcn_state *st = state;
-
- mpi_errno = MPIR_Comm_commit(st->new_comm);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
-
- fn_fail:
- return mpi_errno;
-
-}
-
-#undef FUNCNAME
-#define FUNCNAME sched_cb_gcn_bcast
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int sched_cb_gcn_bcast(MPID_Comm * comm, int tag, void *state)
-{
- int mpi_errno = MPI_SUCCESS;
- struct gcn_state *st = state;
-
- if (st->gcn_cid_kind == MPID_INTERCOMM) {
- if (st->comm_ptr_inter->rank == 0) {
- mpi_errno =
- MPID_Sched_recv(st->ctx1, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, st->comm_ptr_inter,
- st->s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- mpi_errno =
- MPID_Sched_send(st->ctx0, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, st->comm_ptr_inter,
- st->s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPID_SCHED_BARRIER(st->s);
- }
-
- mpi_errno = st->comm_ptr->coll_fns->Ibcast_sched(st->ctx1, 1,
- MPIR_CONTEXT_ID_T_DATATYPE, 0,
- st->comm_ptr, st->s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPID_SCHED_BARRIER(st->s);
- }
-
- mpi_errno = MPID_Sched_cb(&sched_cb_commit_comm, st, st->s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- mpi_errno = MPID_Sched_cb(&MPIR_Sched_cb_free_buf, st, st->s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
-
- fn_fail:
- return mpi_errno;
-}
-
-/* Try to find a valid context id.
- *
- * If the context id is found, then broadcast it; if not, then retry the
- * nonblocking context id allocation algorithm again.
- *
- * Note the subtle difference on thread handling between the nonblocking
- * algorithm (sched_cb_gcn_allocate_cid) and the blocking algorithm
- * (MPIR_Get_contextid_sparse_group). In nonblocking algorithm, there is no
- * need to yield to another thread because this thread will not block the
- * progress. On the contrary, unnecessary yield will allow other threads to
- * execute and insert wrong order of entries to the nonblocking schedule and
- * cause errors.
- */
-#undef FUNCNAME
-#define FUNCNAME sched_cb_gcn_allocate_cid
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int sched_cb_gcn_allocate_cid(MPID_Comm * comm, int tag, void *state)
-{
- int mpi_errno = MPI_SUCCESS;
- struct gcn_state *st = state;
- MPIR_Context_id_t newctxid;
-
- if (st->own_eager_mask) {
- newctxid = MPIR_Find_and_allocate_context_id(st->local_mask);
- if (st->ctx0)
- *st->ctx0 = newctxid;
- if (st->ctx1)
- *st->ctx1 = newctxid;
-
- st->own_eager_mask = 0;
- eager_in_use = 0;
- }
- else if (st->own_mask) {
- newctxid = MPIR_Find_and_allocate_context_id(st->local_mask);
-
- if (st->ctx0)
- *st->ctx0 = newctxid;
- if (st->ctx1)
- *st->ctx1 = newctxid;
-
- /* reset flags for the next try */
- mask_in_use = 0;
-
- if (newctxid > 0) {
- if (lowestContextId == st->comm_ptr->context_id)
- lowestContextId = MPIR_MAXID;
- }
- }
-
- if (*st->ctx0 == 0) {
- /* do not own mask, try again */
- mpi_errno = MPID_Sched_cb(&sched_cb_gcn_copy_mask, st, st->s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPID_SCHED_BARRIER(st->s);
- }
- else {
- /* Successfully allocated a context id */
-
- st->comm_ptr->idup_next_seqnum++;
- st->comm_ptr->idup_count--;
-
- mpi_errno = MPID_Sched_cb(&sched_cb_gcn_bcast, st, st->s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPID_SCHED_BARRIER(st->s);
- }
-
- /* --BEGIN ERROR HANDLING-- */
- /* --END ERROR HANDLING-- */
- fn_fail:
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME sched_cb_gcn_copy_mask
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int sched_cb_gcn_copy_mask(MPID_Comm * comm, int tag, void *state)
-{
- int mpi_errno = MPI_SUCCESS;
- struct gcn_state *st = state;
-
- if (st->first_iter) {
- memset(st->local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
- st->own_eager_mask = 0;
-
- /* Attempt to reserve the eager mask segment */
- if (!eager_in_use && eager_nelem > 0) {
- int i;
- for (i = 0; i < eager_nelem; i++)
- st->local_mask[i] = context_mask[i];
-
- eager_in_use = 1;
- st->own_eager_mask = 1;
- }
- st->first_iter = 0;
-
- }
- else {
- if (st->comm_ptr->context_id < lowestContextId) {
- lowestContextId = st->comm_ptr->context_id;
- }
-
- /* If one of the following conditions happens, set local_mask to zero
- * so sched_cb_gcn_allocate_cid can not find a valid id and will retry:
- * 1. mask is used by other threads;
- * 2. the current MPI_COMM_IDUP operation does not has the lowestContextId;
- * 3. for the case that multiple communicators duplicating from the
- * same communicator at the same time, the sequence number of the
- * current MPI_COMM_IDUP operation is not the smallest. */
- if (mask_in_use || (st->comm_ptr->context_id != lowestContextId)
- || (st->comm_ptr->idup_count > 1 && st->seqnum != st->comm_ptr->idup_next_seqnum)) {
- memset(st->local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
- st->own_mask = 0;
- }
- else {
- /* Copy safe mask segment to local_mask */
- int i;
- for (i = 0; i < eager_nelem; i++)
- st->local_mask[i] = 0;
- for (i = eager_nelem; i < MPIR_MAX_CONTEXT_MASK; i++)
- st->local_mask[i] = context_mask[i];
-
- mask_in_use = 1;
- st->own_mask = 1;
- }
-
- }
-
- mpi_errno =
- st->comm_ptr->coll_fns->Iallreduce_sched(MPI_IN_PLACE, st->local_mask,
- MPIR_MAX_CONTEXT_MASK, MPI_UINT32_T, MPI_BAND,
- st->comm_ptr, st->s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPID_SCHED_BARRIER(st->s);
-
- mpi_errno = MPID_Sched_cb(&sched_cb_gcn_allocate_cid, st, st->s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPID_SCHED_BARRIER(st->s);
-
- fn_fail:
- return mpi_errno;
-}
-
-
-/** Allocating a new context ID collectively over the given communicator in a
- * nonblocking way.
- *
- * The nonblocking mechanism is implemented by inserting MPIDU_Sched_entry to
- * the nonblocking collective progress, which is a part of the progress engine.
- * It uses a two-level linked list 'all_schedules' to manager all nonblocking
- * collective calls: the first level is a linked list of struct MPIDU_Sched;
- * and each struct MPIDU_Sched is an array of struct MPIDU_Sched_entry. The
- * following four functions are used together to implement the algorithm:
- * sched_cb_gcn_copy_mask, sched_cb_gcn_allocate_cid, sched_cb_gcn_bcast and
- * sched_get_cid_nonblock.
- *
- * The above four functions use the same algorithm as
- * MPIR_Get_contextid_sparse_group (multi-threaded version) to allocate a
- * context id. The algorithm needs to retry the allocation process in the case
- * of conflicts. In MPIR_Get_contextid_sparse_group, it is a while loop. In
- * the nonblocking algorithm, 1) new entries are inserted to the end of
- * schedule to replace the 'while' loop in MPI_Comm_dup algorithm; 2) all
- * arguments passed to sched_get_cid_nonblock are saved to gcn_state in order
- * to be called in the future; 3) in sched_cb_gcn_allocate_cid, if the first
- * try failed, it will insert sched_cb_gcn_copy_mask to the schedule again.
- *
- * To ensure thread-safety, it shares the same global flag 'mask_in_use' with
- * other communicator functions to protect access to context_mask. And use
- * CONTEXTID lock to protect critical sections.
- *
- * There is a subtle difference between INTRACOMM and INTERCOMM when
- * duplicating a communicator. They needed to be treated differently in
- * current algorithm. Specifically, 1) when calling sched_get_cid_nonblock, the
- * parameters are different; 2) updating newcommp->recvcontext_id in
- * MPIR_Get_intercomm_contextid_nonblock has been moved to sched_cb_gcn_bcast
- * because this should happen after sched_cb_gcn_allocate_cid has succeed.
- *
- * To avoid deadlock or livelock, it uses the same eager protocol as
- * multi-threaded MPIR_Get_contextid_sparse_group.
- */
-#undef FUNCNAME
-#define FUNCNAME sched_get_cid_nonblock
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int sched_get_cid_nonblock(MPID_Comm * comm_ptr, MPID_Comm * newcomm,
- MPIR_Context_id_t * ctx0, MPIR_Context_id_t * ctx1,
- MPID_Sched_t s, MPID_Comm_kind_t gcn_cid_kind)
-{
- int mpi_errno = MPI_SUCCESS;
- struct gcn_state *st = NULL;
- MPIU_CHKPMEM_DECL(1);
-
- if (initialize_context_mask) {
- MPIR_Init_contextid();
- }
-
- MPIU_CHKPMEM_MALLOC(st, struct gcn_state *, sizeof(struct gcn_state), mpi_errno, "gcn_state");
- st->ctx0 = ctx0;
- st->ctx1 = ctx1;
- if (gcn_cid_kind == MPID_INTRACOMM) {
- st->comm_ptr = comm_ptr;
- st->comm_ptr_inter = NULL;
- }
- else {
- st->comm_ptr = comm_ptr->local_comm;
- st->comm_ptr_inter = comm_ptr;
- }
- st->s = s;
- st->gcn_cid_kind = gcn_cid_kind;
- *(st->ctx0) = 0;
- st->own_eager_mask = 0;
- st->first_iter = 1;
- st->new_comm = newcomm;
- /* idup_count > 1 means there are multiple communicators duplicating
- * from the current communicator at the same time. And
- * idup_curr_seqnum gives each duplication operation a priority */
- st->comm_ptr->idup_count++;
- st->seqnum = st->comm_ptr->idup_curr_seqnum++;
- st->own_mask = 0;
- if (eager_nelem < 0) {
- /* Ensure that at least one word of deadlock-free context IDs is
- * always set aside for the base protocol */
- MPIU_Assert(MPIR_CVAR_CTXID_EAGER_SIZE >= 0 &&
- MPIR_CVAR_CTXID_EAGER_SIZE < MPIR_MAX_CONTEXT_MASK - 1);
- eager_nelem = MPIR_CVAR_CTXID_EAGER_SIZE;
- }
-
- mpi_errno = MPID_Sched_cb(&sched_cb_gcn_copy_mask, st, s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPID_SCHED_BARRIER(s);
-
- MPIU_CHKPMEM_COMMIT();
- fn_exit:
- return mpi_errno;
- /* --BEGIN ERROR HANDLING-- */
- fn_fail:
- MPIU_CHKPMEM_REAP();
- goto fn_exit;
- /* --END ERROR HANDLING-- */
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIR_Get_contextid_nonblock
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid_nonblock(MPID_Comm * comm_ptr, MPID_Comm * newcommp, MPID_Request ** req)
-{
- int mpi_errno = MPI_SUCCESS;
- int tag;
- MPID_Sched_t s;
-
- MPID_MPI_STATE_DECL(MPID_STATE_MPIR_GET_CONTEXTID_NONBLOCK);
-
- MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_GET_CONTEXTID_NONBLOCK);
-
- /* now create a schedule */
- mpi_errno = MPID_Sched_next_tag(comm_ptr, &tag);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- mpi_errno = MPID_Sched_create(&s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
-
- /* add some entries to it */
- mpi_errno =
- sched_get_cid_nonblock(comm_ptr, newcommp, &newcommp->context_id, &newcommp->recvcontext_id,
- s, MPID_INTRACOMM);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
-
- /* finally, kick off the schedule and give the caller a request */
- mpi_errno = MPID_Sched_start(&s, comm_ptr, tag, req);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
-
- fn_exit:
- MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_CONTEXTID_NONBLOCK);
- return mpi_errno;
- /* --BEGIN ERROR HANDLING-- */
- fn_fail:
- goto fn_exit;
- /* --END ERROR HANDLING-- */
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIR_Get_intercomm_contextid_nonblock
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_intercomm_contextid_nonblock(MPID_Comm * comm_ptr, MPID_Comm * newcommp,
- MPID_Request ** req)
-{
- int mpi_errno = MPI_SUCCESS;
- int tag;
- MPID_Sched_t s;
- MPID_MPI_STATE_DECL(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID_NONBLOCK);
-
- MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID_NONBLOCK);
-
- /* do as much local setup as possible */
- if (!comm_ptr->local_comm) {
- mpi_errno = MPIR_Setup_intercomm_localcomm(comm_ptr);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- }
-
- /* now create a schedule */
- mpi_errno = MPID_Sched_next_tag(comm_ptr, &tag);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- mpi_errno = MPID_Sched_create(&s);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
-
- /* add some entries to it */
-
- /* first get a context ID over the local comm */
- mpi_errno =
- sched_get_cid_nonblock(comm_ptr, newcommp, &newcommp->recvcontext_id, &newcommp->context_id,
- s, MPID_INTERCOMM);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
-
- /* finally, kick off the schedule and give the caller a request */
- mpi_errno = MPID_Sched_start(&s, comm_ptr, tag, req);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
-
- fn_fail:
- MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID_NONBLOCK);
- return mpi_errno;
-}
-
-
-/* Get a context for a new intercomm. There are two approaches
- here (for MPI-1 codes only)
- (a) Each local group gets a context; the groups exchange, and
- the low value is accepted and the high one returned. This
- works because the context ids are taken from the same pool.
- (b) Form a temporary intracomm over all processes and use that
- with the regular algorithm.
-
- In some ways, (a) is the better approach because it is the one that
- extends to MPI-2 (where the last step, returning the context, is
- not used and instead separate send and receive context id value
- are kept). For this reason, we'll use (a).
-
- Even better is to separate the local and remote context ids. Then
- each group of processes can manage their context ids separately.
-*/
-/*
- * This uses the thread-safe (if necessary) routine to get a context id
- * and does not need its own thread-safe version.
- */
-#undef FUNCNAME
-#define FUNCNAME MPIR_Get_intercomm_contextid
-#undef FCNAME
-#define FCNAME "MPIR_Get_intercomm_contextid"
-int MPIR_Get_intercomm_contextid(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id,
- MPIR_Context_id_t * recvcontext_id)
-{
- MPIR_Context_id_t mycontext_id, remote_context_id;
- int mpi_errno = MPI_SUCCESS;
- int tag = 31567; /* FIXME - we need an internal tag or
- * communication channel. Can we use a different
- * context instead?. Or can we use the tag
- * provided in the intercomm routine? (not on a dup,
- * but in that case it can use the collective context) */
- mpir_errflag_t errflag = MPIR_ERR_NONE;
- MPID_MPI_STATE_DECL(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID);
-
- MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID);
-
- if (!comm_ptr->local_comm) {
- /* Manufacture the local communicator */
- mpi_errno = MPIR_Setup_intercomm_localcomm(comm_ptr);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- }
-
- mpi_errno = MPIR_Get_contextid(comm_ptr->local_comm, &mycontext_id);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPIU_Assert(mycontext_id != 0);
-
- /* MPIC routine uses an internal context id. The local leads (process 0)
- * exchange data */
- remote_context_id = -1;
- if (comm_ptr->rank == 0) {
- mpi_errno = MPIC_Sendrecv(&mycontext_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, tag,
- &remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, tag,
- comm_ptr, MPI_STATUS_IGNORE, &errflag);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- }
-
- /* Make sure that all of the local processes now have this
- * id */
- mpi_errno = MPIR_Bcast_impl(&remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE,
- 0, comm_ptr->local_comm, &errflag);
- if (mpi_errno)
- MPIU_ERR_POP(mpi_errno);
- MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
- /* The recvcontext_id must be the one that was allocated out of the local
- * group, not the remote group. Otherwise we could end up posting two
- * MPI_ANY_SOURCE,MPI_ANY_TAG recvs on the same context IDs even though we
- * are attempting to post them for two separate communicators. */
- *context_id = remote_context_id;
- *recvcontext_id = mycontext_id;
- fn_fail:
- MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID);
- return mpi_errno;
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIR_Free_contextid
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-void MPIR_Free_contextid(MPIR_Context_id_t context_id)
-{
- int idx, bitpos, raw_prefix;
- MPID_MPI_STATE_DECL(MPID_STATE_MPIR_FREE_CONTEXTID);
-
- MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_FREE_CONTEXTID);
-
- /* Convert the context id to the bit position */
- raw_prefix = MPID_CONTEXT_READ_FIELD(PREFIX, context_id);
- idx = raw_prefix / MPIR_CONTEXT_INT_BITS;
- bitpos = raw_prefix % MPIR_CONTEXT_INT_BITS;
-
- /* --BEGIN ERROR HANDLING-- */
- if (idx < 0 || idx >= MPIR_MAX_CONTEXT_MASK) {
- MPID_Abort(0, MPI_ERR_INTERN, 1, "In MPIR_Free_contextid, idx is out of range");
- }
- /* --END ERROR HANDLING-- */
-
- /* The low order bits for dynamic context IDs don't have meaning the
- * same way that low bits of non-dynamic ctx IDs do. So we have to
- * check the dynamic case first. */
- if (MPID_CONTEXT_READ_FIELD(DYNAMIC_PROC, context_id)) {
- MPIU_DBG_MSG_D(COMM, VERBOSE, "skipping dynamic process ctx id, context_id=%d", context_id);
- goto fn_exit;
- }
- else { /* non-dynamic context ID */
- /* In terms of the context ID bit vector, intercomms and their constituent
- * localcomms have the same value. To avoid a double-free situation we just
- * don't free the context ID for localcomms and assume it will be cleaned up
- * when the parent intercomm is itself completely freed. */
- if (MPID_CONTEXT_READ_FIELD(IS_LOCALCOMM, context_id)) {
-#ifdef USE_DBG_LOGGING
- char dump_str[1024];
- MPIR_Comm_dump_context_id(context_id, dump_str, sizeof(dump_str));
- MPIU_DBG_MSG_S(COMM, VERBOSE, "skipping localcomm id: %s", dump_str);
-#endif
- goto fn_exit;
- }
- else if (MPID_CONTEXT_READ_FIELD(SUBCOMM, context_id)) {
- MPIU_DBG_MSG_D(COMM, VERBOSE, "skipping non-parent communicator ctx id, context_id=%d",
- context_id);
- goto fn_exit;
- }
- }
-
- /* --BEGIN ERROR HANDLING-- */
- /* Check that this context id has been allocated */
- if ((context_mask[idx] & (0x1 << bitpos)) != 0) {
-#ifdef USE_DBG_LOGGING
- char dump_str[1024];
- MPIR_Comm_dump_context_id(context_id, dump_str, sizeof(dump_str));
- MPIU_DBG_MSG_S(COMM, VERBOSE, "context dump: %s", dump_str);
- MPIU_DBG_MSG_S(COMM, VERBOSE, "context mask = %s", MPIR_ContextMaskToStr());
-#endif
- MPID_Abort(0, MPI_ERR_INTERN, 1, "In MPIR_Free_contextid, the context id is not in use");
- }
- /* --END ERROR HANDLING-- */
-
- MPIU_THREAD_CS_ENTER(CONTEXTID,);
- /* MT: Note that this update must be done atomically in the multithreaedd
- * case. In the "one, single lock" implementation, that lock is indeed
- * held when this operation is called. */
- context_mask[idx] |= (0x1 << bitpos);
- MPIU_THREAD_CS_EXIT(CONTEXTID,);
-
- MPIU_DBG_MSG_FMT(COMM, VERBOSE,
- (MPIU_DBG_FDEST,
- "Freed context %d, mask[%d] bit %d (prefix=%#x)",
- context_id, idx, bitpos, raw_prefix));
- fn_exit:
- MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_FREE_CONTEXTID);
-}
-
-/*
* Copy a communicator, including creating a new context and copying the
* virtual connection tables and clearing the various fields.
* Does *not* copy attributes. If size is < the size of the local group
@@ -1919,16 +746,6 @@ int MPIR_Comm_copy(MPID_Comm * comm_ptr, int size, MPID_Comm ** outcomm_ptr)
MPIU_ERR_POP(mpi_errno);
MPIU_Assert(new_context_id != 0);
}
- /* --BEGIN ERROR HANDLING-- */
- if (new_context_id == 0) {
- int nfree = -1;
- int ntotal = -1;
- MPIR_ContextMaskStats(&nfree, &ntotal);
- MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
- "**toomanycomm", "**toomanycomm %d %d %d",
- nfree, ntotal, /*ignore_id= */ 0);
- }
- /* --END ERROR HANDLING-- */
/* This is the local size, not the remote size, in the case of
* an intercomm */
diff --git a/src/mpi/comm/contextid.c b/src/mpi/comm/contextid.c
new file mode 100644
index 0000000..ea0fed7
--- /dev/null
+++ b/src/mpi/comm/contextid.c
@@ -0,0 +1,1195 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ * (C) 2001 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "mpiimpl.h"
+#include "mpicomm.h"
+#include "mpiinfo.h" /* MPIU_Info_free */
+
+#include "mpl_utlist.h"
+#include "mpiu_uthash.h"
+
+/*
+=== BEGIN_MPI_T_CVAR_INFO_BLOCK ===
+
+cvars:
+ - name : MPIR_CVAR_CTXID_EAGER_SIZE
+ category : THREADS
+ type : int
+ default : 2
+ class : device
+ verbosity : MPI_T_VERBOSITY_USER_BASIC
+ scope : MPI_T_SCOPE_ALL_EQ
+ description : >-
+ The MPIR_CVAR_CTXID_EAGER_SIZE environment variable allows you to
+ specify how many words in the context ID mask will be set aside
+ for the eager allocation protocol. If the application is running
+ out of context IDs, reducing this value may help.
+
+=== END_MPI_T_CVAR_INFO_BLOCK ===
+*/
+
+/*
+ * Here are the routines to find a new context id. The algorithm is discussed
+ * in detail in the mpich coding document. There are versions for
+ * single threaded and multithreaded MPI.
+ *
+ * Both the threaded and non-threaded routines use the same mask of
+ * available context id values.
+ */
+static uint32_t context_mask[MPIR_MAX_CONTEXT_MASK];
+static int initialize_context_mask = 1;
+
+/* utility function to pretty print a context ID for debugging purposes, see
+ * mpiimpl.h for more info on the various fields */
+#ifdef USE_DBG_LOGGING
+static void MPIR_Comm_dump_context_id(MPIR_Context_id_t context_id, char *out_str, int len)
+{
+ int subcomm_type = MPID_CONTEXT_READ_FIELD(SUBCOMM, context_id);
+ const char *subcomm_type_name = NULL;
+
+ switch (subcomm_type) {
+ case 0:
+ subcomm_type_name = "parent";
+ break;
+ case 1:
+ subcomm_type_name = "intranode";
+ break;
+ case 2:
+ subcomm_type_name = "internode";
+ break;
+ default:
+ MPIU_Assert(FALSE);
+ break;
+ }
+ MPIU_Snprintf(out_str, len,
+ "context_id=%d (%#x): DYNAMIC_PROC=%d PREFIX=%#x IS_LOCALCOMM=%d SUBCOMM=%s SUFFIX=%s",
+ context_id,
+ context_id,
+ MPID_CONTEXT_READ_FIELD(DYNAMIC_PROC, context_id),
+ MPID_CONTEXT_READ_FIELD(PREFIX, context_id),
+ MPID_CONTEXT_READ_FIELD(IS_LOCALCOMM, context_id),
+ subcomm_type_name,
+ (MPID_CONTEXT_READ_FIELD(SUFFIX, context_id) ? "coll" : "pt2pt"));
+}
+#endif
+
+/* Create a string that contains the context mask. This is
+ used only with the logging interface, and must be used by one thread at
+ a time (should this be enforced by the logging interface?).
+ Converts the mask to hex and returns a pointer to that string.
+
+ Callers should own the context ID critical section, or should be prepared to
+ suffer data races in any fine-grained locking configuration.
+
+ This routine is no longer static in order to allow advanced users and
+ developers to debug context ID problems "in the field". We provide a
+ prototype here to keep the compiler happy, but users will need to put a
+ (possibly "extern") copy of the prototype in their own code in order to call
+ this routine.
+ */
+char *MPIR_ContextMaskToStr(void);
+char *MPIR_ContextMaskToStr(void)
+{
+ static char bufstr[MPIR_MAX_CONTEXT_MASK * 8 + 1];
+ int i;
+ int maxset = 0;
+
+ for (maxset = MPIR_MAX_CONTEXT_MASK - 1; maxset >= 0; maxset--) {
+ if (context_mask[maxset] != 0)
+ break;
+ }
+
+ for (i = 0; i < maxset; i++) {
+ MPIU_Snprintf(&bufstr[i * 8], 9, "%.8x", context_mask[i]);
+ }
+ return bufstr;
+}
+
+/* Returns useful debugging information about the context ID mask bit-vector.
+ * This includes the total number of possibly valid IDs (the size of the ID
+ * space) and the number of free IDs remaining in the mask. NULL arguments are
+ * fine, they will be ignored.
+ *
+ * This routine is for debugging in very particular situations and does not
+ * attempt to control concurrent access to the mask vector.
+ *
+ * Callers should own the context ID critical section, or should be prepared to
+ * suffer data races in any fine-grained locking configuration.
+ *
+ * The routine is non-static in order to permit "in the field debugging". We
+ * provide a prototype here to keep the compiler happy. */
+void MPIR_ContextMaskStats(int *free_ids, int *total_ids);
+void MPIR_ContextMaskStats(int *free_ids, int *total_ids)
+{
+ if (free_ids) {
+ int i, j;
+ *free_ids = 0;
+
+ /* if this ever needs to be fast, use a lookup table to do a per-nibble
+ * or per-byte lookup of the popcount instead of checking each bit at a
+ * time (or just track the count when manipulating the mask and keep
+ * that count stored in a variable) */
+ for (i = 0; i < MPIR_MAX_CONTEXT_MASK; ++i) {
+ for (j = 0; j < sizeof(context_mask[0]) * 8; ++j) {
+ *free_ids += (context_mask[i] & (0x1 << j)) >> j;
+ }
+ }
+ }
+ if (total_ids) {
+ *total_ids = MPIR_MAX_CONTEXT_MASK * sizeof(context_mask[0]) * 8;
+ }
+}
+
+#ifdef MPICH_DEBUG_HANDLEALLOC
+static int MPIU_CheckContextIDsOnFinalize(void *context_mask_ptr)
+{
+ int i;
+ uint32_t *mask = context_mask_ptr;
+ /* the predefined communicators should be freed by this point, so we don't
+ * need to special case bits 0,1, and 2 */
+ for (i = 0; i < MPIR_MAX_CONTEXT_MASK; ++i) {
+ if (~mask[i]) {
+ /* some bits were still cleared */
+ printf("leaked context IDs detected: mask=%p mask[%d]=%#x\n", mask, i, (int) mask[i]);
+ }
+ }
+ return MPI_SUCCESS;
+}
+#endif
+
+static void MPIR_Init_contextid(void)
+{
+ int i;
+
+ for (i = 1; i < MPIR_MAX_CONTEXT_MASK; i++) {
+ context_mask[i] = 0xFFFFFFFF;
+ }
+ /* The first two values are already used (comm_world, comm_self).
+ * The third value is also used for the internal-only copy of
+ * comm_world, if needed by mpid. */
+#ifdef MPID_NEEDS_ICOMM_WORLD
+ context_mask[0] = 0xFFFFFFF8;
+#else
+ context_mask[0] = 0xFFFFFFFC;
+#endif
+ initialize_context_mask = 0;
+
+#ifdef MPICH_DEBUG_HANDLEALLOC
+ /* check for context ID leaks in MPI_Finalize. Use (_PRIO-1) to make sure
+ * that we run after MPID_Finalize. */
+ MPIR_Add_finalize(MPIU_CheckContextIDsOnFinalize, context_mask,
+ MPIR_FINALIZE_CALLBACK_PRIO - 1);
+#endif
+}
+
+/* Return the context id corresponding to the first set bit in the mask.
+ Return 0 if no bit found. This function does _not_ alter local_mask. */
+static int MPIR_Locate_context_bit(uint32_t local_mask[])
+{
+ int i, j, context_id = 0;
+ for (i = 0; i < MPIR_MAX_CONTEXT_MASK; i++) {
+ if (local_mask[i]) {
+ /* There is a bit set in this word. */
+ register uint32_t val, nval;
+ /* The following code finds the highest set bit by recursively
+ * checking the top half of a subword for a bit, and incrementing
+ * the bit location by the number of bit of the lower sub word if
+ * the high subword contains a set bit. The assumption is that
+ * full-word bitwise operations and compares against zero are
+ * fast */
+ val = local_mask[i];
+ j = 0;
+ nval = val & 0xFFFF0000;
+ if (nval) {
+ j += 16;
+ val = nval;
+ }
+ nval = val & 0xFF00FF00;
+ if (nval) {
+ j += 8;
+ val = nval;
+ }
+ nval = val & 0xF0F0F0F0;
+ if (nval) {
+ j += 4;
+ val = nval;
+ }
+ nval = val & 0xCCCCCCCC;
+ if (nval) {
+ j += 2;
+ val = nval;
+ }
+ if (val & 0xAAAAAAAA) {
+ j += 1;
+ }
+ context_id = (MPIR_CONTEXT_INT_BITS * i + j) << MPID_CONTEXT_PREFIX_SHIFT;
+ return context_id;
+ }
+ }
+ return 0;
+}
+
+/* Allocates a context ID from the given mask by clearing the bit
+ * corresponding to the the given id. Returns 0 on failure, id on
+ * success. */
+static int MPIR_Allocate_context_bit(uint32_t mask[], MPIR_Context_id_t id)
+{
+ int raw_prefix, idx, bitpos;
+ raw_prefix = MPID_CONTEXT_READ_FIELD(PREFIX, id);
+ idx = raw_prefix / MPIR_CONTEXT_INT_BITS;
+ bitpos = raw_prefix % MPIR_CONTEXT_INT_BITS;
+
+ /* the bit should not already be cleared (allocated) */
+ MPIU_Assert(mask[idx] & (1 << bitpos));
+
+ /* clear the bit */
+ mask[idx] &= ~(1 << bitpos);
+
+ MPIU_DBG_MSG_FMT(COMM, VERBOSE, (MPIU_DBG_FDEST,
+ "allocating contextid = %d, (mask=%p, mask[%d], bit %d)",
+ id, mask, idx, bitpos));
+ return id;
+}
+
+/* Allocates the first available context ID from context_mask based on the available
+ * bits given in local_mask. This function will clear the corresponding bit in
+ * context_mask if allocation was successful.
+ *
+ * Returns 0 on failure. Returns the allocated context ID on success. */
+static int MPIR_Find_and_allocate_context_id(uint32_t local_mask[])
+{
+ MPIR_Context_id_t context_id;
+ context_id = MPIR_Locate_context_bit(local_mask);
+ if (context_id != 0) {
+ context_id = MPIR_Allocate_context_bit(context_mask, context_id);
+ }
+ return context_id;
+}
+
+/* Older, simpler interface. Allocates a context ID collectively over the given
+ * communicator. */
+#undef FUNCNAME
+#define FUNCNAME MPIR_Get_contextid
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIR_Get_contextid(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id)
+{
+ int mpi_errno = MPI_SUCCESS;
+ mpi_errno = MPIR_Get_contextid_sparse(comm_ptr, context_id, FALSE);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPIU_Assert(*context_id != MPIR_INVALID_CONTEXT_ID);
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (*context_id == 0) {
+ int nfree = -1;
+ int ntotal = -1;
+ MPIR_ContextMaskStats(&nfree, &ntotal);
+ MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
+ "**toomanycomm", "**toomanycomm %d %d %d",
+ nfree, ntotal, /*ignore_id= */ 0);
+ }
+ /* --END ERROR HANDLING-- */
+ fn_fail:
+ return mpi_errno;
+}
+
+
+/* EAGER CONTEXT ID ALLOCATION: Attempt to allocate the context ID during the
+ * initial synchronization step. If eager protocol fails, threads fall back to
+ * the base algorithm.
+ *
+ * They are used to avoid deadlock in multi-threaded case. In single-threaded
+ * case, they are not used.
+ */
+static volatile int eager_nelem = -1;
+static volatile int eager_in_use = 0;
+
+/* In multi-threaded case, mask_in_use is used to maintain thread safety. In
+ * single-threaded case, it is always 0. */
+static volatile int mask_in_use = 0;
+
+/* In multi-threaded case, lowestContextId is used to prioritize access when
+ * multiple threads are contending for the mask, lowestTag is used to break
+ * ties when MPI_Comm_create_group is invoked my multiple threads on the same
+ * parent communicator. In single-threaded case, lowestContextId is always
+ * set to parent context id in sched_cb_gcn_copy_mask and lowestTag is not
+ * used.
+ */
+#define MPIR_MAXID (1 << 30)
+static volatile int lowestContextId = MPIR_MAXID;
+static volatile int lowestTag = -1;
+
+#undef FUNCNAME
+#define FUNCNAME MPIR_Get_contextid_sparse
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIR_Get_contextid_sparse(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id, int ignore_id)
+{
+ return MPIR_Get_contextid_sparse_group(comm_ptr, NULL /*group_ptr */ ,
+ MPIR_Process.attrs.tag_ub /*tag */ ,
+ context_id, ignore_id);
+}
+
+/* Allocates a new context ID collectively over the given communicator. This
+ * routine is "sparse" in the sense that while it is collective, some processes
+ * may not care about the value selected context ID.
+ *
+ * One example of this case is processes who pass MPI_UNDEFINED as the color
+ * value to MPI_Comm_split. Such processes should pass ignore_id==TRUE to
+ * obtain the best performance and utilization of the context ID space.
+ *
+ * Processes that pass ignore_id==TRUE will receive
+ * (*context_id==MPIR_INVALID_CONTEXT_ID) and should not attempt to use it.
+ *
+ * If a group pointer is given, the call is _not_ sparse, and only processes
+ * in the group should call this routine. That is, it is collective only over
+ * the given group.
+ */
+#undef FUNCNAME
+#define FUNCNAME MPIR_Get_contextid_sparse_group
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr, int tag,
+ MPIR_Context_id_t * context_id, int ignore_id)
+{
+ int mpi_errno = MPI_SUCCESS;
+ const int ALL_OWN_MASK_FLAG = MPIR_MAX_CONTEXT_MASK;
+ uint32_t local_mask[MPIR_MAX_CONTEXT_MASK + 1];
+ int own_mask = 0;
+ int own_eager_mask = 0;
+ mpir_errflag_t errflag = MPIR_ERR_NONE;
+ int first_iter = 1;
+ int seqnum = 0;
+ MPID_MPI_STATE_DECL(MPID_STATE_MPIR_GET_CONTEXTID);
+
+ MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_GET_CONTEXTID);
+
+ /* Group-collective and ignore_id should never be combined */
+ MPIU_Assert(!(group_ptr != NULL && ignore_id));
+
+ *context_id = 0;
+
+ MPIU_DBG_MSG_FMT(COMM, VERBOSE, (MPIU_DBG_FDEST,
+ "Entering; shared state is %d:%d:%d, my ctx id is %d, tag=%d",
+ mask_in_use, lowestContextId, lowestTag, comm_ptr->context_id,
+ tag));
+
+ while (*context_id == 0) {
+ /* We lock only around access to the mask (except in the global locking
+ * case). If another thread is using the mask, we take a mask of zero. */
+ MPIU_THREAD_CS_ENTER(CONTEXTID,);
+
+ if (initialize_context_mask) {
+ MPIR_Init_contextid();
+ }
+
+ if (eager_nelem < 0) {
+ /* Ensure that at least one word of deadlock-free context IDs is
+ * always set aside for the base protocol */
+ MPIU_Assert(MPIR_CVAR_CTXID_EAGER_SIZE >= 0 &&
+ MPIR_CVAR_CTXID_EAGER_SIZE < MPIR_MAX_CONTEXT_MASK - 1);
+ eager_nelem = MPIR_CVAR_CTXID_EAGER_SIZE;
+ }
+
+ if (ignore_id) {
+ /* We are not participating in the resulting communicator, so our
+ * context ID space doesn't matter. Set the mask to "all available". */
+ memset(local_mask, 0xff, MPIR_MAX_CONTEXT_MASK * sizeof(int));
+ own_mask = 0;
+ /* don't need to touch mask_in_use/lowestContextId b/c our thread
+ * doesn't ever need to "win" the mask */
+ }
+
+ /* Deadlock avoidance: Only participate in context id loop when all
+ * processes have called this routine. On the first iteration, use the
+ * "eager" allocation protocol.
+ */
+ else if (first_iter) {
+ memset(local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
+ own_eager_mask = 0;
+ if (comm_ptr->idup_count)
+ seqnum = comm_ptr->idup_curr_seqnum++;
+
+
+ /* Attempt to reserve the eager mask segment */
+ if (!eager_in_use && eager_nelem > 0) {
+ int i;
+ for (i = 0; i < eager_nelem; i++)
+ local_mask[i] = context_mask[i];
+
+ eager_in_use = 1;
+ own_eager_mask = 1;
+ }
+ }
+
+ else {
+ /* lowestTag breaks ties when contextIds are the same (happens only
+ * in calls to MPI_Comm_create_group. */
+ if (comm_ptr->context_id < lowestContextId ||
+ (comm_ptr->context_id == lowestContextId && tag < lowestTag)) {
+ lowestContextId = comm_ptr->context_id;
+ lowestTag = tag;
+ }
+
+ if (mask_in_use || !(comm_ptr->context_id == lowestContextId && tag == lowestTag) ||
+ (comm_ptr->idup_count && seqnum != comm_ptr->idup_next_seqnum)) {
+ memset(local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
+ own_mask = 0;
+ MPIU_DBG_MSG_D(COMM, VERBOSE, "In in-use, set lowestContextId to %d",
+ lowestContextId);
+ }
+ else {
+ int i;
+
+ /* Copy safe mask segment to local_mask */
+ for (i = 0; i < eager_nelem; i++)
+ local_mask[i] = 0;
+ for (i = eager_nelem; i < MPIR_MAX_CONTEXT_MASK; i++)
+ local_mask[i] = context_mask[i];
+
+ mask_in_use = 1;
+ own_mask = 1;
+ MPIU_DBG_MSG(COMM, VERBOSE, "Copied local_mask");
+ }
+ }
+ MPIU_THREAD_CS_EXIT(CONTEXTID,);
+
+ /* Note: MPIR_MAX_CONTEXT_MASK elements of local_mask are used by the
+ * context ID allocation algorithm. The additional element is ignored
+ * by the context ID mask access routines and is used as a flag for
+ * detecting context ID exhaustion (explained below). */
+ if (own_mask || ignore_id)
+ local_mask[ALL_OWN_MASK_FLAG] = 1;
+ else
+ local_mask[ALL_OWN_MASK_FLAG] = 0;
+
+ /* Now, try to get a context id */
+ MPIU_Assert(comm_ptr->comm_kind == MPID_INTRACOMM);
+ /* In the global and brief-global cases, note that this routine will
+ * release that global lock when it needs to wait. That will allow
+ * other processes to enter the global or brief global critical section.
+ */
+ if (group_ptr != NULL) {
+ int coll_tag = tag | MPIR_Process.tagged_coll_mask; /* Shift tag into the tagged coll space */
+ mpi_errno = MPIR_Allreduce_group(MPI_IN_PLACE, local_mask, MPIR_MAX_CONTEXT_MASK + 1,
+ MPI_INT, MPI_BAND, comm_ptr, group_ptr, coll_tag,
+ &errflag);
+ }
+ else {
+ mpi_errno = MPIR_Allreduce_impl(MPI_IN_PLACE, local_mask, MPIR_MAX_CONTEXT_MASK + 1,
+ MPI_INT, MPI_BAND, comm_ptr, &errflag);
+ }
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
+
+ /* MT FIXME 2/3 cases don't seem to need the CONTEXTID CS, check and
+ * narrow this region */
+ MPIU_THREAD_CS_ENTER(CONTEXTID,);
+ if (ignore_id) {
+ /* we don't care what the value was, but make sure that everyone
+ * who did care agreed on a value */
+ *context_id = MPIR_Locate_context_bit(local_mask);
+ /* used later in out-of-context ids check and outer while loop condition */
+ }
+ else if (own_eager_mask) {
+ /* There is a chance that we've found a context id */
+ /* Find_and_allocate_context_id updates the context_mask if it finds a match */
+ *context_id = MPIR_Find_and_allocate_context_id(local_mask);
+ MPIU_DBG_MSG_D(COMM, VERBOSE, "Context id is now %hd", *context_id);
+
+ own_eager_mask = 0;
+ eager_in_use = 0;
+
+ if (*context_id <= 0) {
+ /* else we did not find a context id. Give up the mask in case
+ * there is another thread (with a lower input context id)
+ * waiting for it. We need to ensure that any other threads
+ * have the opportunity to run, hence yielding */
+ MPIU_THREAD_CS_YIELD(CONTEXTID,);
+ }
+ }
+ else if (own_mask) {
+ /* There is a chance that we've found a context id */
+ /* Find_and_allocate_context_id updates the context_mask if it finds a match */
+ *context_id = MPIR_Find_and_allocate_context_id(local_mask);
+ MPIU_DBG_MSG_D(COMM, VERBOSE, "Context id is now %hd", *context_id);
+
+ mask_in_use = 0;
+
+ if (*context_id > 0) {
+ /* If we were the lowest context id, reset the value to
+ * allow the other threads to compete for the mask */
+ if (lowestContextId == comm_ptr->context_id && lowestTag == tag) {
+ lowestContextId = MPIR_MAXID;
+ lowestTag = -1;
+ /* Else leave it alone; there is another thread waiting */
+ }
+ comm_ptr->idup_curr_seqnum++;
+ }
+ else {
+ /* else we did not find a context id. Give up the mask in case
+ * there is another thread (with a lower input context id)
+ * waiting for it. We need to ensure that any other threads
+ * have the opportunity to run, hence yielding */
+ MPIU_THREAD_CS_YIELD(CONTEXTID,);
+ }
+ }
+ else {
+ /* As above, force this thread to yield */
+ MPIU_THREAD_CS_YIELD(CONTEXTID,);
+ }
+ MPIU_THREAD_CS_EXIT(CONTEXTID,);
+
+ /* Test for context ID exhaustion: All threads that will participate in
+ * the new communicator owned the mask and could not allocate a context
+ * ID. This indicates that either some process has no context IDs
+ * available, or that some are available, but the allocation cannot
+ * succeed because there is no common context ID. */
+ if (*context_id == 0 && local_mask[ALL_OWN_MASK_FLAG] == 1) {
+ /* --BEGIN ERROR HANDLING-- */
+ int nfree = 0;
+ int ntotal = 0;
+ int minfree;
+
+ if (own_mask) {
+ MPIU_THREAD_CS_ENTER(CONTEXTID,);
+ mask_in_use = 0;
+ if (lowestContextId == comm_ptr->context_id && lowestTag == tag) {
+ lowestContextId = MPIR_MAXID;
+ lowestTag = -1;
+ }
+ MPIU_THREAD_CS_EXIT(CONTEXTID,);
+ }
+
+ MPIR_ContextMaskStats(&nfree, &ntotal);
+ if (ignore_id)
+ minfree = INT_MAX;
+ else
+ minfree = nfree;
+
+ if (group_ptr != NULL) {
+ int coll_tag = tag | MPIR_Process.tagged_coll_mask; /* Shift tag into the tagged coll space */
+ mpi_errno = MPIR_Allreduce_group(MPI_IN_PLACE, &minfree, 1, MPI_INT, MPI_MIN,
+ comm_ptr, group_ptr, coll_tag, &errflag);
+ }
+ else {
+ mpi_errno = MPIR_Allreduce_impl(MPI_IN_PLACE, &minfree, 1, MPI_INT,
+ MPI_MIN, comm_ptr, &errflag);
+ }
+
+ if (minfree > 0) {
+ MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
+ "**toomanycommfrag", "**toomanycommfrag %d %d %d",
+ nfree, ntotal, ignore_id);
+ }
+ else {
+ MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
+ "**toomanycomm", "**toomanycomm %d %d %d",
+ nfree, ntotal, ignore_id);
+ }
+ /* --END ERROR HANDLING-- */
+ }
+
+ first_iter = 0;
+ }
+ if (seqnum > 0)
+ comm_ptr->idup_next_seqnum++;
+
+
+ fn_exit:
+ if (ignore_id)
+ *context_id = MPIR_INVALID_CONTEXT_ID;
+ MPIU_DBG_MSG_S(COMM, VERBOSE, "Context mask = %s", MPIR_ContextMaskToStr());
+ MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_CONTEXTID);
+ return mpi_errno;
+
+ /* --BEGIN ERROR HANDLING-- */
+ fn_fail:
+ /* Release the masks */
+ if (own_mask) {
+ /* is it safe to access this without holding the CS? */
+ mask_in_use = 0;
+ }
+ goto fn_exit;
+ /* --END ERROR HANDLING-- */
+}
+
+struct gcn_state {
+ MPIR_Context_id_t *ctx0;
+ MPIR_Context_id_t *ctx1;
+ int own_mask;
+ int own_eager_mask;
+ int first_iter;
+ int seqnum;
+ MPID_Comm *comm_ptr;
+ MPID_Comm *comm_ptr_inter;
+ MPID_Sched_t s;
+ MPID_Comm *new_comm;
+ MPID_Comm_kind_t gcn_cid_kind;
+ uint32_t local_mask[MPIR_MAX_CONTEXT_MASK];
+};
+
+static int sched_cb_gcn_copy_mask(MPID_Comm * comm, int tag, void *state);
+static int sched_cb_gcn_allocate_cid(MPID_Comm * comm, int tag, void *state);
+static int sched_cb_gcn_bcast(MPID_Comm * comm, int tag, void *state);
+#undef FUNCNAME
+#define FUNCNAME sched_cb_commit_comm
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+static int sched_cb_commit_comm(MPID_Comm * comm, int tag, void *state)
+{
+ int mpi_errno = MPI_SUCCESS;
+ struct gcn_state *st = state;
+
+ mpi_errno = MPIR_Comm_commit(st->new_comm);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+
+ fn_fail:
+ return mpi_errno;
+
+}
+
+#undef FUNCNAME
+#define FUNCNAME sched_cb_gcn_bcast
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+static int sched_cb_gcn_bcast(MPID_Comm * comm, int tag, void *state)
+{
+ int mpi_errno = MPI_SUCCESS;
+ struct gcn_state *st = state;
+
+ if (st->gcn_cid_kind == MPID_INTERCOMM) {
+ if (st->comm_ptr_inter->rank == 0) {
+ mpi_errno =
+ MPID_Sched_recv(st->ctx1, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, st->comm_ptr_inter,
+ st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ mpi_errno =
+ MPID_Sched_send(st->ctx0, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, st->comm_ptr_inter,
+ st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPID_SCHED_BARRIER(st->s);
+ }
+
+ mpi_errno = st->comm_ptr->coll_fns->Ibcast_sched(st->ctx1, 1,
+ MPIR_CONTEXT_ID_T_DATATYPE, 0,
+ st->comm_ptr, st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPID_SCHED_BARRIER(st->s);
+ }
+
+ mpi_errno = MPID_Sched_cb(&sched_cb_commit_comm, st, st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ mpi_errno = MPID_Sched_cb(&MPIR_Sched_cb_free_buf, st, st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+
+ fn_fail:
+ return mpi_errno;
+}
+
+/* Try to find a valid context id.
+ *
+ * If the context id is found, then broadcast it; if not, then retry the
+ * nonblocking context id allocation algorithm again.
+ *
+ * Note the subtle difference on thread handling between the nonblocking
+ * algorithm (sched_cb_gcn_allocate_cid) and the blocking algorithm
+ * (MPIR_Get_contextid_sparse_group). In nonblocking algorithm, there is no
+ * need to yield to another thread because this thread will not block the
+ * progress. On the contrary, unnecessary yield will allow other threads to
+ * execute and insert wrong order of entries to the nonblocking schedule and
+ * cause errors.
+ */
+#undef FUNCNAME
+#define FUNCNAME sched_cb_gcn_allocate_cid
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+static int sched_cb_gcn_allocate_cid(MPID_Comm * comm, int tag, void *state)
+{
+ int mpi_errno = MPI_SUCCESS;
+ struct gcn_state *st = state;
+ MPIR_Context_id_t newctxid;
+
+ if (st->own_eager_mask) {
+ newctxid = MPIR_Find_and_allocate_context_id(st->local_mask);
+ if (st->ctx0)
+ *st->ctx0 = newctxid;
+ if (st->ctx1)
+ *st->ctx1 = newctxid;
+
+ st->own_eager_mask = 0;
+ eager_in_use = 0;
+ }
+ else if (st->own_mask) {
+ newctxid = MPIR_Find_and_allocate_context_id(st->local_mask);
+
+ if (st->ctx0)
+ *st->ctx0 = newctxid;
+ if (st->ctx1)
+ *st->ctx1 = newctxid;
+
+ /* reset flags for the next try */
+ mask_in_use = 0;
+
+ if (newctxid > 0) {
+ if (lowestContextId == st->comm_ptr->context_id)
+ lowestContextId = MPIR_MAXID;
+ }
+ }
+
+ if (*st->ctx0 == 0) {
+ /* do not own mask, try again */
+ mpi_errno = MPID_Sched_cb(&sched_cb_gcn_copy_mask, st, st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPID_SCHED_BARRIER(st->s);
+ }
+ else {
+ /* Successfully allocated a context id */
+
+ st->comm_ptr->idup_next_seqnum++;
+ st->comm_ptr->idup_count--;
+
+ mpi_errno = MPID_Sched_cb(&sched_cb_gcn_bcast, st, st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPID_SCHED_BARRIER(st->s);
+ }
+
+ /* --BEGIN ERROR HANDLING-- */
+ /* --END ERROR HANDLING-- */
+ fn_fail:
+ return mpi_errno;
+}
+
+#undef FUNCNAME
+#define FUNCNAME sched_cb_gcn_copy_mask
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+static int sched_cb_gcn_copy_mask(MPID_Comm * comm, int tag, void *state)
+{
+ int mpi_errno = MPI_SUCCESS;
+ struct gcn_state *st = state;
+
+ if (st->first_iter) {
+ memset(st->local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
+ st->own_eager_mask = 0;
+
+ /* Attempt to reserve the eager mask segment */
+ if (!eager_in_use && eager_nelem > 0) {
+ int i;
+ for (i = 0; i < eager_nelem; i++)
+ st->local_mask[i] = context_mask[i];
+
+ eager_in_use = 1;
+ st->own_eager_mask = 1;
+ }
+ st->first_iter = 0;
+
+ }
+ else {
+ if (st->comm_ptr->context_id < lowestContextId) {
+ lowestContextId = st->comm_ptr->context_id;
+ }
+
+ /* If one of the following conditions happens, set local_mask to zero
+ * so sched_cb_gcn_allocate_cid can not find a valid id and will retry:
+ * 1. mask is used by other threads;
+ * 2. the current MPI_COMM_IDUP operation does not has the lowestContextId;
+ * 3. for the case that multiple communicators duplicating from the
+ * same communicator at the same time, the sequence number of the
+ * current MPI_COMM_IDUP operation is not the smallest. */
+ if (mask_in_use || (st->comm_ptr->context_id != lowestContextId)
+ || (st->comm_ptr->idup_count > 1 && st->seqnum != st->comm_ptr->idup_next_seqnum)) {
+ memset(st->local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
+ st->own_mask = 0;
+ }
+ else {
+ /* Copy safe mask segment to local_mask */
+ int i;
+ for (i = 0; i < eager_nelem; i++)
+ st->local_mask[i] = 0;
+ for (i = eager_nelem; i < MPIR_MAX_CONTEXT_MASK; i++)
+ st->local_mask[i] = context_mask[i];
+
+ mask_in_use = 1;
+ st->own_mask = 1;
+ }
+
+ }
+
+ mpi_errno =
+ st->comm_ptr->coll_fns->Iallreduce_sched(MPI_IN_PLACE, st->local_mask,
+ MPIR_MAX_CONTEXT_MASK, MPI_UINT32_T, MPI_BAND,
+ st->comm_ptr, st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPID_SCHED_BARRIER(st->s);
+
+ mpi_errno = MPID_Sched_cb(&sched_cb_gcn_allocate_cid, st, st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPID_SCHED_BARRIER(st->s);
+
+ fn_fail:
+ return mpi_errno;
+}
+
+
+/** Allocating a new context ID collectively over the given communicator in a
+ * nonblocking way.
+ *
+ * The nonblocking mechanism is implemented by inserting MPIDU_Sched_entry to
+ * the nonblocking collective progress, which is a part of the progress engine.
+ * It uses a two-level linked list 'all_schedules' to manager all nonblocking
+ * collective calls: the first level is a linked list of struct MPIDU_Sched;
+ * and each struct MPIDU_Sched is an array of struct MPIDU_Sched_entry. The
+ * following four functions are used together to implement the algorithm:
+ * sched_cb_gcn_copy_mask, sched_cb_gcn_allocate_cid, sched_cb_gcn_bcast and
+ * sched_get_cid_nonblock.
+ *
+ * The above four functions use the same algorithm as
+ * MPIR_Get_contextid_sparse_group (multi-threaded version) to allocate a
+ * context id. The algorithm needs to retry the allocation process in the case
+ * of conflicts. In MPIR_Get_contextid_sparse_group, it is a while loop. In
+ * the nonblocking algorithm, 1) new entries are inserted to the end of
+ * schedule to replace the 'while' loop in MPI_Comm_dup algorithm; 2) all
+ * arguments passed to sched_get_cid_nonblock are saved to gcn_state in order
+ * to be called in the future; 3) in sched_cb_gcn_allocate_cid, if the first
+ * try failed, it will insert sched_cb_gcn_copy_mask to the schedule again.
+ *
+ * To ensure thread-safety, it shares the same global flag 'mask_in_use' with
+ * other communicator functions to protect access to context_mask. And use
+ * CONTEXTID lock to protect critical sections.
+ *
+ * There is a subtle difference between INTRACOMM and INTERCOMM when
+ * duplicating a communicator. They needed to be treated differently in
+ * current algorithm. Specifically, 1) when calling sched_get_cid_nonblock, the
+ * parameters are different; 2) updating newcommp->recvcontext_id in
+ * MPIR_Get_intercomm_contextid_nonblock has been moved to sched_cb_gcn_bcast
+ * because this should happen after sched_cb_gcn_allocate_cid has succeed.
+ *
+ * To avoid deadlock or livelock, it uses the same eager protocol as
+ * multi-threaded MPIR_Get_contextid_sparse_group.
+ */
+#undef FUNCNAME
+#define FUNCNAME sched_get_cid_nonblock
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+static int sched_get_cid_nonblock(MPID_Comm * comm_ptr, MPID_Comm * newcomm,
+ MPIR_Context_id_t * ctx0, MPIR_Context_id_t * ctx1,
+ MPID_Sched_t s, MPID_Comm_kind_t gcn_cid_kind)
+{
+ int mpi_errno = MPI_SUCCESS;
+ struct gcn_state *st = NULL;
+ MPIU_CHKPMEM_DECL(1);
+
+ if (initialize_context_mask) {
+ MPIR_Init_contextid();
+ }
+
+ MPIU_CHKPMEM_MALLOC(st, struct gcn_state *, sizeof(struct gcn_state), mpi_errno, "gcn_state");
+ st->ctx0 = ctx0;
+ st->ctx1 = ctx1;
+ if (gcn_cid_kind == MPID_INTRACOMM) {
+ st->comm_ptr = comm_ptr;
+ st->comm_ptr_inter = NULL;
+ }
+ else {
+ st->comm_ptr = comm_ptr->local_comm;
+ st->comm_ptr_inter = comm_ptr;
+ }
+ st->s = s;
+ st->gcn_cid_kind = gcn_cid_kind;
+ *(st->ctx0) = 0;
+ st->own_eager_mask = 0;
+ st->first_iter = 1;
+ st->new_comm = newcomm;
+ /* idup_count > 1 means there are multiple communicators duplicating
+ * from the current communicator at the same time. And
+ * idup_curr_seqnum gives each duplication operation a priority */
+ st->comm_ptr->idup_count++;
+ st->seqnum = st->comm_ptr->idup_curr_seqnum++;
+ st->own_mask = 0;
+ if (eager_nelem < 0) {
+ /* Ensure that at least one word of deadlock-free context IDs is
+ * always set aside for the base protocol */
+ MPIU_Assert(MPIR_CVAR_CTXID_EAGER_SIZE >= 0 &&
+ MPIR_CVAR_CTXID_EAGER_SIZE < MPIR_MAX_CONTEXT_MASK - 1);
+ eager_nelem = MPIR_CVAR_CTXID_EAGER_SIZE;
+ }
+
+ mpi_errno = MPID_Sched_cb(&sched_cb_gcn_copy_mask, st, s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPID_SCHED_BARRIER(s);
+
+ MPIU_CHKPMEM_COMMIT();
+ fn_exit:
+ return mpi_errno;
+ /* --BEGIN ERROR HANDLING-- */
+ fn_fail:
+ MPIU_CHKPMEM_REAP();
+ goto fn_exit;
+ /* --END ERROR HANDLING-- */
+}
+
+#undef FUNCNAME
+#define FUNCNAME MPIR_Get_contextid_nonblock
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIR_Get_contextid_nonblock(MPID_Comm * comm_ptr, MPID_Comm * newcommp, MPID_Request ** req)
+{
+ int mpi_errno = MPI_SUCCESS;
+ int tag;
+ MPID_Sched_t s;
+
+ MPID_MPI_STATE_DECL(MPID_STATE_MPIR_GET_CONTEXTID_NONBLOCK);
+
+ MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_GET_CONTEXTID_NONBLOCK);
+
+ /* now create a schedule */
+ mpi_errno = MPID_Sched_next_tag(comm_ptr, &tag);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ mpi_errno = MPID_Sched_create(&s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+
+ /* add some entries to it */
+ mpi_errno =
+ sched_get_cid_nonblock(comm_ptr, newcommp, &newcommp->context_id, &newcommp->recvcontext_id,
+ s, MPID_INTRACOMM);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+
+ /* finally, kick off the schedule and give the caller a request */
+ mpi_errno = MPID_Sched_start(&s, comm_ptr, tag, req);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+
+ fn_exit:
+ MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_CONTEXTID_NONBLOCK);
+ return mpi_errno;
+ /* --BEGIN ERROR HANDLING-- */
+ fn_fail:
+ goto fn_exit;
+ /* --END ERROR HANDLING-- */
+}
+
+#undef FUNCNAME
+#define FUNCNAME MPIR_Get_intercomm_contextid_nonblock
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+int MPIR_Get_intercomm_contextid_nonblock(MPID_Comm * comm_ptr, MPID_Comm * newcommp,
+ MPID_Request ** req)
+{
+ int mpi_errno = MPI_SUCCESS;
+ int tag;
+ MPID_Sched_t s;
+ MPID_MPI_STATE_DECL(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID_NONBLOCK);
+
+ MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID_NONBLOCK);
+
+ /* do as much local setup as possible */
+ if (!comm_ptr->local_comm) {
+ mpi_errno = MPIR_Setup_intercomm_localcomm(comm_ptr);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ }
+
+ /* now create a schedule */
+ mpi_errno = MPID_Sched_next_tag(comm_ptr, &tag);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ mpi_errno = MPID_Sched_create(&s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+
+ /* add some entries to it */
+
+ /* first get a context ID over the local comm */
+ mpi_errno =
+ sched_get_cid_nonblock(comm_ptr, newcommp, &newcommp->recvcontext_id, &newcommp->context_id,
+ s, MPID_INTERCOMM);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+
+ /* finally, kick off the schedule and give the caller a request */
+ mpi_errno = MPID_Sched_start(&s, comm_ptr, tag, req);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+
+ fn_fail:
+ MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID_NONBLOCK);
+ return mpi_errno;
+}
+
+
+/* Get a context for a new intercomm. There are two approaches
+ here (for MPI-1 codes only)
+ (a) Each local group gets a context; the groups exchange, and
+ the low value is accepted and the high one returned. This
+ works because the context ids are taken from the same pool.
+ (b) Form a temporary intracomm over all processes and use that
+ with the regular algorithm.
+
+ In some ways, (a) is the better approach because it is the one that
+ extends to MPI-2 (where the last step, returning the context, is
+ not used and instead separate send and receive context id value
+ are kept). For this reason, we'll use (a).
+
+ Even better is to separate the local and remote context ids. Then
+ each group of processes can manage their context ids separately.
+*/
+/*
+ * This uses the thread-safe (if necessary) routine to get a context id
+ * and does not need its own thread-safe version.
+ */
+#undef FUNCNAME
+#define FUNCNAME MPIR_Get_intercomm_contextid
+#undef FCNAME
+#define FCNAME "MPIR_Get_intercomm_contextid"
+int MPIR_Get_intercomm_contextid(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id,
+ MPIR_Context_id_t * recvcontext_id)
+{
+ MPIR_Context_id_t mycontext_id, remote_context_id;
+ int mpi_errno = MPI_SUCCESS;
+ int tag = 31567; /* FIXME - we need an internal tag or
+ * communication channel. Can we use a different
+ * context instead?. Or can we use the tag
+ * provided in the intercomm routine? (not on a dup,
+ * but in that case it can use the collective context) */
+ mpir_errflag_t errflag = MPIR_ERR_NONE;
+ MPID_MPI_STATE_DECL(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID);
+
+ MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID);
+
+ if (!comm_ptr->local_comm) {
+ /* Manufacture the local communicator */
+ mpi_errno = MPIR_Setup_intercomm_localcomm(comm_ptr);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ }
+
+ mpi_errno = MPIR_Get_contextid(comm_ptr->local_comm, &mycontext_id);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPIU_Assert(mycontext_id != 0);
+
+ /* MPIC routine uses an internal context id. The local leads (process 0)
+ * exchange data */
+ remote_context_id = -1;
+ if (comm_ptr->rank == 0) {
+ mpi_errno = MPIC_Sendrecv(&mycontext_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, tag,
+ &remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, tag,
+ comm_ptr, MPI_STATUS_IGNORE, &errflag);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ }
+
+ /* Make sure that all of the local processes now have this
+ * id */
+ mpi_errno = MPIR_Bcast_impl(&remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE,
+ 0, comm_ptr->local_comm, &errflag);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
+ /* The recvcontext_id must be the one that was allocated out of the local
+ * group, not the remote group. Otherwise we could end up posting two
+ * MPI_ANY_SOURCE,MPI_ANY_TAG recvs on the same context IDs even though we
+ * are attempting to post them for two separate communicators. */
+ *context_id = remote_context_id;
+ *recvcontext_id = mycontext_id;
+ fn_fail:
+ MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID);
+ return mpi_errno;
+}
+
+#undef FUNCNAME
+#define FUNCNAME MPIR_Free_contextid
+#undef FCNAME
+#define FCNAME MPIU_QUOTE(FUNCNAME)
+void MPIR_Free_contextid(MPIR_Context_id_t context_id)
+{
+ int idx, bitpos, raw_prefix;
+ MPID_MPI_STATE_DECL(MPID_STATE_MPIR_FREE_CONTEXTID);
+
+ MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_FREE_CONTEXTID);
+
+ /* Convert the context id to the bit position */
+ raw_prefix = MPID_CONTEXT_READ_FIELD(PREFIX, context_id);
+ idx = raw_prefix / MPIR_CONTEXT_INT_BITS;
+ bitpos = raw_prefix % MPIR_CONTEXT_INT_BITS;
+
+ /* --BEGIN ERROR HANDLING-- */
+ if (idx < 0 || idx >= MPIR_MAX_CONTEXT_MASK) {
+ MPID_Abort(0, MPI_ERR_INTERN, 1, "In MPIR_Free_contextid, idx is out of range");
+ }
+ /* --END ERROR HANDLING-- */
+
+ /* The low order bits for dynamic context IDs don't have meaning the
+ * same way that low bits of non-dynamic ctx IDs do. So we have to
+ * check the dynamic case first. */
+ if (MPID_CONTEXT_READ_FIELD(DYNAMIC_PROC, context_id)) {
+ MPIU_DBG_MSG_D(COMM, VERBOSE, "skipping dynamic process ctx id, context_id=%d", context_id);
+ goto fn_exit;
+ }
+ else { /* non-dynamic context ID */
+ /* In terms of the context ID bit vector, intercomms and their constituent
+ * localcomms have the same value. To avoid a double-free situation we just
+ * don't free the context ID for localcomms and assume it will be cleaned up
+ * when the parent intercomm is itself completely freed. */
+ if (MPID_CONTEXT_READ_FIELD(IS_LOCALCOMM, context_id)) {
+#ifdef USE_DBG_LOGGING
+ char dump_str[1024];
+ MPIR_Comm_dump_context_id(context_id, dump_str, sizeof(dump_str));
+ MPIU_DBG_MSG_S(COMM, VERBOSE, "skipping localcomm id: %s", dump_str);
+#endif
+ goto fn_exit;
+ }
+ else if (MPID_CONTEXT_READ_FIELD(SUBCOMM, context_id)) {
+ MPIU_DBG_MSG_D(COMM, VERBOSE, "skipping non-parent communicator ctx id, context_id=%d",
+ context_id);
+ goto fn_exit;
+ }
+ }
+
+ /* --BEGIN ERROR HANDLING-- */
+ /* Check that this context id has been allocated */
+ if ((context_mask[idx] & (0x1 << bitpos)) != 0) {
+#ifdef USE_DBG_LOGGING
+ char dump_str[1024];
+ MPIR_Comm_dump_context_id(context_id, dump_str, sizeof(dump_str));
+ MPIU_DBG_MSG_S(COMM, VERBOSE, "context dump: %s", dump_str);
+ MPIU_DBG_MSG_S(COMM, VERBOSE, "context mask = %s", MPIR_ContextMaskToStr());
+#endif
+ MPID_Abort(0, MPI_ERR_INTERN, 1, "In MPIR_Free_contextid, the context id is not in use");
+ }
+ /* --END ERROR HANDLING-- */
+
+ MPIU_THREAD_CS_ENTER(CONTEXTID,);
+ /* MT: Note that this update must be done atomically in the multithreaedd
+ * case. In the "one, single lock" implementation, that lock is indeed
+ * held when this operation is called. */
+ context_mask[idx] |= (0x1 << bitpos);
+ MPIU_THREAD_CS_EXIT(CONTEXTID,);
+
+ MPIU_DBG_MSG_FMT(COMM, VERBOSE,
+ (MPIU_DBG_FDEST,
+ "Freed context %d, mask[%d] bit %d (prefix=%#x)",
+ context_id, idx, bitpos, raw_prefix));
+ fn_exit:
+ MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_FREE_CONTEXTID);
+}
http://git.mpich.org/mpich.git/commitdiff/f9439c801ed29b7614f0d05bb4e5f10ac…
commit f9439c801ed29b7614f0d05bb4e5f10ace94d1c9
Author: Pavan Balaji <balaji(a)anl.gov>
Date: Thu Aug 6 22:32:04 2015 -0500
White space cleanup for the commutil file.
No reviewer.
diff --git a/src/mpi/comm/commutil.c b/src/mpi/comm/commutil.c
index dee8775..23af734 100644
--- a/src/mpi/comm/commutil.c
+++ b/src/mpi/comm/commutil.c
@@ -41,10 +41,18 @@ cvars:
/* Preallocated comm objects */
/* initialized in initthread.c */
MPID_Comm MPID_Comm_builtin[MPID_COMM_N_BUILTIN] = { {0} };
-MPID_Comm MPID_Comm_direct[MPID_COMM_PREALLOC] = { {0} };
-MPIU_Object_alloc_t MPID_Comm_mem = { 0, 0, 0, 0, MPID_COMM,
- sizeof(MPID_Comm), MPID_Comm_direct,
- MPID_COMM_PREALLOC};
+MPID_Comm MPID_Comm_direct[MPID_COMM_PREALLOC] = { {0} };
+
+MPIU_Object_alloc_t MPID_Comm_mem = {
+ 0,
+ 0,
+ 0,
+ 0,
+ MPID_COMM,
+ sizeof(MPID_Comm),
+ MPID_Comm_direct,
+ MPID_COMM_PREALLOC
+};
/* Communicator creation functions */
struct MPID_CommOps *MPID_Comm_fns = NULL;
@@ -61,24 +69,32 @@ static struct MPIR_Comm_hint_fn_elt *MPID_hint_fns = NULL;
#ifdef USE_DBG_LOGGING
static void MPIR_Comm_dump_context_id(MPIR_Context_id_t context_id, char *out_str, int len)
{
- int subcomm_type = MPID_CONTEXT_READ_FIELD(SUBCOMM,context_id);
+ int subcomm_type = MPID_CONTEXT_READ_FIELD(SUBCOMM, context_id);
const char *subcomm_type_name = NULL;
switch (subcomm_type) {
- case 0: subcomm_type_name = "parent"; break;
- case 1: subcomm_type_name = "intranode"; break;
- case 2: subcomm_type_name = "internode"; break;
- default: MPIU_Assert(FALSE); break;
+ case 0:
+ subcomm_type_name = "parent";
+ break;
+ case 1:
+ subcomm_type_name = "intranode";
+ break;
+ case 2:
+ subcomm_type_name = "internode";
+ break;
+ default:
+ MPIU_Assert(FALSE);
+ break;
}
MPIU_Snprintf(out_str, len,
"context_id=%d (%#x): DYNAMIC_PROC=%d PREFIX=%#x IS_LOCALCOMM=%d SUBCOMM=%s SUFFIX=%s",
context_id,
context_id,
- MPID_CONTEXT_READ_FIELD(DYNAMIC_PROC,context_id),
- MPID_CONTEXT_READ_FIELD(PREFIX,context_id),
- MPID_CONTEXT_READ_FIELD(IS_LOCALCOMM,context_id),
+ MPID_CONTEXT_READ_FIELD(DYNAMIC_PROC, context_id),
+ MPID_CONTEXT_READ_FIELD(PREFIX, context_id),
+ MPID_CONTEXT_READ_FIELD(IS_LOCALCOMM, context_id),
subcomm_type_name,
- (MPID_CONTEXT_READ_FIELD(SUFFIX,context_id) ? "coll" : "pt2pt"));
+ (MPID_CONTEXT_READ_FIELD(SUFFIX, context_id) ? "coll" : "pt2pt"));
}
#endif
@@ -96,7 +112,7 @@ static void MPIR_Comm_dump_context_id(MPIR_Context_id_t context_id, char *out_st
between when a context id is released and when it is reused. An alternative
is to use an explicit message (in the implementation of MPI_Comm_free)
to indicate that a communicator is being freed; this will often require
- less communication than a barrier in MPI_Comm_free, and will ensure that
+ less communication than a barrier in MPI_Comm_free, and will ensure that
no messages are later sent to the same communicator (we may also want to
have a similar check when building fault-tolerant versions of MPI).
*/
@@ -107,7 +123,7 @@ static void MPIR_Comm_dump_context_id(MPIR_Context_id_t context_id, char *out_st
* to it.
*
* !!! The resulting struct is _not_ ready for communication !!! */
-int MPIR_Comm_init(MPID_Comm *comm_p)
+int MPIR_Comm_init(MPID_Comm * comm_p)
{
int mpi_errno = MPI_SUCCESS;
@@ -121,23 +137,23 @@ int MPIR_Comm_init(MPID_Comm *comm_p)
comm_p->remote_size = -1;
/* Clear many items (empty means to use the default; some of these
- may be overridden within the upper-level communicator initialization) */
- comm_p->errhandler = NULL;
- comm_p->attributes = NULL;
+ * may be overridden within the upper-level communicator initialization) */
+ comm_p->errhandler = NULL;
+ comm_p->attributes = NULL;
comm_p->remote_group = NULL;
- comm_p->local_group = NULL;
- comm_p->coll_fns = NULL;
- comm_p->topo_fns = NULL;
- comm_p->name[0] = '\0';
- comm_p->info = NULL;
-
- comm_p->hierarchy_kind = MPID_HIERARCHY_FLAT;
- comm_p->node_comm = NULL;
+ comm_p->local_group = NULL;
+ comm_p->coll_fns = NULL;
+ comm_p->topo_fns = NULL;
+ comm_p->name[0] = '\0';
+ comm_p->info = NULL;
+
+ comm_p->hierarchy_kind = MPID_HIERARCHY_FLAT;
+ comm_p->node_comm = NULL;
comm_p->node_roots_comm = NULL;
comm_p->intranode_table = NULL;
comm_p->internode_table = NULL;
- /* abstractions bleed a bit here... :( */
+ /* abstractions bleed a bit here... :(*/
comm_p->next_sched_tag = MPIR_FIRST_NBC_TAG;
/* Initialize the revoked flag as false */
@@ -151,22 +167,22 @@ int MPIR_Comm_init(MPID_Comm *comm_p)
comm_p->mapper_tail = NULL;
/* Fields not set include context_id, remote and local size, and
- kind, since different communicator construction routines need
- different values */
-fn_fail:
+ * kind, since different communicator construction routines need
+ * different values */
+ fn_fail:
return mpi_errno;
}
/*
- Create a communicator structure and perform basic initialization
- (mostly clearing fields and updating the reference count).
+ Create a communicator structure and perform basic initialization
+ (mostly clearing fields and updating the reference count).
*/
#undef FUNCNAME
#define FUNCNAME MPIR_Comm_create
#undef FCNAME
#define FCNAME "MPIR_Comm_create"
-int MPIR_Comm_create( MPID_Comm **newcomm_ptr )
+int MPIR_Comm_create(MPID_Comm ** newcomm_ptr)
{
int mpi_errno = MPI_SUCCESS;
MPID_Comm *newptr;
@@ -174,20 +190,21 @@ int MPIR_Comm_create( MPID_Comm **newcomm_ptr )
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_COMM_CREATE);
- newptr = (MPID_Comm *)MPIU_Handle_obj_alloc( &MPID_Comm_mem );
+ newptr = (MPID_Comm *) MPIU_Handle_obj_alloc(&MPID_Comm_mem);
MPIU_ERR_CHKANDJUMP(!newptr, mpi_errno, MPI_ERR_OTHER, "**nomem");
*newcomm_ptr = newptr;
mpi_errno = MPIR_Comm_init(newptr);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* Insert this new communicator into the list of known communicators.
- Make this conditional on debugger support to match the test in
- MPIR_Comm_release . */
- MPIR_COMML_REMEMBER( newptr );
+ * Make this conditional on debugger support to match the test in
+ * MPIR_Comm_release . */
+ MPIR_COMML_REMEMBER(newptr);
- fn_fail:
+ fn_fail:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_CREATE);
return mpi_errno;
@@ -200,7 +217,7 @@ int MPIR_Comm_create( MPID_Comm **newcomm_ptr )
#define FUNCNAME MPIR_Setup_intercomm_localcomm
#undef FCNAME
#define FCNAME "MPIR_Setup_intercomm_localcomm"
-int MPIR_Setup_intercomm_localcomm( MPID_Comm *intercomm_ptr )
+int MPIR_Setup_intercomm_localcomm(MPID_Comm * intercomm_ptr)
{
MPID_Comm *localcomm_ptr;
int mpi_errno = MPI_SUCCESS;
@@ -208,31 +225,37 @@ int MPIR_Setup_intercomm_localcomm( MPID_Comm *intercomm_ptr )
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_SETUP_INTERCOMM_LOCALCOMM);
- localcomm_ptr = (MPID_Comm *)MPIU_Handle_obj_alloc( &MPID_Comm_mem );
- MPIU_ERR_CHKANDJUMP(!localcomm_ptr,mpi_errno,MPI_ERR_OTHER,"**nomem");
+ localcomm_ptr = (MPID_Comm *) MPIU_Handle_obj_alloc(&MPID_Comm_mem);
+ MPIU_ERR_CHKANDJUMP(!localcomm_ptr, mpi_errno, MPI_ERR_OTHER, "**nomem");
/* get sensible default values for most fields (usually zeros) */
mpi_errno = MPIR_Comm_init(localcomm_ptr);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* use the parent intercomm's recv ctx as the basis for our ctx */
- localcomm_ptr->recvcontext_id = MPID_CONTEXT_SET_FIELD(IS_LOCALCOMM, intercomm_ptr->recvcontext_id, 1);
+ localcomm_ptr->recvcontext_id =
+ MPID_CONTEXT_SET_FIELD(IS_LOCALCOMM, intercomm_ptr->recvcontext_id, 1);
localcomm_ptr->context_id = localcomm_ptr->recvcontext_id;
- MPIU_DBG_MSG_FMT(COMM,TYPICAL,(MPIU_DBG_FDEST, "setup_intercomm_localcomm ic=%p ic->context_id=%d ic->recvcontext_id=%d lc->recvcontext_id=%d", intercomm_ptr, intercomm_ptr->context_id, intercomm_ptr->recvcontext_id, localcomm_ptr->recvcontext_id));
+ MPIU_DBG_MSG_FMT(COMM, TYPICAL,
+ (MPIU_DBG_FDEST,
+ "setup_intercomm_localcomm ic=%p ic->context_id=%d ic->recvcontext_id=%d lc->recvcontext_id=%d",
+ intercomm_ptr, intercomm_ptr->context_id, intercomm_ptr->recvcontext_id,
+ localcomm_ptr->recvcontext_id));
/* Save the kind of the communicator */
- localcomm_ptr->comm_kind = MPID_INTRACOMM;
+ localcomm_ptr->comm_kind = MPID_INTRACOMM;
/* Set the sizes and ranks */
localcomm_ptr->remote_size = intercomm_ptr->local_size;
- localcomm_ptr->local_size = intercomm_ptr->local_size;
- localcomm_ptr->rank = intercomm_ptr->rank;
+ localcomm_ptr->local_size = intercomm_ptr->local_size;
+ localcomm_ptr->rank = intercomm_ptr->rank;
MPIR_Comm_map_dup(localcomm_ptr, intercomm_ptr, MPIR_COMM_MAP_DIR_L2L);
- /* TODO More advanced version: if the group is available, dup it by
- increasing the reference count instead of recreating it later */
+ /* TODO More advanced version: if the group is available, dup it by
+ * increasing the reference count instead of recreating it later */
/* FIXME : No coll_fns functions for the collectives */
/* FIXME : No local functions for the topology routines */
@@ -240,9 +263,10 @@ int MPIR_Setup_intercomm_localcomm( MPID_Comm *intercomm_ptr )
/* sets up the SMP-aware sub-communicators and tables */
mpi_errno = MPIR_Comm_commit(localcomm_ptr);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
- fn_fail:
+ fn_fail:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_SETUP_INTERCOMM_LOCALCOMM);
return mpi_errno;
@@ -251,7 +275,8 @@ int MPIR_Setup_intercomm_localcomm( MPID_Comm *intercomm_ptr )
/* holds default collop "vtables" for _intracomms_, where
* default[hierarchy_kind] is the pointer to the collop struct for that
* hierarchy kind */
-static struct MPID_Collops *default_collops[MPID_HIERARCHY_SIZE] = {NULL};
+static struct MPID_Collops *default_collops[MPID_HIERARCHY_SIZE] = { NULL };
+
/* default for intercomms */
static struct MPID_Collops *ic_default_collops = NULL;
@@ -259,7 +284,8 @@ static struct MPID_Collops *ic_default_collops = NULL;
#define FUNCNAME cleanup_default_collops
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int cleanup_default_collops(void *unused) {
+static int cleanup_default_collops(void *unused)
+{
int i;
for (i = 0; i < MPID_HIERARCHY_SIZE; ++i) {
if (default_collops[i]) {
@@ -286,12 +312,13 @@ static int init_default_collops(void)
int mpi_errno = MPI_SUCCESS;
int i;
struct MPID_Collops *ops = NULL;
- MPIU_CHKPMEM_DECL(MPID_HIERARCHY_SIZE+1);
+ MPIU_CHKPMEM_DECL(MPID_HIERARCHY_SIZE + 1);
/* first initialize the intracomms */
for (i = 0; i < MPID_HIERARCHY_SIZE; ++i) {
- MPIU_CHKPMEM_CALLOC(ops, struct MPID_Collops *, sizeof(struct MPID_Collops), mpi_errno, "default intracomm collops");
- ops->ref_count = 1; /* force existence until finalize time */
+ MPIU_CHKPMEM_CALLOC(ops, struct MPID_Collops *, sizeof(struct MPID_Collops), mpi_errno,
+ "default intracomm collops");
+ ops->ref_count = 1; /* force existence until finalize time */
/* intracomm default defaults... */
ops->Ibcast_sched = &MPIR_Ibcast_intra;
@@ -311,37 +338,37 @@ static int init_default_collops(void)
ops->Iallgatherv_sched = &MPIR_Iallgatherv_intra;
ops->Iscan_sched = &MPIR_Iscan_rec_dbl;
ops->Iexscan_sched = &MPIR_Iexscan;
- ops->Neighbor_allgather = &MPIR_Neighbor_allgather_default;
- ops->Neighbor_allgatherv = &MPIR_Neighbor_allgatherv_default;
- ops->Neighbor_alltoall = &MPIR_Neighbor_alltoall_default;
- ops->Neighbor_alltoallv = &MPIR_Neighbor_alltoallv_default;
- ops->Neighbor_alltoallw = &MPIR_Neighbor_alltoallw_default;
- ops->Ineighbor_allgather = &MPIR_Ineighbor_allgather_default;
+ ops->Neighbor_allgather = &MPIR_Neighbor_allgather_default;
+ ops->Neighbor_allgatherv = &MPIR_Neighbor_allgatherv_default;
+ ops->Neighbor_alltoall = &MPIR_Neighbor_alltoall_default;
+ ops->Neighbor_alltoallv = &MPIR_Neighbor_alltoallv_default;
+ ops->Neighbor_alltoallw = &MPIR_Neighbor_alltoallw_default;
+ ops->Ineighbor_allgather = &MPIR_Ineighbor_allgather_default;
ops->Ineighbor_allgatherv = &MPIR_Ineighbor_allgatherv_default;
- ops->Ineighbor_alltoall = &MPIR_Ineighbor_alltoall_default;
- ops->Ineighbor_alltoallv = &MPIR_Ineighbor_alltoallv_default;
- ops->Ineighbor_alltoallw = &MPIR_Ineighbor_alltoallw_default;
+ ops->Ineighbor_alltoall = &MPIR_Ineighbor_alltoall_default;
+ ops->Ineighbor_alltoallv = &MPIR_Ineighbor_alltoallv_default;
+ ops->Ineighbor_alltoallw = &MPIR_Ineighbor_alltoallw_default;
/* override defaults, such as for SMP */
switch (i) {
- case MPID_HIERARCHY_FLAT:
- break;
- case MPID_HIERARCHY_PARENT:
- ops->Ibcast_sched = &MPIR_Ibcast_SMP;
- ops->Iscan_sched = &MPIR_Iscan_SMP;
- ops->Iallreduce_sched = &MPIR_Iallreduce_SMP;
- ops->Ireduce_sched = &MPIR_Ireduce_SMP;
- break;
- case MPID_HIERARCHY_NODE:
- break;
- case MPID_HIERARCHY_NODE_ROOTS:
- break;
-
- /* --BEGIN ERROR HANDLING-- */
- default:
- MPIU_Assertp(FALSE);
- break;
- /* --END ERROR HANDLING-- */
+ case MPID_HIERARCHY_FLAT:
+ break;
+ case MPID_HIERARCHY_PARENT:
+ ops->Ibcast_sched = &MPIR_Ibcast_SMP;
+ ops->Iscan_sched = &MPIR_Iscan_SMP;
+ ops->Iallreduce_sched = &MPIR_Iallreduce_SMP;
+ ops->Ireduce_sched = &MPIR_Ireduce_SMP;
+ break;
+ case MPID_HIERARCHY_NODE:
+ break;
+ case MPID_HIERARCHY_NODE_ROOTS:
+ break;
+
+ /* --BEGIN ERROR HANDLING-- */
+ default:
+ MPIU_Assertp(FALSE);
+ break;
+ /* --END ERROR HANDLING-- */
}
/* this is a default table, it's not overriding another table */
@@ -352,8 +379,9 @@ static int init_default_collops(void)
/* now the intercomm table */
{
- MPIU_CHKPMEM_CALLOC(ops, struct MPID_Collops *, sizeof(struct MPID_Collops), mpi_errno, "default intercomm collops");
- ops->ref_count = 1; /* force existence until finalize time */
+ MPIU_CHKPMEM_CALLOC(ops, struct MPID_Collops *, sizeof(struct MPID_Collops), mpi_errno,
+ "default intercomm collops");
+ ops->ref_count = 1; /* force existence until finalize time */
/* intercomm defaults */
ops->Ibcast_sched = &MPIR_Ibcast_inter;
@@ -386,10 +414,10 @@ static int init_default_collops(void)
MPIR_Add_finalize(cleanup_default_collops, NULL, MPIR_FINALIZE_CALLBACK_PRIO - 1);
MPIU_CHKPMEM_COMMIT();
-fn_exit:
+ fn_exit:
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
-fn_fail:
+ fn_fail:
MPIU_CHKPMEM_REAP();
goto fn_exit;
/* --END ERROR HANDLING-- */
@@ -406,7 +434,7 @@ fn_fail:
#define FUNCNAME set_collops
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int set_collops(MPID_Comm *comm)
+static int set_collops(MPID_Comm * comm)
{
int mpi_errno = MPI_SUCCESS;
static int initialized = FALSE;
@@ -416,7 +444,8 @@ static int set_collops(MPID_Comm *comm)
if (unlikely(!initialized)) {
mpi_errno = init_default_collops();
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
initialized = TRUE;
}
@@ -425,15 +454,15 @@ static int set_collops(MPID_Comm *comm)
/* FIXME MT what protects access to this structure and ic_default_collops? */
comm->coll_fns = default_collops[comm->hierarchy_kind];
}
- else { /* intercomm */
+ else { /* intercomm */
comm->coll_fns = ic_default_collops;
}
comm->coll_fns->ref_count++;
-fn_exit:
+ fn_exit:
return mpi_errno;
-fn_fail:
+ fn_fail:
goto fn_exit;
}
@@ -441,10 +470,9 @@ fn_fail:
#define FUNCNAME MPIR_Comm_map_irregular
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Comm_map_irregular(MPID_Comm *newcomm, MPID_Comm *src_comm,
- int *src_mapping, int src_mapping_size,
- MPIR_Comm_map_dir_t dir,
- MPIR_Comm_map_t **map)
+int MPIR_Comm_map_irregular(MPID_Comm * newcomm, MPID_Comm * src_comm,
+ int *src_mapping, int src_mapping_size,
+ MPIR_Comm_map_dir_t dir, MPIR_Comm_map_t ** map)
{
int mpi_errno = MPI_SUCCESS;
MPIR_Comm_map_t *mapper;
@@ -453,9 +481,7 @@ int MPIR_Comm_map_irregular(MPID_Comm *newcomm, MPID_Comm *src_comm,
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_COMM_MAP_IRREGULAR);
- MPIU_CHKPMEM_MALLOC(mapper, MPIR_Comm_map_t *,
- sizeof(MPIR_Comm_map_t), mpi_errno,
- "mapper");
+ MPIU_CHKPMEM_MALLOC(mapper, MPIR_Comm_map_t *, sizeof(MPIR_Comm_map_t), mpi_errno, "mapper");
mapper->type = MPIR_COMM_MAP_IRREGULAR;
mapper->src_comm = src_comm;
@@ -468,8 +494,7 @@ int MPIR_Comm_map_irregular(MPID_Comm *newcomm, MPID_Comm *src_comm,
}
else {
MPIU_CHKPMEM_MALLOC(mapper->src_mapping, int *,
- src_mapping_size * sizeof(int), mpi_errno,
- "mapper mapping");
+ src_mapping_size * sizeof(int), mpi_errno, "mapper mapping");
mapper->free_mapping = 1;
}
@@ -480,11 +505,11 @@ int MPIR_Comm_map_irregular(MPID_Comm *newcomm, MPID_Comm *src_comm,
if (map)
*map = mapper;
-fn_exit:
+ fn_exit:
MPIU_CHKPMEM_COMMIT();
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_MAP_IRREGULAR);
return mpi_errno;
-fn_fail:
+ fn_fail:
MPIU_CHKPMEM_REAP();
goto fn_exit;
}
@@ -493,8 +518,7 @@ fn_fail:
#define FUNCNAME MPIR_Comm_map_dup
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Comm_map_dup(MPID_Comm *newcomm, MPID_Comm *src_comm,
- MPIR_Comm_map_dir_t dir)
+int MPIR_Comm_map_dup(MPID_Comm * newcomm, MPID_Comm * src_comm, MPIR_Comm_map_dir_t dir)
{
int mpi_errno = MPI_SUCCESS;
MPIR_Comm_map_t *mapper;
@@ -503,9 +527,7 @@ int MPIR_Comm_map_dup(MPID_Comm *newcomm, MPID_Comm *src_comm,
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_COMM_MAP_DUP);
- MPIU_CHKPMEM_MALLOC(mapper, MPIR_Comm_map_t *,
- sizeof(MPIR_Comm_map_t), mpi_errno,
- "mapper");
+ MPIU_CHKPMEM_MALLOC(mapper, MPIR_Comm_map_t *, sizeof(MPIR_Comm_map_t), mpi_errno, "mapper");
mapper->type = MPIR_COMM_MAP_DUP;
mapper->src_comm = src_comm;
@@ -515,11 +537,11 @@ int MPIR_Comm_map_dup(MPID_Comm *newcomm, MPID_Comm *src_comm,
MPL_LL_APPEND(newcomm->mapper_head, newcomm->mapper_tail, mapper);
-fn_exit:
+ fn_exit:
MPIU_CHKPMEM_COMMIT();
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_MAP_DUP);
return mpi_errno;
-fn_fail:
+ fn_fail:
MPIU_CHKPMEM_REAP();
goto fn_exit;
}
@@ -529,7 +551,7 @@ fn_fail:
#define FUNCNAME MPIR_Comm_map_free
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Comm_map_free(MPID_Comm *comm)
+int MPIR_Comm_map_free(MPID_Comm * comm)
{
int mpi_errno = MPI_SUCCESS;
MPIR_Comm_map_t *mapper, *tmp;
@@ -539,31 +561,30 @@ int MPIR_Comm_map_free(MPID_Comm *comm)
for (mapper = comm->mapper_head; mapper;) {
tmp = mapper->next;
- if (mapper->type == MPIR_COMM_MAP_IRREGULAR &&
- mapper->free_mapping)
+ if (mapper->type == MPIR_COMM_MAP_IRREGULAR && mapper->free_mapping)
MPIU_Free(mapper->src_mapping);
MPIU_Free(mapper);
mapper = tmp;
}
comm->mapper_head = NULL;
-fn_exit:
+ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_MAP_FREE);
return mpi_errno;
-fn_fail:
+ fn_fail:
goto fn_exit;
}
/* Provides a hook for the top level functions to perform some manipulation on a
communicator just before it is given to the application level.
-
+
For example, we create sub-communicators for SMP-aware collectives at this
step. */
#undef FUNCNAME
#define FUNCNAME MPIR_Comm_commit
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Comm_commit(MPID_Comm *comm)
+int MPIR_Comm_commit(MPID_Comm * comm)
{
int mpi_errno = MPI_SUCCESS;
int num_local = -1, num_external = -1;
@@ -574,33 +595,37 @@ int MPIR_Comm_commit(MPID_Comm *comm)
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_COMM_COMMIT);
/* It's OK to relax these assertions, but we should do so very
- intentionally. For now this function is the only place that we create
- our hierarchy of communicators */
+ * intentionally. For now this function is the only place that we create
+ * our hierarchy of communicators */
MPIU_Assert(comm->node_comm == NULL);
MPIU_Assert(comm->node_roots_comm == NULL);
mpi_errno = set_collops(comm);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* Notify device of communicator creation */
mpi_errno = MPID_Dev_comm_create_hook(comm);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPIR_Comm_map_free(comm);
if (comm->comm_kind == MPID_INTRACOMM) {
mpi_errno = MPIU_Find_local_and_external(comm,
- &num_local, &local_rank, &local_procs,
+ &num_local, &local_rank, &local_procs,
&num_external, &external_rank, &external_procs,
&comm->intranode_table, &comm->internode_table);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno) {
- if (MPIR_Err_is_fatal(mpi_errno)) MPIU_ERR_POP(mpi_errno);
+ if (MPIR_Err_is_fatal(mpi_errno))
+ MPIU_ERR_POP(mpi_errno);
/* Non-fatal errors simply mean that this communicator will not have
- any node awareness. Node-aware collectives are an optimization. */
- MPIU_DBG_MSG_P(COMM,VERBOSE,"MPIU_Find_local_and_external failed for comm_ptr=%p", comm);
+ * any node awareness. Node-aware collectives are an optimization. */
+ MPIU_DBG_MSG_P(COMM, VERBOSE, "MPIU_Find_local_and_external failed for comm_ptr=%p",
+ comm);
if (comm->intranode_table)
MPIU_Free(comm->intranode_table);
if (comm->internode_table)
@@ -617,7 +642,7 @@ int MPIR_Comm_commit(MPID_Comm *comm)
MPIU_Assert(external_rank < 0 || external_procs != NULL);
/* if the node_roots_comm and comm would be the same size, then creating
- the second communicator is useless and wasteful. */
+ * the second communicator is useless and wasteful. */
if (num_external == comm->remote_size) {
MPIU_Assert(num_local == 1);
goto fn_exit;
@@ -626,7 +651,8 @@ int MPIR_Comm_commit(MPID_Comm *comm)
/* we don't need a local comm if this process is the only one on this node */
if (num_local > 1) {
mpi_errno = MPIR_Comm_create(&comm->node_comm);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
comm->node_comm->context_id = comm->context_id + MPID_CONTEXT_INTRANODE_OFFSET;
comm->node_comm->recvcontext_id = comm->node_comm->context_id;
@@ -634,21 +660,22 @@ int MPIR_Comm_commit(MPID_Comm *comm)
comm->node_comm->comm_kind = MPID_INTRACOMM;
comm->node_comm->hierarchy_kind = MPID_HIERARCHY_NODE;
comm->node_comm->local_comm = NULL;
- MPIU_DBG_MSG_D(CH3_OTHER,VERBOSE,"Create node_comm=%p\n", comm->node_comm);
+ MPIU_DBG_MSG_D(CH3_OTHER, VERBOSE, "Create node_comm=%p\n", comm->node_comm);
- comm->node_comm->local_size = num_local;
+ comm->node_comm->local_size = num_local;
comm->node_comm->remote_size = num_local;
MPIR_Comm_map_irregular(comm->node_comm, comm, local_procs,
- num_local, MPIR_COMM_MAP_DIR_L2L,
- NULL);
+ num_local, MPIR_COMM_MAP_DIR_L2L, NULL);
mpi_errno = set_collops(comm->node_comm);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* Notify device of communicator creation */
- mpi_errno = MPID_Dev_comm_create_hook( comm->node_comm );
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno = MPID_Dev_comm_create_hook(comm->node_comm);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* don't call MPIR_Comm_commit here */
MPIR_Comm_map_free(comm->node_comm);
@@ -658,7 +685,8 @@ int MPIR_Comm_commit(MPID_Comm *comm)
/* this process may not be a member of the node_roots_comm */
if (local_rank == 0) {
mpi_errno = MPIR_Comm_create(&comm->node_roots_comm);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
comm->node_roots_comm->context_id = comm->context_id + MPID_CONTEXT_INTERNODE_OFFSET;
comm->node_roots_comm->recvcontext_id = comm->node_roots_comm->context_id;
@@ -667,19 +695,20 @@ int MPIR_Comm_commit(MPID_Comm *comm)
comm->node_roots_comm->hierarchy_kind = MPID_HIERARCHY_NODE_ROOTS;
comm->node_roots_comm->local_comm = NULL;
- comm->node_roots_comm->local_size = num_external;
+ comm->node_roots_comm->local_size = num_external;
comm->node_roots_comm->remote_size = num_external;
MPIR_Comm_map_irregular(comm->node_roots_comm, comm,
- external_procs, num_external,
- MPIR_COMM_MAP_DIR_L2L, NULL);
+ external_procs, num_external, MPIR_COMM_MAP_DIR_L2L, NULL);
mpi_errno = set_collops(comm->node_roots_comm);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* Notify device of communicator creation */
- mpi_errno = MPID_Dev_comm_create_hook( comm->node_roots_comm );
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno = MPID_Dev_comm_create_hook(comm->node_roots_comm);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* don't call MPIR_Comm_commit here */
MPIR_Comm_map_free(comm->node_roots_comm);
@@ -688,7 +717,7 @@ int MPIR_Comm_commit(MPID_Comm *comm)
comm->hierarchy_kind = MPID_HIERARCHY_PARENT;
}
-fn_exit:
+ fn_exit:
if (external_procs != NULL)
MPIU_Free(external_procs);
if (local_procs != NULL)
@@ -696,7 +725,7 @@ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_COMMIT);
return mpi_errno;
-fn_fail:
+ fn_fail:
goto fn_exit;
}
@@ -719,8 +748,7 @@ int MPIR_Comm_is_node_consecutive(MPID_Comm * comm)
if (!MPIR_Comm_is_node_aware(comm))
return 0;
- for (; i < comm->local_size; i++)
- {
+ for (; i < comm->local_size; i++) {
if (internode_table[i] == curr_nodeidx + 1)
curr_nodeidx++;
else if (internode_table[i] != curr_nodeidx)
@@ -731,7 +759,7 @@ int MPIR_Comm_is_node_consecutive(MPID_Comm * comm)
}
/*
- * Here are the routines to find a new context id. The algorithm is discussed
+ * Here are the routines to find a new context id. The algorithm is discussed
* in detail in the mpich coding document. There are versions for
* single threaded and multithreaded MPI.
*
@@ -742,7 +770,7 @@ static uint32_t context_mask[MPIR_MAX_CONTEXT_MASK];
static int initialize_context_mask = 1;
/* Create a string that contains the context mask. This is
- used only with the logging interface, and must be used by one thread at
+ used only with the logging interface, and must be used by one thread at
a time (should this be enforced by the logging interface?).
Converts the mask to hex and returns a pointer to that string.
@@ -755,19 +783,20 @@ static int initialize_context_mask = 1;
(possibly "extern") copy of the prototype in their own code in order to call
this routine.
*/
-char *MPIR_ContextMaskToStr( void );
-char *MPIR_ContextMaskToStr( void )
+char *MPIR_ContextMaskToStr(void);
+char *MPIR_ContextMaskToStr(void)
{
- static char bufstr[MPIR_MAX_CONTEXT_MASK*8+1];
+ static char bufstr[MPIR_MAX_CONTEXT_MASK * 8 + 1];
int i;
- int maxset=0;
+ int maxset = 0;
- for (maxset=MPIR_MAX_CONTEXT_MASK-1; maxset>=0; maxset--) {
- if (context_mask[maxset] != 0) break;
+ for (maxset = MPIR_MAX_CONTEXT_MASK - 1; maxset >= 0; maxset--) {
+ if (context_mask[maxset] != 0)
+ break;
}
- for (i=0; i<maxset; i++) {
- MPIU_Snprintf( &bufstr[i*8], 9, "%.8x", context_mask[i] );
+ for (i = 0; i < maxset; i++) {
+ MPIU_Snprintf(&bufstr[i * 8], 9, "%.8x", context_mask[i]);
}
return bufstr;
}
@@ -797,13 +826,13 @@ void MPIR_ContextMaskStats(int *free_ids, int *total_ids)
* time (or just track the count when manipulating the mask and keep
* that count stored in a variable) */
for (i = 0; i < MPIR_MAX_CONTEXT_MASK; ++i) {
- for (j = 0; j < sizeof(context_mask[0])*8; ++j) {
+ for (j = 0; j < sizeof(context_mask[0]) * 8; ++j) {
*free_ids += (context_mask[i] & (0x1 << j)) >> j;
}
}
}
if (total_ids) {
- *total_ids = MPIR_MAX_CONTEXT_MASK*sizeof(context_mask[0])*8;
+ *total_ids = MPIR_MAX_CONTEXT_MASK * sizeof(context_mask[0]) * 8;
}
}
@@ -817,7 +846,7 @@ static int MPIU_CheckContextIDsOnFinalize(void *context_mask_ptr)
for (i = 0; i < MPIR_MAX_CONTEXT_MASK; ++i) {
if (~mask[i]) {
/* some bits were still cleared */
- printf("leaked context IDs detected: mask=%p mask[%d]=%#x\n", mask, i, (int)mask[i]);
+ printf("leaked context IDs detected: mask=%p mask[%d]=%#x\n", mask, i, (int) mask[i]);
}
}
return MPI_SUCCESS;
@@ -828,12 +857,12 @@ static void MPIR_Init_contextid(void)
{
int i;
- for (i=1; i<MPIR_MAX_CONTEXT_MASK; i++) {
- context_mask[i] = 0xFFFFFFFF;
+ for (i = 1; i < MPIR_MAX_CONTEXT_MASK; i++) {
+ context_mask[i] = 0xFFFFFFFF;
}
/* The first two values are already used (comm_world, comm_self).
- The third value is also used for the internal-only copy of
- comm_world, if needed by mpid. */
+ * The third value is also used for the internal-only copy of
+ * comm_world, if needed by mpid. */
#ifdef MPID_NEEDS_ICOMM_WORLD
context_mask[0] = 0xFFFFFFF8;
#else
@@ -854,44 +883,44 @@ static void MPIR_Init_contextid(void)
static int MPIR_Locate_context_bit(uint32_t local_mask[])
{
int i, j, context_id = 0;
- for (i=0; i<MPIR_MAX_CONTEXT_MASK; i++) {
- if (local_mask[i]) {
- /* There is a bit set in this word. */
- register uint32_t val, nval;
- /* The following code finds the highest set bit by recursively
- checking the top half of a subword for a bit, and incrementing
- the bit location by the number of bit of the lower sub word if
- the high subword contains a set bit. The assumption is that
- full-word bitwise operations and compares against zero are
- fast */
- val = local_mask[i];
- j = 0;
- nval = val & 0xFFFF0000;
- if (nval) {
- j += 16;
- val = nval;
- }
- nval = val & 0xFF00FF00;
- if (nval) {
- j += 8;
- val = nval;
- }
- nval = val & 0xF0F0F0F0;
- if (nval) {
- j += 4;
- val = nval;
- }
- nval = val & 0xCCCCCCCC;
- if (nval) {
- j += 2;
- val = nval;
- }
- if (val & 0xAAAAAAAA) {
- j += 1;
- }
- context_id = (MPIR_CONTEXT_INT_BITS * i + j) << MPID_CONTEXT_PREFIX_SHIFT;
- return context_id;
- }
+ for (i = 0; i < MPIR_MAX_CONTEXT_MASK; i++) {
+ if (local_mask[i]) {
+ /* There is a bit set in this word. */
+ register uint32_t val, nval;
+ /* The following code finds the highest set bit by recursively
+ * checking the top half of a subword for a bit, and incrementing
+ * the bit location by the number of bit of the lower sub word if
+ * the high subword contains a set bit. The assumption is that
+ * full-word bitwise operations and compares against zero are
+ * fast */
+ val = local_mask[i];
+ j = 0;
+ nval = val & 0xFFFF0000;
+ if (nval) {
+ j += 16;
+ val = nval;
+ }
+ nval = val & 0xFF00FF00;
+ if (nval) {
+ j += 8;
+ val = nval;
+ }
+ nval = val & 0xF0F0F0F0;
+ if (nval) {
+ j += 4;
+ val = nval;
+ }
+ nval = val & 0xCCCCCCCC;
+ if (nval) {
+ j += 2;
+ val = nval;
+ }
+ if (val & 0xAAAAAAAA) {
+ j += 1;
+ }
+ context_id = (MPIR_CONTEXT_INT_BITS * i + j) << MPID_CONTEXT_PREFIX_SHIFT;
+ return context_id;
+ }
}
return 0;
}
@@ -902,19 +931,19 @@ static int MPIR_Locate_context_bit(uint32_t local_mask[])
static int MPIR_Allocate_context_bit(uint32_t mask[], MPIR_Context_id_t id)
{
int raw_prefix, idx, bitpos;
- raw_prefix = MPID_CONTEXT_READ_FIELD(PREFIX,id);
- idx = raw_prefix / MPIR_CONTEXT_INT_BITS;
+ raw_prefix = MPID_CONTEXT_READ_FIELD(PREFIX, id);
+ idx = raw_prefix / MPIR_CONTEXT_INT_BITS;
bitpos = raw_prefix % MPIR_CONTEXT_INT_BITS;
/* the bit should not already be cleared (allocated) */
- MPIU_Assert(mask[idx] & (1<<bitpos));
+ MPIU_Assert(mask[idx] & (1 << bitpos));
/* clear the bit */
- mask[idx] &= ~(1<<bitpos);
+ mask[idx] &= ~(1 << bitpos);
- MPIU_DBG_MSG_FMT(COMM,VERBOSE,(MPIU_DBG_FDEST,
- "allocating contextid = %d, (mask=%p, mask[%d], bit %d)",
- id, mask, idx, bitpos));
+ MPIU_DBG_MSG_FMT(COMM, VERBOSE, (MPIU_DBG_FDEST,
+ "allocating contextid = %d, (mask=%p, mask[%d], bit %d)",
+ id, mask, idx, bitpos));
return id;
}
@@ -939,13 +968,14 @@ static int MPIR_Find_and_allocate_context_id(uint32_t local_mask[])
#define FUNCNAME MPIR_Get_contextid
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid(MPID_Comm *comm_ptr, MPIR_Context_id_t *context_id)
+int MPIR_Get_contextid(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id)
{
int mpi_errno = MPI_SUCCESS;
mpi_errno = MPIR_Get_contextid_sparse(comm_ptr, context_id, FALSE);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPIU_Assert(*context_id != MPIR_INVALID_CONTEXT_ID);
-fn_fail:
+ fn_fail:
return mpi_errno;
}
@@ -957,12 +987,12 @@ fn_fail:
* They are used to avoid deadlock in multi-threaded case. In single-threaded
* case, they are not used.
*/
-static volatile int eager_nelem = -1;
-static volatile int eager_in_use = 0;
+static volatile int eager_nelem = -1;
+static volatile int eager_in_use = 0;
/* In multi-threaded case, mask_in_use is used to maintain thread safety. In
* single-threaded case, it is always 0. */
-static volatile int mask_in_use = 0;
+static volatile int mask_in_use = 0;
/* In multi-threaded case, lowestContextId is used to prioritize access when
* multiple threads are contending for the mask, lowestTag is used to break
@@ -973,16 +1003,16 @@ static volatile int mask_in_use = 0;
*/
#define MPIR_MAXID (1 << 30)
static volatile int lowestContextId = MPIR_MAXID;
-static volatile int lowestTag = -1;
+static volatile int lowestTag = -1;
#undef FUNCNAME
#define FUNCNAME MPIR_Get_contextid_sparse
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid_sparse(MPID_Comm *comm_ptr, MPIR_Context_id_t *context_id, int ignore_id)
+int MPIR_Get_contextid_sparse(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id, int ignore_id)
{
- return MPIR_Get_contextid_sparse_group(comm_ptr, NULL /*group_ptr*/,
- MPIR_Process.attrs.tag_ub /*tag*/,
+ return MPIR_Get_contextid_sparse_group(comm_ptr, NULL /*group_ptr */ ,
+ MPIR_Process.attrs.tag_ub /*tag */ ,
context_id, ignore_id);
}
@@ -1005,11 +1035,12 @@ int MPIR_Get_contextid_sparse(MPID_Comm *comm_ptr, MPIR_Context_id_t *context_id
#define FUNCNAME MPIR_Get_contextid_sparse_group
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr, int tag, MPIR_Context_id_t *context_id, int ignore_id)
+int MPIR_Get_contextid_sparse_group(MPID_Comm * comm_ptr, MPID_Group * group_ptr, int tag,
+ MPIR_Context_id_t * context_id, int ignore_id)
{
int mpi_errno = MPI_SUCCESS;
const int ALL_OWN_MASK_FLAG = MPIR_MAX_CONTEXT_MASK;
- uint32_t local_mask[MPIR_MAX_CONTEXT_MASK+1];
+ uint32_t local_mask[MPIR_MAX_CONTEXT_MASK + 1];
int own_mask = 0;
int own_eager_mask = 0;
mpir_errflag_t errflag = MPIR_ERR_NONE;
@@ -1020,13 +1051,14 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_GET_CONTEXTID);
/* Group-collective and ignore_id should never be combined */
- MPIU_Assert(! (group_ptr != NULL && ignore_id) );
+ MPIU_Assert(!(group_ptr != NULL && ignore_id));
*context_id = 0;
MPIU_DBG_MSG_FMT(COMM, VERBOSE, (MPIU_DBG_FDEST,
- "Entering; shared state is %d:%d:%d, my ctx id is %d, tag=%d",
- mask_in_use, lowestContextId, lowestTag, comm_ptr->context_id, tag));
+ "Entering; shared state is %d:%d:%d, my ctx id is %d, tag=%d",
+ mask_in_use, lowestContextId, lowestTag, comm_ptr->context_id,
+ tag));
while (*context_id == 0) {
/* We lock only around access to the mask (except in the global locking
@@ -1039,8 +1071,9 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
if (eager_nelem < 0) {
/* Ensure that at least one word of deadlock-free context IDs is
- always set aside for the base protocol */
- MPIU_Assert( MPIR_CVAR_CTXID_EAGER_SIZE >= 0 && MPIR_CVAR_CTXID_EAGER_SIZE < MPIR_MAX_CONTEXT_MASK-1 );
+ * always set aside for the base protocol */
+ MPIU_Assert(MPIR_CVAR_CTXID_EAGER_SIZE >= 0 &&
+ MPIR_CVAR_CTXID_EAGER_SIZE < MPIR_MAX_CONTEXT_MASK - 1);
eager_nelem = MPIR_CVAR_CTXID_EAGER_SIZE;
}
@@ -1060,8 +1093,8 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
else if (first_iter) {
memset(local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
own_eager_mask = 0;
- if(comm_ptr->idup_count)
- seqnum = comm_ptr->idup_curr_seqnum++;
+ if (comm_ptr->idup_count)
+ seqnum = comm_ptr->idup_curr_seqnum++;
/* Attempt to reserve the eager mask segment */
@@ -1070,25 +1103,26 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
for (i = 0; i < eager_nelem; i++)
local_mask[i] = context_mask[i];
- eager_in_use = 1;
+ eager_in_use = 1;
own_eager_mask = 1;
}
}
else {
/* lowestTag breaks ties when contextIds are the same (happens only
- in calls to MPI_Comm_create_group. */
+ * in calls to MPI_Comm_create_group. */
if (comm_ptr->context_id < lowestContextId ||
- (comm_ptr->context_id == lowestContextId && tag < lowestTag)) {
+ (comm_ptr->context_id == lowestContextId && tag < lowestTag)) {
lowestContextId = comm_ptr->context_id;
- lowestTag = tag;
+ lowestTag = tag;
}
- if (mask_in_use || ! (comm_ptr->context_id == lowestContextId && tag == lowestTag) ||
- (comm_ptr->idup_count && seqnum != comm_ptr->idup_next_seqnum)) {
+ if (mask_in_use || !(comm_ptr->context_id == lowestContextId && tag == lowestTag) ||
+ (comm_ptr->idup_count && seqnum != comm_ptr->idup_next_seqnum)) {
memset(local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
own_mask = 0;
- MPIU_DBG_MSG_D(COMM, VERBOSE, "In in-use, set lowestContextId to %d", lowestContextId);
+ MPIU_DBG_MSG_D(COMM, VERBOSE, "In in-use, set lowestContextId to %d",
+ lowestContextId);
}
else {
int i;
@@ -1099,8 +1133,8 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
for (i = eager_nelem; i < MPIR_MAX_CONTEXT_MASK; i++)
local_mask[i] = context_mask[i];
- mask_in_use = 1;
- own_mask = 1;
+ mask_in_use = 1;
+ own_mask = 1;
MPIU_DBG_MSG(COMM, VERBOSE, "Copied local_mask");
}
}
@@ -1118,18 +1152,21 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
/* Now, try to get a context id */
MPIU_Assert(comm_ptr->comm_kind == MPID_INTRACOMM);
/* In the global and brief-global cases, note that this routine will
- release that global lock when it needs to wait. That will allow
- other processes to enter the global or brief global critical section.
+ * release that global lock when it needs to wait. That will allow
+ * other processes to enter the global or brief global critical section.
*/
if (group_ptr != NULL) {
int coll_tag = tag | MPIR_Process.tagged_coll_mask; /* Shift tag into the tagged coll space */
- mpi_errno = MPIR_Allreduce_group(MPI_IN_PLACE, local_mask, MPIR_MAX_CONTEXT_MASK+1,
- MPI_INT, MPI_BAND, comm_ptr, group_ptr, coll_tag, &errflag);
- } else {
- mpi_errno = MPIR_Allreduce_impl(MPI_IN_PLACE, local_mask, MPIR_MAX_CONTEXT_MASK+1,
+ mpi_errno = MPIR_Allreduce_group(MPI_IN_PLACE, local_mask, MPIR_MAX_CONTEXT_MASK + 1,
+ MPI_INT, MPI_BAND, comm_ptr, group_ptr, coll_tag,
+ &errflag);
+ }
+ else {
+ mpi_errno = MPIR_Allreduce_impl(MPI_IN_PLACE, local_mask, MPIR_MAX_CONTEXT_MASK + 1,
MPI_INT, MPI_BAND, comm_ptr, &errflag);
}
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
/* MT FIXME 2/3 cases don't seem to need the CONTEXTID CS, check and
@@ -1148,7 +1185,7 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
MPIU_DBG_MSG_D(COMM, VERBOSE, "Context id is now %hd", *context_id);
own_eager_mask = 0;
- eager_in_use = 0;
+ eager_in_use = 0;
if (*context_id <= 0) {
/* else we did not find a context id. Give up the mask in case
@@ -1168,10 +1205,10 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
if (*context_id > 0) {
/* If we were the lowest context id, reset the value to
- allow the other threads to compete for the mask */
+ * allow the other threads to compete for the mask */
if (lowestContextId == comm_ptr->context_id && lowestTag == tag) {
lowestContextId = MPIR_MAXID;
- lowestTag = -1;
+ lowestTag = -1;
/* Else leave it alone; there is another thread waiting */
}
comm_ptr->idup_curr_seqnum++;
@@ -1206,7 +1243,7 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
mask_in_use = 0;
if (lowestContextId == comm_ptr->context_id && lowestTag == tag) {
lowestContextId = MPIR_MAXID;
- lowestTag = -1;
+ lowestTag = -1;
}
MPIU_THREAD_CS_EXIT(CONTEXTID,);
}
@@ -1218,19 +1255,21 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
minfree = nfree;
if (group_ptr != NULL) {
- int coll_tag = tag | MPIR_Process.tagged_coll_mask; /* Shift tag into the tagged coll space */
+ int coll_tag = tag | MPIR_Process.tagged_coll_mask; /* Shift tag into the tagged coll space */
mpi_errno = MPIR_Allreduce_group(MPI_IN_PLACE, &minfree, 1, MPI_INT, MPI_MIN,
comm_ptr, group_ptr, coll_tag, &errflag);
- } else {
+ }
+ else {
mpi_errno = MPIR_Allreduce_impl(MPI_IN_PLACE, &minfree, 1, MPI_INT,
- MPI_MIN, comm_ptr, &errflag);
+ MPI_MIN, comm_ptr, &errflag);
}
if (minfree > 0) {
MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
"**toomanycommfrag", "**toomanycommfrag %d %d %d",
nfree, ntotal, ignore_id);
- } else {
+ }
+ else {
MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
"**toomanycomm", "**toomanycomm %d %d %d",
nfree, ntotal, ignore_id);
@@ -1244,15 +1283,15 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
comm_ptr->idup_next_seqnum++;
-fn_exit:
+ fn_exit:
if (ignore_id)
*context_id = MPIR_INVALID_CONTEXT_ID;
- MPIU_DBG_MSG_S(COMM,VERBOSE,"Context mask = %s",MPIR_ContextMaskToStr());
+ MPIU_DBG_MSG_S(COMM, VERBOSE, "Context mask = %s", MPIR_ContextMaskToStr());
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_CONTEXTID);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
-fn_fail:
+ fn_fail:
/* Release the masks */
if (own_mask) {
/* is it safe to access this without holding the CS? */
@@ -1277,22 +1316,23 @@ struct gcn_state {
uint32_t local_mask[MPIR_MAX_CONTEXT_MASK];
};
-static int sched_cb_gcn_copy_mask(MPID_Comm *comm, int tag, void *state);
-static int sched_cb_gcn_allocate_cid(MPID_Comm *comm, int tag, void *state);
-static int sched_cb_gcn_bcast(MPID_Comm *comm, int tag, void *state);
+static int sched_cb_gcn_copy_mask(MPID_Comm * comm, int tag, void *state);
+static int sched_cb_gcn_allocate_cid(MPID_Comm * comm, int tag, void *state);
+static int sched_cb_gcn_bcast(MPID_Comm * comm, int tag, void *state);
#undef FUNCNAME
#define FUNCNAME sched_cb_commit_comm
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int sched_cb_commit_comm(MPID_Comm *comm, int tag, void *state)
+static int sched_cb_commit_comm(MPID_Comm * comm, int tag, void *state)
{
int mpi_errno = MPI_SUCCESS;
struct gcn_state *st = state;
mpi_errno = MPIR_Comm_commit(st->new_comm);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
-fn_fail:
+ fn_fail:
return mpi_errno;
}
@@ -1301,32 +1341,42 @@ fn_fail:
#define FUNCNAME sched_cb_gcn_bcast
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int sched_cb_gcn_bcast(MPID_Comm *comm, int tag, void *state)
+static int sched_cb_gcn_bcast(MPID_Comm * comm, int tag, void *state)
{
int mpi_errno = MPI_SUCCESS;
struct gcn_state *st = state;
if (st->gcn_cid_kind == MPID_INTERCOMM) {
if (st->comm_ptr_inter->rank == 0) {
- mpi_errno = MPID_Sched_recv(st->ctx1, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, st->comm_ptr_inter, st->s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
- mpi_errno = MPID_Sched_send(st->ctx0, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, st->comm_ptr_inter, st->s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno =
+ MPID_Sched_recv(st->ctx1, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, st->comm_ptr_inter,
+ st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
+ mpi_errno =
+ MPID_Sched_send(st->ctx0, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, st->comm_ptr_inter,
+ st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPID_SCHED_BARRIER(st->s);
}
mpi_errno = st->comm_ptr->coll_fns->Ibcast_sched(st->ctx1, 1,
- MPIR_CONTEXT_ID_T_DATATYPE, 0, st->comm_ptr, st->s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ MPIR_CONTEXT_ID_T_DATATYPE, 0,
+ st->comm_ptr, st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPID_SCHED_BARRIER(st->s);
}
mpi_errno = MPID_Sched_cb(&sched_cb_commit_comm, st, st->s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
mpi_errno = MPID_Sched_cb(&MPIR_Sched_cb_free_buf, st, st->s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
-fn_fail:
+ fn_fail:
return mpi_errno;
}
@@ -1347,7 +1397,7 @@ fn_fail:
#define FUNCNAME sched_cb_gcn_allocate_cid
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int sched_cb_gcn_allocate_cid(MPID_Comm *comm, int tag, void *state)
+static int sched_cb_gcn_allocate_cid(MPID_Comm * comm, int tag, void *state)
{
int mpi_errno = MPI_SUCCESS;
struct gcn_state *st = state;
@@ -1362,7 +1412,8 @@ static int sched_cb_gcn_allocate_cid(MPID_Comm *comm, int tag, void *state)
st->own_eager_mask = 0;
eager_in_use = 0;
- } else if (st->own_mask) {
+ }
+ else if (st->own_mask) {
newctxid = MPIR_Find_and_allocate_context_id(st->local_mask);
if (st->ctx0)
@@ -1382,22 +1433,25 @@ static int sched_cb_gcn_allocate_cid(MPID_Comm *comm, int tag, void *state)
if (*st->ctx0 == 0) {
/* do not own mask, try again */
mpi_errno = MPID_Sched_cb(&sched_cb_gcn_copy_mask, st, st->s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPID_SCHED_BARRIER(st->s);
- } else {
+ }
+ else {
/* Successfully allocated a context id */
st->comm_ptr->idup_next_seqnum++;
st->comm_ptr->idup_count--;
mpi_errno = MPID_Sched_cb(&sched_cb_gcn_bcast, st, st->s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPID_SCHED_BARRIER(st->s);
}
/* --BEGIN ERROR HANDLING-- */
/* --END ERROR HANDLING-- */
-fn_fail:
+ fn_fail:
return mpi_errno;
}
@@ -1405,7 +1459,7 @@ fn_fail:
#define FUNCNAME sched_cb_gcn_copy_mask
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int sched_cb_gcn_copy_mask(MPID_Comm *comm, int tag, void *state)
+static int sched_cb_gcn_copy_mask(MPID_Comm * comm, int tag, void *state)
{
int mpi_errno = MPI_SUCCESS;
struct gcn_state *st = state;
@@ -1420,12 +1474,13 @@ static int sched_cb_gcn_copy_mask(MPID_Comm *comm, int tag, void *state)
for (i = 0; i < eager_nelem; i++)
st->local_mask[i] = context_mask[i];
- eager_in_use = 1;
+ eager_in_use = 1;
st->own_eager_mask = 1;
}
st->first_iter = 0;
- } else {
+ }
+ else {
if (st->comm_ptr->context_id < lowestContextId) {
lowestContextId = st->comm_ptr->context_id;
}
@@ -1438,11 +1493,11 @@ static int sched_cb_gcn_copy_mask(MPID_Comm *comm, int tag, void *state)
* same communicator at the same time, the sequence number of the
* current MPI_COMM_IDUP operation is not the smallest. */
if (mask_in_use || (st->comm_ptr->context_id != lowestContextId)
- || (st->comm_ptr->idup_count > 1
- && st->seqnum != st->comm_ptr->idup_next_seqnum)) {
+ || (st->comm_ptr->idup_count > 1 && st->seqnum != st->comm_ptr->idup_next_seqnum)) {
memset(st->local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
st->own_mask = 0;
- } else {
+ }
+ else {
/* Copy safe mask segment to local_mask */
int i;
for (i = 0; i < eager_nelem; i++)
@@ -1456,16 +1511,20 @@ static int sched_cb_gcn_copy_mask(MPID_Comm *comm, int tag, void *state)
}
- mpi_errno = st->comm_ptr->coll_fns->Iallreduce_sched(MPI_IN_PLACE, st->local_mask, MPIR_MAX_CONTEXT_MASK,
- MPI_UINT32_T, MPI_BAND, st->comm_ptr, st->s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno =
+ st->comm_ptr->coll_fns->Iallreduce_sched(MPI_IN_PLACE, st->local_mask,
+ MPIR_MAX_CONTEXT_MASK, MPI_UINT32_T, MPI_BAND,
+ st->comm_ptr, st->s);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPID_SCHED_BARRIER(st->s);
mpi_errno = MPID_Sched_cb(&sched_cb_gcn_allocate_cid, st, st->s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPID_SCHED_BARRIER(st->s);
-fn_fail:
+ fn_fail:
return mpi_errno;
}
@@ -1510,8 +1569,9 @@ fn_fail:
#define FUNCNAME sched_get_cid_nonblock
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-static int sched_get_cid_nonblock(MPID_Comm *comm_ptr, MPID_Comm *newcomm, MPIR_Context_id_t *ctx0,
- MPIR_Context_id_t *ctx1, MPID_Sched_t s, MPID_Comm_kind_t gcn_cid_kind)
+static int sched_get_cid_nonblock(MPID_Comm * comm_ptr, MPID_Comm * newcomm,
+ MPIR_Context_id_t * ctx0, MPIR_Context_id_t * ctx1,
+ MPID_Sched_t s, MPID_Comm_kind_t gcn_cid_kind)
{
int mpi_errno = MPI_SUCCESS;
struct gcn_state *st = NULL;
@@ -1527,7 +1587,8 @@ static int sched_get_cid_nonblock(MPID_Comm *comm_ptr, MPID_Comm *newcomm, MPIR
if (gcn_cid_kind == MPID_INTRACOMM) {
st->comm_ptr = comm_ptr;
st->comm_ptr_inter = NULL;
- } else {
+ }
+ else {
st->comm_ptr = comm_ptr->local_comm;
st->comm_ptr_inter = comm_ptr;
}
@@ -1540,25 +1601,27 @@ static int sched_get_cid_nonblock(MPID_Comm *comm_ptr, MPID_Comm *newcomm, MPIR
/* idup_count > 1 means there are multiple communicators duplicating
* from the current communicator at the same time. And
* idup_curr_seqnum gives each duplication operation a priority */
- st->comm_ptr->idup_count++;
- st->seqnum = st->comm_ptr->idup_curr_seqnum++;
- st->own_mask = 0;
+ st->comm_ptr->idup_count++;
+ st->seqnum = st->comm_ptr->idup_curr_seqnum++;
+ st->own_mask = 0;
if (eager_nelem < 0) {
/* Ensure that at least one word of deadlock-free context IDs is
- always set aside for the base protocol */
- MPIU_Assert( MPIR_CVAR_CTXID_EAGER_SIZE >= 0 && MPIR_CVAR_CTXID_EAGER_SIZE < MPIR_MAX_CONTEXT_MASK-1 );
+ * always set aside for the base protocol */
+ MPIU_Assert(MPIR_CVAR_CTXID_EAGER_SIZE >= 0 &&
+ MPIR_CVAR_CTXID_EAGER_SIZE < MPIR_MAX_CONTEXT_MASK - 1);
eager_nelem = MPIR_CVAR_CTXID_EAGER_SIZE;
}
mpi_errno = MPID_Sched_cb(&sched_cb_gcn_copy_mask, st, s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPID_SCHED_BARRIER(s);
MPIU_CHKPMEM_COMMIT();
-fn_exit:
+ fn_exit:
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
-fn_fail:
+ fn_fail:
MPIU_CHKPMEM_REAP();
goto fn_exit;
/* --END ERROR HANDLING-- */
@@ -1568,7 +1631,7 @@ fn_fail:
#define FUNCNAME MPIR_Get_contextid_nonblock
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid_nonblock(MPID_Comm *comm_ptr, MPID_Comm *newcommp, MPID_Request **req)
+int MPIR_Get_contextid_nonblock(MPID_Comm * comm_ptr, MPID_Comm * newcommp, MPID_Request ** req)
{
int mpi_errno = MPI_SUCCESS;
int tag;
@@ -1580,23 +1643,29 @@ int MPIR_Get_contextid_nonblock(MPID_Comm *comm_ptr, MPID_Comm *newcommp, MPID_R
/* now create a schedule */
mpi_errno = MPID_Sched_next_tag(comm_ptr, &tag);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
mpi_errno = MPID_Sched_create(&s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* add some entries to it */
- mpi_errno = sched_get_cid_nonblock(comm_ptr, newcommp, &newcommp->context_id, &newcommp->recvcontext_id, s, MPID_INTRACOMM);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno =
+ sched_get_cid_nonblock(comm_ptr, newcommp, &newcommp->context_id, &newcommp->recvcontext_id,
+ s, MPID_INTRACOMM);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* finally, kick off the schedule and give the caller a request */
mpi_errno = MPID_Sched_start(&s, comm_ptr, tag, req);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
-fn_exit:
+ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_CONTEXTID_NONBLOCK);
return mpi_errno;
/* --BEGIN ERROR HANDLING-- */
-fn_fail:
+ fn_fail:
goto fn_exit;
/* --END ERROR HANDLING-- */
}
@@ -1605,7 +1674,8 @@ fn_fail:
#define FUNCNAME MPIR_Get_intercomm_contextid_nonblock
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_intercomm_contextid_nonblock(MPID_Comm *comm_ptr, MPID_Comm *newcommp, MPID_Request **req)
+int MPIR_Get_intercomm_contextid_nonblock(MPID_Comm * comm_ptr, MPID_Comm * newcommp,
+ MPID_Request ** req)
{
int mpi_errno = MPI_SUCCESS;
int tag;
@@ -1617,48 +1687,55 @@ int MPIR_Get_intercomm_contextid_nonblock(MPID_Comm *comm_ptr, MPID_Comm *newcom
/* do as much local setup as possible */
if (!comm_ptr->local_comm) {
mpi_errno = MPIR_Setup_intercomm_localcomm(comm_ptr);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
}
/* now create a schedule */
mpi_errno = MPID_Sched_next_tag(comm_ptr, &tag);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
mpi_errno = MPID_Sched_create(&s);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* add some entries to it */
/* first get a context ID over the local comm */
- mpi_errno = sched_get_cid_nonblock(comm_ptr, newcommp, &newcommp->recvcontext_id, &newcommp->context_id, s, MPID_INTERCOMM);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno =
+ sched_get_cid_nonblock(comm_ptr, newcommp, &newcommp->recvcontext_id, &newcommp->context_id,
+ s, MPID_INTERCOMM);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* finally, kick off the schedule and give the caller a request */
mpi_errno = MPID_Sched_start(&s, comm_ptr, tag, req);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
-fn_fail:
+ fn_fail:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID_NONBLOCK);
return mpi_errno;
}
-/* Get a context for a new intercomm. There are two approaches
+/* Get a context for a new intercomm. There are two approaches
here (for MPI-1 codes only)
(a) Each local group gets a context; the groups exchange, and
the low value is accepted and the high one returned. This
works because the context ids are taken from the same pool.
(b) Form a temporary intracomm over all processes and use that
with the regular algorithm.
-
+
In some ways, (a) is the better approach because it is the one that
- extends to MPI-2 (where the last step, returning the context, is
- not used and instead separate send and receive context id value
+ extends to MPI-2 (where the last step, returning the context, is
+ not used and instead separate send and receive context id value
are kept). For this reason, we'll use (a).
Even better is to separate the local and remote context ids. Then
each group of processes can manage their context ids separately.
*/
-/*
+/*
* This uses the thread-safe (if necessary) routine to get a context id
* and does not need its own thread-safe version.
*/
@@ -1666,16 +1743,16 @@ fn_fail:
#define FUNCNAME MPIR_Get_intercomm_contextid
#undef FCNAME
#define FCNAME "MPIR_Get_intercomm_contextid"
-int MPIR_Get_intercomm_contextid( MPID_Comm *comm_ptr, MPIR_Context_id_t *context_id,
- MPIR_Context_id_t *recvcontext_id )
+int MPIR_Get_intercomm_contextid(MPID_Comm * comm_ptr, MPIR_Context_id_t * context_id,
+ MPIR_Context_id_t * recvcontext_id)
{
MPIR_Context_id_t mycontext_id, remote_context_id;
int mpi_errno = MPI_SUCCESS;
- int tag = 31567; /* FIXME - we need an internal tag or
- communication channel. Can we use a different
- context instead?. Or can we use the tag
- provided in the intercomm routine? (not on a dup,
- but in that case it can use the collective context) */
+ int tag = 31567; /* FIXME - we need an internal tag or
+ * communication channel. Can we use a different
+ * context instead?. Or can we use the tag
+ * provided in the intercomm routine? (not on a dup,
+ * but in that case it can use the collective context) */
mpir_errflag_t errflag = MPIR_ERR_NONE;
MPID_MPI_STATE_DECL(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID);
@@ -1683,37 +1760,41 @@ int MPIR_Get_intercomm_contextid( MPID_Comm *comm_ptr, MPIR_Context_id_t *contex
if (!comm_ptr->local_comm) {
/* Manufacture the local communicator */
- mpi_errno = MPIR_Setup_intercomm_localcomm( comm_ptr );
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno = MPIR_Setup_intercomm_localcomm(comm_ptr);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
}
- mpi_errno = MPIR_Get_contextid( comm_ptr->local_comm, &mycontext_id );
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno = MPIR_Get_contextid(comm_ptr->local_comm, &mycontext_id);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPIU_Assert(mycontext_id != 0);
/* MPIC routine uses an internal context id. The local leads (process 0)
- exchange data */
+ * exchange data */
remote_context_id = -1;
if (comm_ptr->rank == 0) {
- mpi_errno = MPIC_Sendrecv( &mycontext_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, tag,
- &remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, tag,
- comm_ptr, MPI_STATUS_IGNORE, &errflag );
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno = MPIC_Sendrecv(&mycontext_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, tag,
+ &remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE, 0, tag,
+ comm_ptr, MPI_STATUS_IGNORE, &errflag);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
}
/* Make sure that all of the local processes now have this
- id */
- mpi_errno = MPIR_Bcast_impl( &remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE,
- 0, comm_ptr->local_comm, &errflag );
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ * id */
+ mpi_errno = MPIR_Bcast_impl(&remote_context_id, 1, MPIR_CONTEXT_ID_T_DATATYPE,
+ 0, comm_ptr->local_comm, &errflag);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
/* The recvcontext_id must be the one that was allocated out of the local
* group, not the remote group. Otherwise we could end up posting two
* MPI_ANY_SOURCE,MPI_ANY_TAG recvs on the same context IDs even though we
* are attempting to post them for two separate communicators. */
- *context_id = remote_context_id;
+ *context_id = remote_context_id;
*recvcontext_id = mycontext_id;
- fn_fail:
+ fn_fail:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_INTERCOMM_CONTEXTID);
return mpi_errno;
}
@@ -1722,22 +1803,21 @@ int MPIR_Get_intercomm_contextid( MPID_Comm *comm_ptr, MPIR_Context_id_t *contex
#define FUNCNAME MPIR_Free_contextid
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-void MPIR_Free_contextid( MPIR_Context_id_t context_id )
+void MPIR_Free_contextid(MPIR_Context_id_t context_id)
{
int idx, bitpos, raw_prefix;
MPID_MPI_STATE_DECL(MPID_STATE_MPIR_FREE_CONTEXTID);
-
+
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_FREE_CONTEXTID);
/* Convert the context id to the bit position */
- raw_prefix = MPID_CONTEXT_READ_FIELD(PREFIX,context_id);
- idx = raw_prefix / MPIR_CONTEXT_INT_BITS;
+ raw_prefix = MPID_CONTEXT_READ_FIELD(PREFIX, context_id);
+ idx = raw_prefix / MPIR_CONTEXT_INT_BITS;
bitpos = raw_prefix % MPIR_CONTEXT_INT_BITS;
/* --BEGIN ERROR HANDLING-- */
if (idx < 0 || idx >= MPIR_MAX_CONTEXT_MASK) {
- MPID_Abort( 0, MPI_ERR_INTERN, 1,
- "In MPIR_Free_contextid, idx is out of range" );
+ MPID_Abort(0, MPI_ERR_INTERN, 1, "In MPIR_Free_contextid, idx is out of range");
}
/* --END ERROR HANDLING-- */
@@ -1745,10 +1825,10 @@ void MPIR_Free_contextid( MPIR_Context_id_t context_id )
* same way that low bits of non-dynamic ctx IDs do. So we have to
* check the dynamic case first. */
if (MPID_CONTEXT_READ_FIELD(DYNAMIC_PROC, context_id)) {
- MPIU_DBG_MSG_D(COMM,VERBOSE,"skipping dynamic process ctx id, context_id=%d", context_id);
+ MPIU_DBG_MSG_D(COMM, VERBOSE, "skipping dynamic process ctx id, context_id=%d", context_id);
goto fn_exit;
}
- else { /* non-dynamic context ID */
+ else { /* non-dynamic context ID */
/* In terms of the context ID bit vector, intercomms and their constituent
* localcomms have the same value. To avoid a double-free situation we just
* don't free the context ID for localcomms and assume it will be cleaned up
@@ -1757,42 +1837,42 @@ void MPIR_Free_contextid( MPIR_Context_id_t context_id )
#ifdef USE_DBG_LOGGING
char dump_str[1024];
MPIR_Comm_dump_context_id(context_id, dump_str, sizeof(dump_str));
- MPIU_DBG_MSG_S(COMM,VERBOSE,"skipping localcomm id: %s", dump_str);
+ MPIU_DBG_MSG_S(COMM, VERBOSE, "skipping localcomm id: %s", dump_str);
#endif
goto fn_exit;
}
else if (MPID_CONTEXT_READ_FIELD(SUBCOMM, context_id)) {
- MPIU_DBG_MSG_D(COMM,VERBOSE,"skipping non-parent communicator ctx id, context_id=%d", context_id);
+ MPIU_DBG_MSG_D(COMM, VERBOSE, "skipping non-parent communicator ctx id, context_id=%d",
+ context_id);
goto fn_exit;
}
}
/* --BEGIN ERROR HANDLING-- */
/* Check that this context id has been allocated */
- if ( (context_mask[idx] & (0x1 << bitpos)) != 0 ) {
+ if ((context_mask[idx] & (0x1 << bitpos)) != 0) {
#ifdef USE_DBG_LOGGING
char dump_str[1024];
MPIR_Comm_dump_context_id(context_id, dump_str, sizeof(dump_str));
- MPIU_DBG_MSG_S(COMM,VERBOSE,"context dump: %s", dump_str);
- MPIU_DBG_MSG_S(COMM,VERBOSE,"context mask = %s",MPIR_ContextMaskToStr());
+ MPIU_DBG_MSG_S(COMM, VERBOSE, "context dump: %s", dump_str);
+ MPIU_DBG_MSG_S(COMM, VERBOSE, "context mask = %s", MPIR_ContextMaskToStr());
#endif
- MPID_Abort( 0, MPI_ERR_INTERN, 1,
- "In MPIR_Free_contextid, the context id is not in use" );
+ MPID_Abort(0, MPI_ERR_INTERN, 1, "In MPIR_Free_contextid, the context id is not in use");
}
/* --END ERROR HANDLING-- */
MPIU_THREAD_CS_ENTER(CONTEXTID,);
/* MT: Note that this update must be done atomically in the multithreaedd
- case. In the "one, single lock" implementation, that lock is indeed
- held when this operation is called. */
+ * case. In the "one, single lock" implementation, that lock is indeed
+ * held when this operation is called. */
context_mask[idx] |= (0x1 << bitpos);
MPIU_THREAD_CS_EXIT(CONTEXTID,);
- MPIU_DBG_MSG_FMT(COMM,VERBOSE,
+ MPIU_DBG_MSG_FMT(COMM, VERBOSE,
(MPIU_DBG_FDEST,
"Freed context %d, mask[%d] bit %d (prefix=%#x)",
context_id, idx, bitpos, raw_prefix));
-fn_exit:
+ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_FREE_CONTEXTID);
}
@@ -1802,17 +1882,17 @@ fn_exit:
* Does *not* copy attributes. If size is < the size of the local group
* in the input communicator, copy only the first size elements.
* If this process is not a member, return a null pointer in outcomm_ptr.
- * This is only supported in the case where the communicator is in
+ * This is only supported in the case where the communicator is in
* Intracomm (not an Intercomm). Note that this is all that is required
* for cart_create and graph_create.
*
- * Used by cart_create, graph_create, and dup_create
+ * Used by cart_create, graph_create, and dup_create
*/
#undef FUNCNAME
#define FUNCNAME MPIR_Comm_copy
#undef FCNAME
#define FCNAME "MPIR_Comm_copy"
-int MPIR_Comm_copy( MPID_Comm *comm_ptr, int size, MPID_Comm **outcomm_ptr )
+int MPIR_Comm_copy(MPID_Comm * comm_ptr, int size, MPID_Comm ** outcomm_ptr)
{
int mpi_errno = MPI_SUCCESS;
MPIR_Context_id_t new_context_id, new_recvcontext_id;
@@ -1823,20 +1903,20 @@ int MPIR_Comm_copy( MPID_Comm *comm_ptr, int size, MPID_Comm **outcomm_ptr )
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_COMM_COPY);
/* Get a new context first. We need this to be collective over the
- input communicator */
+ * input communicator */
/* If there is a context id cache in oldcomm, use it here. Otherwise,
- use the appropriate algorithm to get a new context id. Be careful
- of intercomms here */
+ * use the appropriate algorithm to get a new context id. Be careful
+ * of intercomms here */
if (comm_ptr->comm_kind == MPID_INTERCOMM) {
- mpi_errno =
- MPIR_Get_intercomm_contextid(
- comm_ptr, &new_context_id, &new_recvcontext_id );
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno = MPIR_Get_intercomm_contextid(comm_ptr, &new_context_id, &new_recvcontext_id);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
}
else {
- mpi_errno = MPIR_Get_contextid( comm_ptr, &new_context_id );
- new_recvcontext_id = new_context_id;
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ mpi_errno = MPIR_Get_contextid(comm_ptr, &new_context_id);
+ new_recvcontext_id = new_context_id;
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
MPIU_Assert(new_context_id != 0);
}
/* --BEGIN ERROR HANDLING-- */
@@ -1846,102 +1926,104 @@ int MPIR_Comm_copy( MPID_Comm *comm_ptr, int size, MPID_Comm **outcomm_ptr )
MPIR_ContextMaskStats(&nfree, &ntotal);
MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
"**toomanycomm", "**toomanycomm %d %d %d",
- nfree, ntotal, /*ignore_id=*/0);
+ nfree, ntotal, /*ignore_id= */ 0);
}
/* --END ERROR HANDLING-- */
/* This is the local size, not the remote size, in the case of
- an intercomm */
+ * an intercomm */
if (comm_ptr->rank >= size) {
*outcomm_ptr = 0;
/* always free the recvcontext ID, never the "send" ID */
MPIR_Free_contextid(new_recvcontext_id);
- goto fn_exit;
+ goto fn_exit;
}
/* We're left with the processes that will have a non-null communicator.
- Create the object, initialize the data, and return the result */
+ * Create the object, initialize the data, and return the result */
- mpi_errno = MPIR_Comm_create( &newcomm_ptr );
- if (mpi_errno) goto fn_fail;
+ mpi_errno = MPIR_Comm_create(&newcomm_ptr);
+ if (mpi_errno)
+ goto fn_fail;
- newcomm_ptr->context_id = new_context_id;
+ newcomm_ptr->context_id = new_context_id;
newcomm_ptr->recvcontext_id = new_recvcontext_id;
/* Save the kind of the communicator */
- newcomm_ptr->comm_kind = comm_ptr->comm_kind;
- newcomm_ptr->local_comm = 0;
+ newcomm_ptr->comm_kind = comm_ptr->comm_kind;
+ newcomm_ptr->local_comm = 0;
/* There are two cases here - size is the same as the old communicator,
- or it is smaller. If the size is the same, we can just add a reference.
- Otherwise, we need to create a new network address mapping. Note that this is the
- test that matches the test on rank above. */
+ * or it is smaller. If the size is the same, we can just add a reference.
+ * Otherwise, we need to create a new network address mapping. Note that this is the
+ * test that matches the test on rank above. */
if (size == comm_ptr->local_size) {
- /* Duplicate the network address mapping */
- if (comm_ptr->comm_kind == MPID_INTRACOMM)
- MPIR_Comm_map_dup(newcomm_ptr, comm_ptr, MPIR_COMM_MAP_DIR_L2L);
- else
- MPIR_Comm_map_dup(newcomm_ptr, comm_ptr, MPIR_COMM_MAP_DIR_R2R);
+ /* Duplicate the network address mapping */
+ if (comm_ptr->comm_kind == MPID_INTRACOMM)
+ MPIR_Comm_map_dup(newcomm_ptr, comm_ptr, MPIR_COMM_MAP_DIR_L2L);
+ else
+ MPIR_Comm_map_dup(newcomm_ptr, comm_ptr, MPIR_COMM_MAP_DIR_R2R);
}
else {
- int i;
-
- if (comm_ptr->comm_kind == MPID_INTRACOMM)
- MPIR_Comm_map_irregular(newcomm_ptr, comm_ptr, NULL, size,
- MPIR_COMM_MAP_DIR_L2L, &map);
- else
- MPIR_Comm_map_irregular(newcomm_ptr, comm_ptr, NULL, size,
- MPIR_COMM_MAP_DIR_R2R, &map);
- for (i = 0; i < size; i++) {
- /* For rank i in the new communicator, find the corresponding
- rank in the input communicator */
- map->src_mapping[i] = i;
- }
+ int i;
+
+ if (comm_ptr->comm_kind == MPID_INTRACOMM)
+ MPIR_Comm_map_irregular(newcomm_ptr, comm_ptr, NULL, size, MPIR_COMM_MAP_DIR_L2L, &map);
+ else
+ MPIR_Comm_map_irregular(newcomm_ptr, comm_ptr, NULL, size, MPIR_COMM_MAP_DIR_R2R, &map);
+ for (i = 0; i < size; i++) {
+ /* For rank i in the new communicator, find the corresponding
+ * rank in the input communicator */
+ map->src_mapping[i] = i;
+ }
}
/* If it is an intercomm, duplicate the local network address references */
if (comm_ptr->comm_kind == MPID_INTERCOMM) {
- MPIR_Comm_map_dup(newcomm_ptr, comm_ptr, MPIR_COMM_MAP_DIR_L2L);
+ MPIR_Comm_map_dup(newcomm_ptr, comm_ptr, MPIR_COMM_MAP_DIR_L2L);
}
/* Set the sizes and ranks */
- newcomm_ptr->rank = comm_ptr->rank;
+ newcomm_ptr->rank = comm_ptr->rank;
if (comm_ptr->comm_kind == MPID_INTERCOMM) {
- newcomm_ptr->local_size = comm_ptr->local_size;
- newcomm_ptr->remote_size = comm_ptr->remote_size;
- newcomm_ptr->is_low_group = comm_ptr->is_low_group;
+ newcomm_ptr->local_size = comm_ptr->local_size;
+ newcomm_ptr->remote_size = comm_ptr->remote_size;
+ newcomm_ptr->is_low_group = comm_ptr->is_low_group;
}
else {
- newcomm_ptr->local_size = size;
- newcomm_ptr->remote_size = size;
+ newcomm_ptr->local_size = size;
+ newcomm_ptr->remote_size = size;
}
/* Inherit the error handler (if any) */
MPIU_THREAD_CS_ENTER(MPI_OBJ, comm_ptr);
newcomm_ptr->errhandler = comm_ptr->errhandler;
if (comm_ptr->errhandler) {
- MPIR_Errhandler_add_ref( comm_ptr->errhandler );
+ MPIR_Errhandler_add_ref(comm_ptr->errhandler);
}
MPIU_THREAD_CS_EXIT(MPI_OBJ, comm_ptr);
/* FIXME do we want to copy coll_fns here? */
mpi_errno = MPIR_Comm_commit(newcomm_ptr);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* Start with no attributes on this communicator */
newcomm_ptr->attributes = 0;
/* Copy over the info hints from the original communicator. */
mpi_errno = MPIR_Info_dup_impl(comm_ptr->info, &(newcomm_ptr->info));
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
mpi_errno = MPIR_Comm_apply_hints(newcomm_ptr, newcomm_ptr->info);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
*outcomm_ptr = newcomm_ptr;
- fn_fail:
- fn_exit:
+ fn_fail:
+ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_COPY);
@@ -1958,7 +2040,7 @@ int MPIR_Comm_copy( MPID_Comm *comm_ptr, int size, MPID_Comm **outcomm_ptr )
#define FUNCNAME MPIR_Comm_copy_data
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Comm_copy_data(MPID_Comm *comm_ptr, MPID_Comm **outcomm_ptr)
+int MPIR_Comm_copy_data(MPID_Comm * comm_ptr, MPID_Comm ** outcomm_ptr)
{
int mpi_errno = MPI_SUCCESS;
MPID_Comm *newcomm_ptr = NULL;
@@ -1967,14 +2049,15 @@ int MPIR_Comm_copy_data(MPID_Comm *comm_ptr, MPID_Comm **outcomm_ptr)
MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_COMM_COPY_DATA);
mpi_errno = MPIR_Comm_create(&newcomm_ptr);
- if (mpi_errno) goto fn_fail;
+ if (mpi_errno)
+ goto fn_fail;
/* use a large garbage value to ensure errors are caught more easily */
- newcomm_ptr->context_id = 32767;
+ newcomm_ptr->context_id = 32767;
newcomm_ptr->recvcontext_id = 32767;
/* Save the kind of the communicator */
- newcomm_ptr->comm_kind = comm_ptr->comm_kind;
+ newcomm_ptr->comm_kind = comm_ptr->comm_kind;
newcomm_ptr->local_comm = 0;
if (comm_ptr->comm_kind == MPID_INTRACOMM)
@@ -1988,9 +2071,9 @@ int MPIR_Comm_copy_data(MPID_Comm *comm_ptr, MPID_Comm **outcomm_ptr)
}
/* Set the sizes and ranks */
- newcomm_ptr->rank = comm_ptr->rank;
- newcomm_ptr->local_size = comm_ptr->local_size;
- newcomm_ptr->remote_size = comm_ptr->remote_size;
+ newcomm_ptr->rank = comm_ptr->rank;
+ newcomm_ptr->local_size = comm_ptr->local_size;
+ newcomm_ptr->remote_size = comm_ptr->remote_size;
newcomm_ptr->is_low_group = comm_ptr->is_low_group; /* only relevant for intercomms */
/* Inherit the error handler (if any) */
@@ -2007,11 +2090,12 @@ int MPIR_Comm_copy_data(MPID_Comm *comm_ptr, MPID_Comm **outcomm_ptr)
newcomm_ptr->attributes = 0;
*outcomm_ptr = newcomm_ptr;
-fn_fail:
-fn_exit:
+ fn_fail:
+ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_COPY_DATA);
return mpi_errno;
}
+
/* Common body between MPIR_Comm_release and MPIR_comm_release_always. This
* helper function frees the actual MPID_Comm structure and any associated
* storage. It also releases any references to other objects.
@@ -2032,36 +2116,36 @@ int MPIR_Comm_delete_internal(MPID_Comm * comm_ptr)
MPID_MPI_FUNC_ENTER(MPID_STATE_COMM_DELETE_INTERNAL);
- MPIU_Assert(MPIU_Object_get_ref(comm_ptr) == 0); /* sanity check */
+ MPIU_Assert(MPIU_Object_get_ref(comm_ptr) == 0); /* sanity check */
/* Remove the attributes, executing the attribute delete routine.
- Do this only if the attribute functions are defined.
- This must be done first, because if freeing the attributes
- returns an error, the communicator is not freed */
+ * Do this only if the attribute functions are defined.
+ * This must be done first, because if freeing the attributes
+ * returns an error, the communicator is not freed */
if (MPIR_Process.attr_free && comm_ptr->attributes) {
/* Temporarily add a reference to this communicator because
- the attr_free code requires a valid communicator */
- MPIU_Object_add_ref( comm_ptr );
- mpi_errno = MPIR_Process.attr_free( comm_ptr->handle,
- &comm_ptr->attributes );
+ * the attr_free code requires a valid communicator */
+ MPIU_Object_add_ref(comm_ptr);
+ mpi_errno = MPIR_Process.attr_free(comm_ptr->handle, &comm_ptr->attributes);
/* Release the temporary reference added before the call to
- attr_free */
- MPIU_Object_release_ref( comm_ptr, &in_use);
+ * attr_free */
+ MPIU_Object_release_ref(comm_ptr, &in_use);
}
/* If the attribute delete functions return failure, the
- communicator must not be freed. That is the reason for the
- test on mpi_errno here. */
+ * communicator must not be freed. That is the reason for the
+ * test on mpi_errno here. */
if (mpi_errno == MPI_SUCCESS) {
/* If this communicator is our parent, and we're disconnecting
- from the parent, mark that fact */
+ * from the parent, mark that fact */
if (MPIR_Process.comm_parent == comm_ptr)
MPIR_Process.comm_parent = NULL;
/* Notify the device that the communicator is about to be
- destroyed */
+ * destroyed */
mpi_errno = MPID_Dev_comm_destroy_hook(comm_ptr);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
/* Free info hints */
if (comm_ptr->info != NULL) {
@@ -2102,42 +2186,40 @@ int MPIR_Comm_delete_internal(MPID_Comm * comm_ptr)
/* This must be the recvcontext_id (i.e. not the (send)context_id)
* because in the case of intercommunicators the send context ID is
* allocated out of the remote group's bit vector, not ours. */
- MPIR_Free_contextid( comm_ptr->recvcontext_id );
+ MPIR_Free_contextid(comm_ptr->recvcontext_id);
/* We need to release the error handler */
/* no MPI_OBJ CS needed */
if (comm_ptr->errhandler &&
- ! (HANDLE_GET_KIND(comm_ptr->errhandler->handle) ==
- HANDLE_KIND_BUILTIN) ) {
+ !(HANDLE_GET_KIND(comm_ptr->errhandler->handle) == HANDLE_KIND_BUILTIN)) {
int errhInuse;
- MPIR_Errhandler_release_ref( comm_ptr->errhandler,&errhInuse);
+ MPIR_Errhandler_release_ref(comm_ptr->errhandler, &errhInuse);
if (!errhInuse) {
- MPIU_Handle_obj_free( &MPID_Errhandler_mem,
- comm_ptr->errhandler );
+ MPIU_Handle_obj_free(&MPID_Errhandler_mem, comm_ptr->errhandler);
}
}
/* Remove from the list of active communicators if
- we are supporting message-queue debugging. We make this
- conditional on having debugger support since the
- operation is not constant-time */
- MPIR_COMML_FORGET( comm_ptr );
+ * we are supporting message-queue debugging. We make this
+ * conditional on having debugger support since the
+ * operation is not constant-time */
+ MPIR_COMML_FORGET(comm_ptr);
/* Check for predefined communicators - these should not
- be freed */
- if (! (HANDLE_GET_KIND(comm_ptr->handle) == HANDLE_KIND_BUILTIN) )
- MPIU_Handle_obj_free( &MPID_Comm_mem, comm_ptr );
+ * be freed */
+ if (!(HANDLE_GET_KIND(comm_ptr->handle) == HANDLE_KIND_BUILTIN))
+ MPIU_Handle_obj_free(&MPID_Comm_mem, comm_ptr);
}
else {
/* If the user attribute free function returns an error,
- then do not free the communicator */
- MPIR_Comm_add_ref( comm_ptr );
+ * then do not free the communicator */
+ MPIR_Comm_add_ref(comm_ptr);
}
- fn_exit:
+ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_COMM_DELETE_INTERNAL);
return mpi_errno;
- fn_fail:
+ fn_fail:
goto fn_exit;
}
@@ -2149,7 +2231,7 @@ int MPIR_Comm_delete_internal(MPID_Comm * comm_ptr)
#define FUNCNAME MPIR_Comm_release_always
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Comm_release_always(MPID_Comm *comm_ptr)
+int MPIR_Comm_release_always(MPID_Comm * comm_ptr)
{
int mpi_errno = MPI_SUCCESS;
int in_use;
@@ -2162,13 +2244,14 @@ int MPIR_Comm_release_always(MPID_Comm *comm_ptr)
MPIU_Object_release_ref_always(comm_ptr, &in_use);
if (!in_use) {
mpi_errno = MPIR_Comm_delete_internal(comm_ptr);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
}
- fn_exit:
+ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_RELEASE_ALWAYS);
return mpi_errno;
- fn_fail:
+ fn_fail:
goto fn_exit;
}
@@ -2178,7 +2261,7 @@ int MPIR_Comm_release_always(MPID_Comm *comm_ptr)
#define FUNCNAME MPIR_Comm_apply_hints
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Comm_apply_hints(MPID_Comm *comm_ptr, MPID_Info *info_ptr)
+int MPIR_Comm_apply_hints(MPID_Comm * comm_ptr, MPID_Info * info_ptr)
{
int mpi_errno = MPI_SUCCESS;
MPID_Info *hint = NULL;
@@ -2190,7 +2273,8 @@ int MPIR_Comm_apply_hints(MPID_Comm *comm_ptr, MPID_Info *info_ptr)
MPL_LL_FOREACH(info_ptr, hint) {
/* Have we hit the default, empty info hint? */
- if (hint->key == NULL) continue;
+ if (hint->key == NULL)
+ continue;
strncpy(hint_name, hint->key, MPI_MAX_INFO_KEY);
@@ -2199,14 +2283,15 @@ int MPIR_Comm_apply_hints(MPID_Comm *comm_ptr, MPID_Info *info_ptr)
/* Skip hints that MPICH doesn't recognize. */
if (hint_fn) {
mpi_errno = hint_fn->fn(comm_ptr, hint, hint_fn->state);
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
+ if (mpi_errno)
+ MPIU_ERR_POP(mpi_errno);
}
}
- fn_exit:
+ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_APPLY_HINTS);
return mpi_errno;
- fn_fail:
+ fn_fail:
goto fn_exit;
}
@@ -2229,10 +2314,10 @@ static int MPIR_Comm_free_hint_handles(void *ignore)
}
}
- fn_exit:
+ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_FREE_HINT_HANDLES);
return mpi_errno;
- fn_fail:
+ fn_fail:
goto fn_exit;
}
@@ -2261,9 +2346,9 @@ int MPIR_Comm_register_hint(const char *hint_key, MPIR_Comm_hint_fn_t fn, void *
HASH_ADD_STR(MPID_hint_fns, name, hint_elt);
- fn_exit:
+ fn_exit:
MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_COMM_REGISTER_HINT);
return mpi_errno;
- fn_fail:
+ fn_fail:
goto fn_exit;
}
-----------------------------------------------------------------------
Summary of changes:
src/include/mpiimpl.h | 1 -
src/mpi/comm/Makefile.mk | 3 +-
src/mpi/comm/comm_create.c | 6 +-
src/mpi/comm/comm_split.c | 2 +-
src/mpi/comm/commutil.c | 1646 +++++++--------------------------------
src/mpi/comm/contextid.c | 1163 +++++++++++++++++++++++++++
src/mpi/comm/intercomm_create.c | 4 +-
src/mpi/comm/intercomm_merge.c | 4 +-
src/mpi/comm/mpicomm.h | 5 -
src/mpid/ch3/src/ch3u_port.c | 4 +-
10 files changed, 1449 insertions(+), 1389 deletions(-)
create mode 100644 src/mpi/comm/contextid.c
hooks/post-receive
--
MPICH primary repository
1
0
[mpich] MPICH primary repository branch, master, updated. v3.2b4-82-g0d6f27f
by noreply@mpich.org 06 Aug '15
by noreply@mpich.org 06 Aug '15
06 Aug '15
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 0d6f27fb0333f17358552d1ea1c8acd803d678de (commit)
from 2dba0efc81f00b3b41b6f1dfb71eef76a243bdd9 (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/0d6f27fb0333f17358552d1ea1c8acd80…
commit 0d6f27fb0333f17358552d1ea1c8acd803d678de
Author: Ken Raffenetti <raffenet(a)mcs.anl.gov>
Date: Thu Aug 6 09:16:00 2015 -0500
netmod/portals4: delete unused code
No reviewer.
diff --git a/src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_impl.h b/src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_impl.h
index 7ec7870..0f0cc64 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_impl.h
+++ b/src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_impl.h
@@ -32,21 +32,11 @@ extern ptl_ni_limits_t MPIDI_nem_ptl_ni_limits;
/* workaround for NULL operations */
extern char dummy;
-#define MPID_NEM_PTL_MAX_OVERFLOW_DATA 32 /* that's way more than we need */
-typedef struct MPID_nem_ptl_pack_overflow
-{
- MPI_Aint len;
- MPI_Aint offset;
- char buf[MPID_NEM_PTL_MAX_OVERFLOW_DATA];
-} MPID_nem_ptl_pack_overflow_t;
-
typedef int (* event_handler_fn)(const ptl_event_t *e);
#define MPID_NEM_PTL_NUM_CHUNK_BUFFERS 2
typedef struct {
- struct MPID_nem_ptl_pack_overflow overflow[MPID_NEM_PTL_NUM_CHUNK_BUFFERS];
- int large;
ptl_handle_md_t md;
ptl_handle_me_t put_me;
ptl_handle_me_t *get_me_p;
@@ -69,7 +59,6 @@ static inline MPID_nem_ptl_req_area * REQ_PTL(MPID_Request *req) {
for (i = 0; i < MPID_NEM_PTL_NUM_CHUNK_BUFFERS; ++i) { \
REQ_PTL(req_)->chunk_buffer[i] = NULL; \
} \
- REQ_PTL(req_)->large = FALSE; \
REQ_PTL(req_)->md = PTL_INVALID_HANDLE; \
REQ_PTL(req_)->put_me = PTL_INVALID_HANDLE; \
REQ_PTL(req_)->get_me_p = NULL; \
@@ -163,10 +152,6 @@ int MPID_nem_ptl_poll(int is_blocking_poll);
int MPID_nem_ptl_vc_terminated(MPIDI_VC_t *vc);
int MPID_nem_ptl_get_id_from_bc(const char *business_card, ptl_process_t *id, ptl_pt_index_t *pt, ptl_pt_index_t *ptg,
ptl_pt_index_t *ptc, ptl_pt_index_t *ptr, ptl_pt_index_t *ptrg, ptl_pt_index_t *ptrc);
-void MPI_nem_ptl_pack_byte(MPID_Segment *segment, MPI_Aint first, MPI_Aint last, void *buf,
- MPID_nem_ptl_pack_overflow_t *overflow);
-int MPID_nem_ptl_unpack_byte(MPID_Segment *segment, MPI_Aint first, MPI_Aint last, void *buf,
- MPID_nem_ptl_pack_overflow_t *overflow);
/* comm override functions */
int MPID_nem_ptl_recv_posted(struct MPIDI_VC *vc, struct MPID_Request *req);
diff --git a/src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_send.c b/src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_send.c
index 1ef148f..959f278 100644
--- a/src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_send.c
+++ b/src/mpid/ch3/channels/nemesis/netmod/portals4/ptl_send.c
@@ -217,7 +217,6 @@ static int send_msg(ptl_hdr_data_t ssend_flag, struct MPIDI_VC *vc, const void *
MPIU_DBG_MSG(CH3_CHANNEL, VERBOSE, "Large contig message");
big_meappend((char *)buf + dt_true_lb + PTL_LARGE_THRESHOLD, data_sz - PTL_LARGE_THRESHOLD, vc,
NPTL_MATCH(tag, comm->context_id + context_offset, comm->rank), sreq);
- REQ_PTL(sreq)->large = TRUE;
REQ_PTL(sreq)->event_handler = handler_send;
ret = MPID_nem_ptl_rptl_put(MPIDI_nem_ptl_global_md, (ptl_size_t)((char *)buf + dt_true_lb), PTL_LARGE_THRESHOLD, PTL_NO_ACK_REQ, vc_ptl->id, vc_ptl->pt,
@@ -291,8 +290,6 @@ static int send_msg(ptl_hdr_data_t ssend_flag, struct MPIDI_VC *vc, const void *
ret = PtlMDBind(MPIDI_nem_ptl_ni, &md, &REQ_PTL(sreq)->md);
MPIU_ERR_CHKANDJUMP1(ret, mpi_errno, MPI_ERR_OTHER, "**ptlmdbind", "**ptlmdbind %s", MPID_nem_ptl_strerror(ret));
- REQ_PTL(sreq)->large = TRUE;
-
REQ_PTL(sreq)->event_handler = handler_send;
ret = MPID_nem_ptl_rptl_put(REQ_PTL(sreq)->md, 0, PTL_LARGE_THRESHOLD, PTL_NO_ACK_REQ, vc_ptl->id, vc_ptl->pt,
NPTL_MATCH(tag, comm->context_id + context_offset, comm->rank), 0, sreq,
@@ -315,7 +312,6 @@ static int send_msg(ptl_hdr_data_t ssend_flag, struct MPIDI_VC *vc, const void *
big_meappend((char *)REQ_PTL(sreq)->chunk_buffer[0] + PTL_LARGE_THRESHOLD, data_sz - PTL_LARGE_THRESHOLD, vc,
NPTL_MATCH(tag, comm->context_id + context_offset, comm->rank), sreq);
- REQ_PTL(sreq)->large = TRUE;
REQ_PTL(sreq)->event_handler = handler_send;
ret = MPID_nem_ptl_rptl_put(MPIDI_nem_ptl_global_md, (ptl_size_t)REQ_PTL(sreq)->chunk_buffer[0], PTL_LARGE_THRESHOLD,
-----------------------------------------------------------------------
Summary of changes:
.../channels/nemesis/netmod/portals4/ptl_impl.h | 15 ---------------
.../channels/nemesis/netmod/portals4/ptl_send.c | 4 ----
2 files changed, 0 insertions(+), 19 deletions(-)
hooks/post-receive
--
MPICH primary repository
1
0
[mpich] MPICH primary repository branch, master, updated. v3.2b4-81-g2dba0ef
by noreply@mpich.org 06 Aug '15
by noreply@mpich.org 06 Aug '15
06 Aug '15
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 2dba0efc81f00b3b41b6f1dfb71eef76a243bdd9 (commit)
from 4096fe9f4d97ce54244995c5e459e26637be272f (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/2dba0efc81f00b3b41b6f1dfb71eef76a…
commit 2dba0efc81f00b3b41b6f1dfb71eef76a243bdd9
Author: Lena Oden <loden(a)anl.gov>
Date: Wed Aug 5 11:05:14 2015 -0500
Remove old USE_STRICT_MPI macros
MPI_Comm_idup and MPI_Create_groups are now part of the MPI3
standard, so these Macros are not neccessary any longer.
Signed-off-by: Huiwei Lu <huiweilu(a)mcs.anl.gov>
diff --git a/test/mpi/comm/comm_create_group.c b/test/mpi/comm/comm_create_group.c
index c89760b..ee0a8df 100644
--- a/test/mpi/comm/comm_create_group.c
+++ b/test/mpi/comm/comm_create_group.c
@@ -4,7 +4,6 @@
* See COPYRIGHT in top-level directory.
*/
#include "mpi.h"
-/* USE_STRICT_MPI may be defined in mpitestconf.h */
#include "mpitestconf.h"
#include <stdio.h>
#include <string.h>
@@ -39,14 +38,12 @@ int main(int argc, char *argv[])
MPI_Group_excl(world_group, size / 2, excl, &even_group);
MPI_Group_free(&world_group);
-#if !defined(USE_STRICT_MPI) && defined(MPICH)
if (rank % 2 == 0) {
/* Even processes create a group for themselves */
MPI_Comm_create_group(MPI_COMM_WORLD, even_group, 0, &even_comm);
MPI_Barrier(even_comm);
MPI_Comm_free(&even_comm);
}
-#endif /* USE_STRICT_MPI */
MPI_Group_free(&even_group);
MPI_Barrier(MPI_COMM_WORLD);
diff --git a/test/mpi/comm/comm_group_half.c b/test/mpi/comm/comm_group_half.c
index e6a5bbe..bd98ab3 100644
--- a/test/mpi/comm/comm_group_half.c
+++ b/test/mpi/comm/comm_group_half.c
@@ -6,7 +6,6 @@
#include <stdio.h>
#include <mpi.h>
-/* USE_STRICT_MPI may be defined in mpitestconf.h */
#include "mpitestconf.h"
int main(int argc, char **argv)
@@ -26,13 +25,11 @@ int main(int argc, char **argv)
range[0][2] = 1;
MPI_Group_range_incl(full_group, 1, range, &half_group);
-#if !defined(USE_STRICT_MPI) && defined(MPICH)
if (rank <= size / 2) {
MPI_Comm_create_group(MPI_COMM_WORLD, half_group, 0, &comm);
MPI_Barrier(comm);
MPI_Comm_free(&comm);
}
-#endif /* USE_STRICT_MPI */
MPI_Group_free(&half_group);
MPI_Group_free(&full_group);
diff --git a/test/mpi/comm/comm_group_rand.c b/test/mpi/comm/comm_group_rand.c
index 681242d..7f609c0 100644
--- a/test/mpi/comm/comm_group_rand.c
+++ b/test/mpi/comm/comm_group_rand.c
@@ -7,7 +7,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
-/* USE_STRICT_MPI may be defined in mpitestconf.h */
#include "mpitestconf.h"
#define LOOPS 100
@@ -42,13 +41,11 @@ int main(int argc, char **argv)
MPI_Group_incl(full_group, count, ranks, &sub_group);
-#if !defined(USE_STRICT_MPI) && defined(MPICH)
if (included[rank]) {
MPI_Comm_create_group(MPI_COMM_WORLD, sub_group, 0, &comm);
MPI_Barrier(comm);
MPI_Comm_free(&comm);
}
-#endif /* USE_STRICT_MPI */
MPI_Group_free(&sub_group);
}
diff --git a/test/mpi/comm/comm_idup.c b/test/mpi/comm/comm_idup.c
index fc41ae1..4aa94ea 100644
--- a/test/mpi/comm/comm_idup.c
+++ b/test/mpi/comm/comm_idup.c
@@ -10,13 +10,6 @@
#include "mpi.h"
#include "mpitest.h"
-/* This is a temporary #ifdef to control whether we test this functionality. A
- * configure-test or similar would be better. Eventually the MPI-3 standard
- * will be released and this can be gated on a MPI_VERSION check */
-#if !defined(USE_STRICT_MPI) && defined(MPICH)
-#define TEST_IDUP 1
-#endif
-
/* assert-like macro that bumps the err count and emits a message */
#define check(x_) \
do { \
@@ -47,7 +40,6 @@ int main(int argc, char **argv)
MPI_Abort(MPI_COMM_WORLD, 1);
}
-#ifdef TEST_IDUP
/* test plan: make rank 0 wait in a blocking recv until all other processes
* have posted their MPI_Comm_idup ops, then post last. Should ensure that
@@ -130,7 +122,6 @@ int main(int argc, char **argv)
MPI_Comm_free(&newcomm);
MPI_Comm_free(&ic);
-#endif /* TEST_IDUP */
MPI_Reduce((rank == 0 ? MPI_IN_PLACE : &errs), &errs, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (rank == 0) {
diff --git a/test/mpi/threads/comm/comm_create_group_threads.c b/test/mpi/threads/comm/comm_create_group_threads.c
index 9eaeaf9..74c955d 100644
--- a/test/mpi/threads/comm/comm_create_group_threads.c
+++ b/test/mpi/threads/comm/comm_create_group_threads.c
@@ -40,7 +40,6 @@ MTEST_THREAD_RETURN_TYPE test_comm_create_group(void *arg)
* ranks join an even comm and threads on odd ranks join the odd comm.
*/
-#ifndef USE_STRICT_MPI
if (verbose)
printf("%d: Thread %d - Comm_create_group %d start\n", rank, *(int *) arg, i);
MPI_Comm_create_group(comms[*(int *) arg], world_group, *(int *) arg /* tag */ , &comm);
@@ -48,7 +47,6 @@ MTEST_THREAD_RETURN_TYPE test_comm_create_group(void *arg)
MPI_Comm_free(&comm);
if (verbose)
printf("%d: Thread %d - Comm_create_group %d finish\n", rank, *(int *) arg, i);
-#endif /* USE_STRICT_MPI */
MPI_Group_free(&world_group);
diff --git a/test/mpi/threads/comm/testlist.in b/test/mpi/threads/comm/testlist.in
index cbc4cb0..bbc7f8a 100644
--- a/test/mpi/threads/comm/testlist.in
+++ b/test/mpi/threads/comm/testlist.in
@@ -2,7 +2,7 @@ ctxdup 4
dup_leak_test 2
comm_dup_deadlock 4
comm_create_threads 4
-comm_create_group_threads 4
+comm_create_group_threads 4 mpiversion=3.0
@comm_overlap@ comm_idup 4 mpiversion=3.0
@comm_overlap@ ctxidup 4 mpiversion=3.0
idup_nb 4 mpiversion=3.0
-----------------------------------------------------------------------
Summary of changes:
test/mpi/comm/comm_create_group.c | 3 ---
test/mpi/comm/comm_group_half.c | 3 ---
test/mpi/comm/comm_group_rand.c | 3 ---
test/mpi/comm/comm_idup.c | 9 ---------
test/mpi/threads/comm/comm_create_group_threads.c | 2 --
test/mpi/threads/comm/testlist.in | 2 +-
6 files changed, 1 insertions(+), 21 deletions(-)
hooks/post-receive
--
MPICH primary repository
1
0
[mpich] MPICH primary repository branch, master, updated. v3.2b4-80-g4096fe9
by noreply@mpich.org 06 Aug '15
by noreply@mpich.org 06 Aug '15
06 Aug '15
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 4096fe9f4d97ce54244995c5e459e26637be272f (commit)
via 24a5f95441047c9c5c8738d0c7515355fe81bd82 (commit)
from 6b640b5f0aa5886add15e38c6eb77e41196605f7 (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/4096fe9f4d97ce54244995c5e459e2663…
commit 4096fe9f4d97ce54244995c5e459e26637be272f
Author: Huiwei Lu <huiweilu(a)mcs.anl.gov>
Date: Thu Aug 6 10:58:54 2015 -0500
Deprecate single-threaded MPIR_Get_contextid_sparse_group
The single-threaded MPIR_Get_contextid_sparse_group is outdated and
buggy, which does not consider the overlapping use of itself and
MPI_Comm_idup. The multi-threaded implementation has already fixed that
and has better error handling, there is no reason to still keep the
single-threaded version.
Fixes #2295, #2297
Signed-off-by: Lena Oden <loden(a)anl.gov>
diff --git a/src/mpi/comm/commutil.c b/src/mpi/comm/commutil.c
index 2b6bd31..dee8775 100644
--- a/src/mpi/comm/commutil.c
+++ b/src/mpi/comm/commutil.c
@@ -975,98 +975,6 @@ static volatile int mask_in_use = 0;
static volatile int lowestContextId = MPIR_MAXID;
static volatile int lowestTag = -1;
-#ifndef MPICH_IS_THREADED
-/* Unthreaded (only one MPI call active at any time) */
-
-#undef FUNCNAME
-#define FUNCNAME MPIR_Get_contextid_sparse
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid_sparse(MPID_Comm *comm_ptr, MPIR_Context_id_t *context_id, int ignore_id)
-{
- return MPIR_Get_contextid_sparse_group(comm_ptr, NULL /* group_ptr */, MPIR_Process.attrs.tag_ub /* tag */, context_id, ignore_id);
-}
-
-#undef FUNCNAME
-#define FUNCNAME MPIR_Get_contextid_sparse_group
-#undef FCNAME
-#define FCNAME MPIU_QUOTE(FUNCNAME)
-int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr, int tag, MPIR_Context_id_t *context_id, int ignore_id)
-{
- int mpi_errno = MPI_SUCCESS;
- uint32_t local_mask[MPIR_MAX_CONTEXT_MASK];
- mpir_errflag_t errflag = MPIR_ERR_NONE;
- int seqnum = 0;
- if (comm_ptr->idup_count)
- seqnum = comm_ptr->idup_curr_seqnum++;
- MPID_MPI_STATE_DECL(MPID_STATE_MPIR_GET_CONTEXTID);
-
- MPID_MPI_FUNC_ENTER(MPID_STATE_MPIR_GET_CONTEXTID);
-
- *context_id = 0;
-
- while (*context_id == 0) {
- if (initialize_context_mask) {
- MPIR_Init_contextid();
- }
-
- if (ignore_id) {
- /* We are not participating in the resulting communicator, so our
- * context ID space doesn't matter. Set the mask to "all available". */
- memset(local_mask, 0xff, MPIR_MAX_CONTEXT_MASK * sizeof(int));
- }
- else if (comm_ptr->idup_count && seqnum != comm_ptr->idup_next_seqnum) {
- memset(local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
- }
- else {
- MPIU_Memcpy(local_mask, context_mask, MPIR_MAX_CONTEXT_MASK * sizeof(int));
- }
-
- /* Note that this is the unthreaded version */
- /* Comm must be an intracommunicator */
- if (group_ptr != NULL) {
- int coll_tag = tag | MPIR_Process.tagged_coll_mask; /* Shift tag into the tagged coll space */
- mpi_errno = MPIR_Allreduce_group(MPI_IN_PLACE, local_mask, MPIR_MAX_CONTEXT_MASK,
- MPI_INT, MPI_BAND, comm_ptr, group_ptr, coll_tag, &errflag);
- } else {
- mpi_errno = MPIR_Allreduce_impl(MPI_IN_PLACE, local_mask, MPIR_MAX_CONTEXT_MASK,
- MPI_INT, MPI_BAND, comm_ptr, &errflag);
- }
-
- if (mpi_errno) MPIU_ERR_POP(mpi_errno);
- MPIU_ERR_CHKANDJUMP(errflag, mpi_errno, MPI_ERR_OTHER, "**coll_fail");
-
- if (ignore_id) {
- *context_id = MPIR_Locate_context_bit(local_mask);
- if (*context_id == 0) {
- int nfree = -1;
- int ntotal = -1;
- MPIR_ContextMaskStats(&nfree, &ntotal);
- MPIU_ERR_SETANDJUMP3(mpi_errno, MPI_ERR_OTHER,
- "**toomanycomm", "**toomanycomm %d %d %d",
- nfree, ntotal, ignore_id);
- }
- }
- else {
- *context_id = MPIR_Find_and_allocate_context_id(local_mask);
- }
- }
- if (seqnum > 0)
- comm_ptr->idup_next_seqnum++;
-
-fn_exit:
- if (ignore_id)
- *context_id = MPIR_INVALID_CONTEXT_ID;
- MPIU_DBG_MSG_S(COMM,VERBOSE,"Context mask = %s",MPIR_ContextMaskToStr());
-
- MPID_MPI_FUNC_EXIT(MPID_STATE_MPIR_GET_CONTEXTID);
- return mpi_errno;
-fn_fail:
- goto fn_exit;
-}
-
-#else /* MPICH_IS_THREADED is set and true */
-
#undef FUNCNAME
#define FUNCNAME MPIR_Get_contextid_sparse
#undef FCNAME
@@ -1354,8 +1262,6 @@ fn_fail:
/* --END ERROR HANDLING-- */
}
-#endif
-
struct gcn_state {
MPIR_Context_id_t *ctx0;
MPIR_Context_id_t *ctx1;
http://git.mpich.org/mpich.git/commitdiff/24a5f95441047c9c5c8738d0c7515355f…
commit 24a5f95441047c9c5c8738d0c7515355fe81bd82
Author: Huiwei Lu <huiweilu(a)mcs.anl.gov>
Date: Wed Aug 5 13:07:25 2015 -0500
Fixing a copy-paste error in comm_idup_comm2
comm_idup_comm2.c is copied from comm_idup_comm.c, while modifing it to
do overlapping communicator operations on a separate communicator.
However, the group related to the separate communicator was not changed
accordingly, thus causes a user error in MPI_Comm_create_group.
Ref #2295
Signed-off-by: Lena Oden <loden(a)anl.gov>
diff --git a/test/mpi/comm/comm_idup_comm2.c b/test/mpi/comm/comm_idup_comm2.c
index dd476dc..bf70824 100644
--- a/test/mpi/comm/comm_idup_comm2.c
+++ b/test/mpi/comm/comm_idup_comm2.c
@@ -22,7 +22,7 @@ int main(int argc, char **argv)
int *excl;
int ranges[1][3];
int isLeft, rleader;
- MPI_Group world_group, high_group, even_group;
+ MPI_Group dup_group, high_group, even_group;
MPI_Comm local_comm, inter_comm, test_comm, outcomm, dupcomm;
MPI_Comm idupcomms[NUM_IDUPS];
MPI_Request reqs[NUM_IDUPS];
@@ -30,8 +30,8 @@ int main(int argc, char **argv)
MTest_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &size);
- MPI_Comm_group(MPI_COMM_WORLD, &world_group);
MPI_Comm_dup(MPI_COMM_WORLD, &dupcomm);
+ MPI_Comm_group(dupcomm, &dup_group);
if (size < 2) {
printf("this test requires at least 2 processes\n");
@@ -59,7 +59,7 @@ int main(int argc, char **argv)
ranges[0][0] = size / 2;
ranges[0][1] = size - 1;
ranges[0][2] = 1;
- MPI_Group_range_incl(world_group, 1, ranges, &high_group);
+ MPI_Group_range_incl(dup_group, 1, ranges, &high_group);
MPI_Comm_create(dupcomm, high_group, &outcomm);
MPI_Group_free(&high_group);
errs += MTestTestComm(outcomm);
@@ -71,7 +71,7 @@ int main(int argc, char **argv)
for (i = 0; i < size / 2; i++)
excl[i] = (2 * i) + 1;
- MPI_Group_excl(world_group, size / 2, excl, &even_group);
+ MPI_Group_excl(dup_group, size / 2, excl, &even_group);
free(excl);
if (rank % 2 == 0) {
@@ -115,7 +115,7 @@ int main(int argc, char **argv)
MPI_Comm_free(&idupcomms[i]);
}
- MPI_Group_free(&world_group);
+ MPI_Group_free(&dup_group);
MPI_Comm_free(&dupcomm);
MTest_Finalize(errs);
-----------------------------------------------------------------------
Summary of changes:
src/mpi/comm/commutil.c | 94 ---------------------------------------
test/mpi/comm/comm_idup_comm2.c | 10 ++--
2 files changed, 5 insertions(+), 99 deletions(-)
hooks/post-receive
--
MPICH primary repository
1
0
[mpich] MPICH primary repository branch, master, updated. v3.2b4-78-g6b640b5
by noreply@mpich.org 06 Aug '15
by noreply@mpich.org 06 Aug '15
06 Aug '15
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 6b640b5f0aa5886add15e38c6eb77e41196605f7 (commit)
via 541429d3685946446138c89583dceb86855cd04e (commit)
from f6277dbb69ee729c098f8ba811e4c39ad5c41bb0 (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/6b640b5f0aa5886add15e38c6eb77e411…
commit 6b640b5f0aa5886add15e38c6eb77e41196605f7
Author: Pavan Balaji <balaji(a)anl.gov>
Date: Wed Aug 5 13:02:43 2015 -0500
Minor cleanup for context_id allocation
Signed-off-by: Lena Oden <loden(a)anl.gov>
diff --git a/src/mpi/comm/commutil.c b/src/mpi/comm/commutil.c
index 4bc328d..2b6bd31 100644
--- a/src/mpi/comm/commutil.c
+++ b/src/mpi/comm/commutil.c
@@ -1015,12 +1015,12 @@ int MPIR_Get_contextid_sparse_group(MPID_Comm *comm_ptr, MPID_Group *group_ptr,
* context ID space doesn't matter. Set the mask to "all available". */
memset(local_mask, 0xff, MPIR_MAX_CONTEXT_MASK * sizeof(int));
}
+ else if (comm_ptr->idup_count && seqnum != comm_ptr->idup_next_seqnum) {
+ memset(local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
+ }
else {
MPIU_Memcpy(local_mask, context_mask, MPIR_MAX_CONTEXT_MASK * sizeof(int));
}
- if (comm_ptr->idup_count && seqnum != comm_ptr->idup_next_seqnum) {
- memset(local_mask, 0, MPIR_MAX_CONTEXT_MASK * sizeof(int));
- }
/* Note that this is the unthreaded version */
/* Comm must be an intracommunicator */
http://git.mpich.org/mpich.git/commitdiff/541429d3685946446138c89583dceb868…
commit 541429d3685946446138c89583dceb86855cd04e
Author: Pavan Balaji <balaji(a)anl.gov>
Date: Wed Aug 5 11:04:29 2015 -0500
Added a new test for duping many comms with idup.
Signed-off-by: Lena Oden <loden(a)anl.gov>
diff --git a/test/mpi/errors/comm/Makefile.am b/test/mpi/errors/comm/Makefile.am
index 598030b..5957b13 100644
--- a/test/mpi/errors/comm/Makefile.am
+++ b/test/mpi/errors/comm/Makefile.am
@@ -12,5 +12,5 @@ EXTRA_DIST = testlist
## for all programs that are just built from the single corresponding source
## file, we don't need per-target _SOURCES rules, automake will infer them
## correctly
-noinst_PROGRAMS = cfree ccreate1 manysplit userdup too_many_comms too_many_comms2 too_many_comms3
+noinst_PROGRAMS = cfree ccreate1 manysplit userdup too_many_comms too_many_comms2 too_many_comms3 too_many_icomms
diff --git a/test/mpi/errors/comm/testlist b/test/mpi/errors/comm/testlist
index 6875502..d5c58e1 100644
--- a/test/mpi/errors/comm/testlist
+++ b/test/mpi/errors/comm/testlist
@@ -3,5 +3,6 @@ ccreate1 8
userdup 4
manysplit 4
too_many_comms 4 strict=FALSE
+too_many_icomms 4 strict=FALSE
too_many_comms2 4 strict=FALSE
too_many_comms3 4 strict=FALSE
diff --git a/test/mpi/errors/comm/too_many_icomms.c b/test/mpi/errors/comm/too_many_icomms.c
new file mode 100644
index 0000000..a91d4eb
--- /dev/null
+++ b/test/mpi/errors/comm/too_many_icomms.c
@@ -0,0 +1,67 @@
+/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
+/*
+ *
+ * (C) 2015 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+/* This test attempts to create a large number of communicators, in an effort
+ * to exceed the number of communicators that the MPI implementation can
+ * provide. It checks that the implementation detects this error correctly
+ * handles it.
+ */
+
+/* In this version, we duplicate MPI_COMM_WORLD in a non-blocking
+ * fashion until we run out of context IDs. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <mpi.h>
+#include "mpitest.h"
+
+#define MAX_NCOMM 100000
+
+static const int verbose = 0;
+
+int main(int argc, char **argv)
+{
+ int rank, nproc, mpi_errno;
+ int i, ncomm;
+ int errors = 1;
+ MPI_Comm *comm_hdls;
+ MPI_Request req;
+
+ MPI_Init(&argc, &argv);
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &nproc);
+
+ MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
+ comm_hdls = malloc(sizeof(MPI_Comm) * MAX_NCOMM);
+
+
+ ncomm = 0;
+ for (i = 0; i < MAX_NCOMM; i++) {
+ /* Note: the comms we create are all dups of MPI_COMM_WORLD */
+ MPI_Comm_idup(MPI_COMM_WORLD, &comm_hdls[i], &req);
+ mpi_errno = MPI_Wait(&req,MPI_STATUSES_IGNORE);
+ if (mpi_errno == MPI_SUCCESS) {
+ ncomm++;
+ }
+ else {
+ if (verbose)
+ printf("%d: Error creating comm %d\n", rank, i);
+ errors = 0;
+ break;
+ }
+ }
+
+ for (i = 0; i < ncomm; i++)
+ MPI_Comm_free(&comm_hdls[i]);
+
+ free(comm_hdls);
+ MTest_Finalize(errors);
+ MPI_Finalize();
+
+ return 0;
+}
-----------------------------------------------------------------------
Summary of changes:
src/mpi/comm/commutil.c | 6 +++---
test/mpi/errors/comm/Makefile.am | 2 +-
test/mpi/errors/comm/testlist | 1 +
.../comm/{too_many_comms.c => too_many_icomms.c} | 12 +++++++-----
4 files changed, 12 insertions(+), 9 deletions(-)
copy test/mpi/errors/comm/{too_many_comms.c => too_many_icomms.c} (82%)
hooks/post-receive
--
MPICH primary repository
1
0