This source file includes following definitions.
- MPI_Ireduce
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #include "ompi_config.h"
26 #include <stdio.h>
27
28 #include "ompi/mpi/c/bindings.h"
29 #include "ompi/runtime/params.h"
30 #include "ompi/communicator/communicator.h"
31 #include "ompi/errhandler/errhandler.h"
32 #include "ompi/datatype/ompi_datatype.h"
33 #include "ompi/op/op.h"
34 #include "ompi/memchecker.h"
35 #include "ompi/runtime/ompi_spc.h"
36
37 #if OMPI_BUILD_MPI_PROFILING
38 #if OPAL_HAVE_WEAK_SYMBOLS
39 #pragma weak MPI_Ireduce = PMPI_Ireduce
40 #endif
41 #define MPI_Ireduce PMPI_Ireduce
42 #endif
43
44 static const char FUNC_NAME[] = "MPI_Ireduce";
45
46
47 int MPI_Ireduce(const void *sendbuf, void *recvbuf, int count,
48 MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm, MPI_Request *request)
49 {
50 int err;
51
52 SPC_RECORD(OMPI_SPC_IREDUCE, 1);
53
54 MEMCHECKER(
55 memchecker_datatype(datatype);
56 memchecker_comm(comm);
57
58 if(OMPI_COMM_IS_INTRA(comm)) {
59 if(ompi_comm_rank(comm) == root) {
60
61 if (MPI_IN_PLACE == sendbuf) {
62 memchecker_call(&opal_memchecker_base_isdefined, recvbuf, count, datatype);
63 } else {
64 memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
65 }
66
67
68 memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, count, datatype);
69 } else {
70
71 memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
72 }
73 } else {
74 if (MPI_ROOT == root) {
75
76 memchecker_call(&opal_memchecker_base_isaddressable, recvbuf, count, datatype);
77 } else if (MPI_PROC_NULL != root) {
78
79 memchecker_call(&opal_memchecker_base_isdefined, sendbuf, count, datatype);
80 }
81 }
82 );
83
84 if (MPI_PARAM_CHECK) {
85 char *msg;
86 err = MPI_SUCCESS;
87 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
88 if (ompi_comm_invalid(comm)) {
89 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
90 FUNC_NAME);
91 }
92
93
94
95 else if (MPI_OP_NULL == op || NULL == op) {
96 err = MPI_ERR_OP;
97 } else if (!ompi_op_is_valid(op, datatype, &msg, FUNC_NAME)) {
98 int ret = OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_OP, msg);
99 free(msg);
100 return ret;
101 } else if ((ompi_comm_rank(comm) != root && MPI_IN_PLACE == sendbuf) ||
102 (ompi_comm_rank(comm) == root && ((MPI_IN_PLACE == recvbuf) || (sendbuf == recvbuf)))) {
103 err = MPI_ERR_ARG;
104 } else {
105 OMPI_CHECK_DATATYPE_FOR_SEND(err, datatype, count);
106 }
107 OMPI_ERRHANDLER_CHECK(err, comm, err, FUNC_NAME);
108
109
110
111 if (!OMPI_COMM_IS_INTRA(comm)) {
112 if (! ((root >= 0 && root < ompi_comm_remote_size(comm)) ||
113 MPI_ROOT == root || MPI_PROC_NULL == root)) {
114 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
115 }
116 }
117
118
119
120 else {
121 if (root < 0 || root >= ompi_comm_size(comm)) {
122 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ROOT, FUNC_NAME);
123 }
124 }
125 }
126
127
128
129
130
131 if (0 == count) {
132 *request = &ompi_request_empty;
133 return MPI_SUCCESS;
134 }
135
136 OPAL_CR_ENTER_LIBRARY();
137
138
139 OBJ_RETAIN(op);
140 err = comm->c_coll->coll_ireduce(sendbuf, recvbuf, count,
141 datatype, op, root, comm, request,
142 comm->c_coll->coll_ireduce_module);
143 OBJ_RELEASE(op);
144 OMPI_ERRHANDLER_RETURN(err, comm, err, FUNC_NAME);
145 }