11
=== BEGIN_MPI_T_CVAR_INFO_BLOCK ===
14
- name : MPIR_CVAR_ENABLE_SMP_BARRIER
19
verbosity : MPI_T_VERBOSITY_USER_BASIC
20
scope : MPI_T_SCOPE_ALL_EQ
21
description : Enable SMP aware barrier.
23
=== END_MPI_T_CVAR_INFO_BLOCK ===
10
26
/* -- Begin Profiling Symbol Block for routine MPI_Barrier */
11
27
#if defined(HAVE_PRAGMA_WEAK)
12
28
#pragma weak MPI_Barrier = PMPI_Barrier
47
61
This is an intracommunicator barrier only!
65
#define FUNCNAME barrier_smp_intra
67
#define FCNAME MPIU_QUOTE(FUNCNAME)
68
static int barrier_smp_intra(MPID_Comm *comm_ptr, int *errflag)
70
int mpi_errno=MPI_SUCCESS;
71
int mpi_errno_ret = MPI_SUCCESS;
73
MPIU_Assert(MPIR_CVAR_ENABLE_SMP_COLLECTIVES && MPIR_CVAR_ENABLE_SMP_BARRIER &&
74
MPIR_Comm_is_node_aware(comm_ptr));
76
/* do the intranode barrier on all nodes */
77
if (comm_ptr->node_comm != NULL)
79
mpi_errno = MPIR_Barrier_impl(comm_ptr->node_comm, errflag);
81
/* for communication errors, just record the error but continue */
83
MPIU_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**fail");
84
MPIU_ERR_ADD(mpi_errno_ret, mpi_errno);
88
/* do the barrier across roots of all nodes */
89
if (comm_ptr->node_roots_comm != NULL) {
90
mpi_errno = MPIR_Barrier_impl(comm_ptr->node_roots_comm, errflag);
92
/* for communication errors, just record the error but continue */
94
MPIU_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**fail");
95
MPIU_ERR_ADD(mpi_errno_ret, mpi_errno);
99
/* release the local processes on each node with a 1-byte
100
broadcast (0-byte broadcast just returns without doing
102
if (comm_ptr->node_comm != NULL)
105
mpi_errno = MPIR_Bcast_impl(&i, 1, MPI_BYTE, 0, comm_ptr->node_comm, errflag);
107
/* for communication errors, just record the error but continue */
109
MPIU_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**fail");
110
MPIU_ERR_ADD(mpi_errno_ret, mpi_errno);
116
mpi_errno = mpi_errno_ret;
118
MPIU_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**coll_fail");
50
124
/* not declared static because it is called in ch3_comm_connect/accept */
52
126
#define FUNCNAME MPIR_Barrier_intra
66
140
/* Trivial barriers return immediately */
67
141
if (size == 1) goto fn_exit;
143
if (MPIR_CVAR_ENABLE_SMP_COLLECTIVES && MPIR_CVAR_ENABLE_SMP_BARRIER &&
144
MPIR_Comm_is_node_aware(comm_ptr)) {
145
mpi_errno = barrier_smp_intra(comm_ptr, errflag);
147
/* for communication errors, just record the error but continue */
149
MPIU_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**fail");
150
MPIU_ERR_ADD(mpi_errno_ret, mpi_errno);
69
155
rank = comm_ptr->rank;
70
156
comm = comm_ptr->handle;
73
159
while (mask < size) {
74
160
dst = (rank + mask) % size;
75
161
src = (rank - mask + size) % size;
76
mpi_errno = MPIC_Sendrecv_ft(NULL, 0, MPI_BYTE, dst,
162
mpi_errno = MPIC_Sendrecv(NULL, 0, MPI_BYTE, dst,
77
163
MPIR_BARRIER_TAG, NULL, 0, MPI_BYTE,
78
164
src, MPIR_BARRIER_TAG, comm,
79
165
MPI_STATUS_IGNORE, errflag);
100
/* A simple utility function to that calls the comm_ptr->coll_fns->Barrier
101
override if it exists or else it calls MPIR_Barrier_intra with the same arguments. */
102
/* Note that this function must *not* be inline - if weak symbols are not
103
available, this function must be a global symbol. */
105
#define FUNCNAME MPIR_Barrier_or_coll_fn
107
#define FCNAME MPIU_QUOTE(FUNCNAME)
108
PMPI_LOCAL int MPIR_Barrier_or_coll_fn(MPID_Comm *comm_ptr, int *errflag )
110
int mpi_errno = MPI_SUCCESS;
112
if (comm_ptr->coll_fns != NULL && comm_ptr->coll_fns->Barrier != NULL)
114
/* --BEGIN USEREXTENSION-- */
115
mpi_errno = comm_ptr->coll_fns->Barrier(comm_ptr, errflag);
116
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
117
/* --END USEREXTENSION-- */
120
mpi_errno = MPIR_Barrier_intra(comm_ptr, errflag);
121
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
131
186
/* not declared static because a machine-specific function may call this one
272
if (comm_ptr->comm_kind == MPID_INTRACOMM) {
273
#if defined(USE_SMP_COLLECTIVES)
274
if (MPIR_Comm_is_node_aware(comm_ptr)) {
276
/* do the intranode barrier on all nodes */
277
if (comm_ptr->node_comm != NULL)
279
mpi_errno = MPIR_Barrier_or_coll_fn(comm_ptr->node_comm, errflag);
281
/* for communication errors, just record the error but continue */
283
MPIU_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**fail");
284
MPIU_ERR_ADD(mpi_errno_ret, mpi_errno);
288
/* do the barrier across roots of all nodes */
289
if (comm_ptr->node_roots_comm != NULL) {
290
mpi_errno = MPIR_Barrier_or_coll_fn(comm_ptr->node_roots_comm, errflag);
292
/* for communication errors, just record the error but continue */
294
MPIU_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**fail");
295
MPIU_ERR_ADD(mpi_errno_ret, mpi_errno);
299
/* release the local processes on each node with a 1-byte broadcast
300
(0-byte broadcast just returns without doing anything) */
301
if (comm_ptr->node_comm != NULL)
304
mpi_errno = MPIR_Bcast_impl(&i, 1, MPI_BYTE, 0, comm_ptr->node_comm, errflag);
306
/* for communication errors, just record the error but continue */
308
MPIU_ERR_SET(mpi_errno, MPI_ERR_OTHER, "**fail");
309
MPIU_ERR_ADD(mpi_errno_ret, mpi_errno);
314
mpi_errno = MPIR_Barrier_intra( comm_ptr, errflag );
315
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
318
mpi_errno = MPIR_Barrier_intra( comm_ptr, errflag );
319
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
323
/* intercommunicator */
324
mpi_errno = MPIR_Barrier_inter( comm_ptr, errflag );
325
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
327
mpi_errno = MPIR_Barrier(comm_ptr, errflag);
328
if (mpi_errno) MPIU_ERR_POP(mpi_errno);