1 /* Copyright (c) 2013-2022. 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"
18 namespace simgrid::smpi {
19 int barrier__mpich_smp(MPI_Comm comm)
21 int mpi_errno = MPI_SUCCESS;
22 int mpi_errno_ret = MPI_SUCCESS;
23 MPI_Comm shmem_comm = MPI_COMM_NULL, leader_comm = MPI_COMM_NULL;
26 if(comm->get_leaders_comm()==MPI_COMM_NULL){
30 shmem_comm = comm->get_intra_comm();
31 local_rank = shmem_comm->rank();
32 /* do the intranode barrier on all nodes */
33 if (shmem_comm != nullptr) {
34 mpi_errno = barrier__mpich(shmem_comm);
36 mpi_errno_ret += mpi_errno;
40 leader_comm = comm->get_leaders_comm();
41 /* do the barrier across roots of all nodes */
42 if (leader_comm != nullptr && local_rank == 0) {
43 mpi_errno = barrier__mpich(leader_comm);
45 mpi_errno_ret += mpi_errno;
49 /* release the local processes on each node with a 1-byte
50 * broadcast (0-byte broadcast just returns without doing
52 if (shmem_comm != nullptr) {
54 mpi_errno = bcast__mpich(&i, 1, MPI_BYTE, 0, shmem_comm);
56 mpi_errno_ret += mpi_errno;
61 mpi_errno = mpi_errno_ret;
65 } // namespace simgrid::smpi