1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2017 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2006-2007 University of Houston. All rights reserved.
13 * Copyright (c) 2013 Cisco Systems, Inc. All rights reserved.
14 * $COPYRIGHT$
15 *
16 * Additional copyrights may follow
17 *
18 * $HEADER$
19 */
20
21 #include "ompi_config.h"
22 #include "coll_inter.h"
23
24 #include "mpi.h"
25 #include "ompi/constants.h"
26 #include "ompi/communicator/communicator.h"
27 #include "ompi/mca/coll/coll.h"
28 #include "ompi/mca/coll/base/coll_tags.h"
29 #include "ompi/mca/pml/pml.h"
30
31
32 /*
33 * bcast_inter
34 *
35 * Function: - broadcast using the local_comm
36 * Accepts: - same arguments as MPI_Bcast()
37 * Returns: - MPI_SUCCESS or error code
38 */
39 int
40 mca_coll_inter_bcast_inter(void *buff, int count,
41 struct ompi_datatype_t *datatype, int root,
42 struct ompi_communicator_t *comm,
43 mca_coll_base_module_t *module)
44 {
45 int rank;
46 int err;
47
48 rank = ompi_comm_rank(comm);
49
50 if (MPI_PROC_NULL == root) {
51 /* do nothing */
52 err = OMPI_SUCCESS;
53 } else if (MPI_ROOT != root) {
54 /* Non-root, first process recieves the data and bcast to others */
55 if ( 0 == rank ) {
56 err = MCA_PML_CALL(recv(buff, count, datatype, root,
57 MCA_COLL_BASE_TAG_BCAST, comm,
58 MPI_STATUS_IGNORE));
59 if (OMPI_SUCCESS != err) {
60 return err;
61 }
62 }
63 err = comm->c_local_comm->c_coll->coll_bcast(buff, count, datatype, 0,
64 comm->c_local_comm,
65 comm->c_local_comm->c_coll->coll_bcast_module);
66 } else {
67 /* root section, send to the first process of the remote group */
68 err = MCA_PML_CALL(send(buff, count, datatype, 0,
69 MCA_COLL_BASE_TAG_BCAST,
70 MCA_PML_BASE_SEND_STANDARD,
71 comm));
72 if (OMPI_SUCCESS != err) {
73 return err;
74 }
75 }
76
77 /* All done */
78 return err;
79 }
80