This source file includes following definitions.
- MPI_Bcast
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include "ompi_config.h"
21 #include <stdio.h>
22
23 #include "ompi/mpi/c/bindings.h"
24 #include "ompi/runtime/params.h"
25 #include "ompi/communicator/communicator.h"
26 #include "ompi/errhandler/errhandler.h"
27 #include "ompi/datatype/ompi_datatype.h"
28 #include "ompi/memchecker.h"
29 #include "ompi/runtime/ompi_spc.h"
30
31 #if OMPI_BUILD_MPI_PROFILING
32 #if OPAL_HAVE_WEAK_SYMBOLS
33 #pragma weak MPI_Bcast = PMPI_Bcast
34 #endif
35 #define MPI_Bcast PMPI_Bcast
36 #endif
37
38 static const char FUNC_NAME[] = "MPI_Bcast";
39
40
41 int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype,
42 int root, MPI_Comm comm)
43 {
44 int err;
45
46 SPC_RECORD(OMPI_SPC_BCAST, 1);
47
48 MEMCHECKER(
49 memchecker_datatype(datatype);
50 memchecker_comm(comm);
51 if (OMPI_COMM_IS_INTRA(comm)) {
52 if (ompi_comm_rank(comm) == root) {
53
54 memchecker_call(&opal_memchecker_base_isdefined, buffer, count, datatype);
55 }
56
57 memchecker_call(&opal_memchecker_base_isaddressable, buffer, count, datatype);
58 } else {
59 if (MPI_ROOT == root) {
60
61 memchecker_call(&opal_memchecker_base_isdefined, buffer, count, datatype);
62 } else if (MPI_PROC_NULL != root) {
63
64 memchecker_call(&opal_memchecker_base_isaddressable, buffer, count, datatype);
65 }
66 }
67 );
68
69 if (MPI_PARAM_CHECK) {
70 err = MPI_SUCCESS;
71 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
72 if (ompi_comm_invalid(comm)) {
73 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
74 FUNC_NAME);
75 }
76
77
78
79 OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count);
80 OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
81 if (MPI_IN_PLACE == buffer) {
82 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG, FUNC_NAME);
83 }
84
85
86
87 if (OMPI_COMM_IS_INTRA(comm)) {
88 if ((root >= ompi_comm_size(comm)) || (root < 0)) {
89 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
90 }
91 }
92
93
94
95 else {
96 if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) ||
97 MPI_ROOT == root || MPI_PROC_NULL == root)) {
98 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
99 }
100 }
101 }
102
103
104
105 if ((OMPI_COMM_IS_INTRA(comm) && ompi_comm_size(comm) <= 1) ||
106 0 == count) {
107 return MPI_SUCCESS;
108 }
109
110 OPAL_CR_ENTER_LIBRARY();
111
112
113
114 err = comm->c_coll->coll_bcast(buffer, count, datatype, root, comm,
115 comm->c_coll->coll_bcast_module);
116 OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
117 }