1 /* Copyright (c) 2013-2023. 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. */
8 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
9 * University Research and Technology
10 * Corporation. All rights reserved.
11 * Copyright (c) 2004-2006 The University of Tennessee and The University
12 * of Tennessee Research Foundation. All rights
14 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
15 * University of Stuttgart. All rights reserved.
16 * Copyright (c) 2004-2005 The Regents of the University of California.
17 * All rights reserved.
18 * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
20 * Additional copyrights may follow
23 /* -*- Mode: C; c-basic-offset:4 ; -*- */
26 * (C) 2001 by Argonne National Laboratory.
27 * See COPYRIGHT in top-level directory.
30 /* Copyright (c) 2001-2014, The Ohio State University. All rights
33 * This file is part of the MVAPICH2 software package developed by the
34 * team members of The Ohio State University's Network-Based Computing
35 * Laboratory (NBCL), headed by Professor Dhabaleswar K. (DK) Panda.
37 * For detailed copyright and licensing information, please refer to the
38 * copyright file COPYRIGHT in the top level MVAPICH2 directory.
42 #include "../coll_tuned_topo.hpp"
43 #include "../colls_private.hpp"
44 #include "smpi_actor.hpp"
45 namespace simgrid::smpi {
46 int barrier__mvapich2_pair(MPI_Comm comm)
51 int mpi_errno = MPI_SUCCESS;
52 int tag = smpi_process()->finalizing() ? COLL_TAG_BARRIER-1: COLL_TAG_BARRIER;
55 /* Trivial barriers return immediately */
61 /* N2_prev = greatest power of two < size of Comm */
62 for( N2_prev = 1; N2_prev <= size; N2_prev <<= 1 );
65 int surfeit = size - N2_prev;
67 /* Perform a combine-like operation */
70 /* get the fanin letter from the upper "half" process: */
72 Request::recv(nullptr, 0, MPI_BYTE, dst, tag, comm, MPI_STATUS_IGNORE);
75 /* combine on embedded N2_prev power-of-two processes */
76 for (d = 1; d < N2_prev; d <<= 1) {
78 Request::sendrecv(nullptr, 0, MPI_BYTE, dst, tag, nullptr, 0, MPI_BYTE, dst, tag,
79 comm, MPI_STATUS_IGNORE);
82 /* fanout data to nodes above N2_prev... */
85 Request::send(nullptr, 0, MPI_BYTE, dst, tag, comm);
88 /* fanin data to power of 2 subset */
90 Request::sendrecv(nullptr, 0, MPI_BYTE, src, tag, nullptr, 0, MPI_BYTE, src, tag,
91 comm, MPI_STATUS_IGNORE);
98 } // namespace simgrid::smpi