1 /* Copyright (c) 2013-2020. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
10 * (C) 2001 by Argonne National Laboratory.
11 * See COPYRIGHT in top-level directory.
15 #include "../coll_tuned_topo.hpp"
16 #include "../colls_private.hpp"
20 int barrier__mpich_smp(MPI_Comm comm)
22 int mpi_errno = MPI_SUCCESS;
23 int mpi_errno_ret = MPI_SUCCESS;
24 MPI_Comm shmem_comm = MPI_COMM_NULL, leader_comm = MPI_COMM_NULL;
27 if(comm->get_leaders_comm()==MPI_COMM_NULL){
31 shmem_comm = comm->get_intra_comm();
32 local_rank = shmem_comm->rank();
33 /* do the intranode barrier on all nodes */
34 if (shmem_comm != nullptr) {
35 mpi_errno = barrier__mpich(shmem_comm);
37 mpi_errno_ret += mpi_errno;
41 leader_comm = comm->get_leaders_comm();
42 /* do the barrier across roots of all nodes */
43 if (leader_comm != nullptr && local_rank == 0) {
44 mpi_errno = barrier__mpich(leader_comm);
46 mpi_errno_ret += mpi_errno;
50 /* release the local processes on each node with a 1-byte
51 * broadcast (0-byte broadcast just returns without doing
53 if (shmem_comm != nullptr) {
55 mpi_errno = bcast__mpich(&i, 1, MPI_BYTE, 0, shmem_comm);
57 mpi_errno_ret += mpi_errno;
62 mpi_errno = mpi_errno_ret;