1 /* Copyright (c) 2013-2017. 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 "../colls_private.h"
43 #include "../coll_tuned_topo.h"
46 int Coll_barrier_mvapich2_pair::barrier(MPI_Comm comm)
51 int mpi_errno = MPI_SUCCESS;
54 /* Trivial barriers return immediately */
60 /* N2_prev = greatest power of two < size of Comm */
61 for( N2_prev = 1; N2_prev <= size; N2_prev <<= 1 );
64 int surfeit = size - N2_prev;
66 /* Perform a combine-like operation */
69 /* get the fanin letter from the upper "half" process: */
71 Request::recv(NULL, 0, MPI_BYTE, dst, COLL_TAG_BARRIER,
72 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(NULL, 0, MPI_BYTE, dst, COLL_TAG_BARRIER, NULL,
79 0, MPI_BYTE, dst, COLL_TAG_BARRIER, comm,
83 /* fanout data to nodes above N2_prev... */
86 Request::send(NULL, 0, MPI_BYTE, dst, COLL_TAG_BARRIER,
90 /* fanin data to power of 2 subset */
92 Request::sendrecv(NULL, 0, MPI_BYTE, src, COLL_TAG_BARRIER,
93 NULL, 0, MPI_BYTE, src, COLL_TAG_BARRIER,
94 comm, MPI_STATUS_IGNORE);