This source file includes following definitions.
- mca_coll_basic_gatherv_intra
- mca_coll_basic_gatherv_inter
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include "ompi_config.h"
23 #include "coll_basic.h"
24
25 #include "mpi.h"
26 #include "ompi/constants.h"
27 #include "ompi/datatype/ompi_datatype.h"
28 #include "ompi/mca/coll/coll.h"
29 #include "ompi/mca/coll/base/coll_tags.h"
30 #include "ompi/mca/pml/pml.h"
31
32
33
34
35
36
37
38
39 int
40 mca_coll_basic_gatherv_intra(const void *sbuf, int scount,
41 struct ompi_datatype_t *sdtype,
42 void *rbuf, const int *rcounts, const int *disps,
43 struct ompi_datatype_t *rdtype, int root,
44 struct ompi_communicator_t *comm,
45 mca_coll_base_module_t *module)
46 {
47 int i, rank, size, err;
48 char *ptmp;
49 ptrdiff_t lb, extent;
50
51 size = ompi_comm_size(comm);
52 rank = ompi_comm_rank(comm);
53
54
55
56
57
58
59
60 if (rank != root) {
61 if (scount > 0) {
62 return MCA_PML_CALL(send(sbuf, scount, sdtype, root,
63 MCA_COLL_BASE_TAG_GATHERV,
64 MCA_PML_BASE_SEND_STANDARD, comm));
65 }
66 return MPI_SUCCESS;
67 }
68
69
70
71 err = ompi_datatype_get_extent(rdtype, &lb, &extent);
72 if (OMPI_SUCCESS != err) {
73 return OMPI_ERROR;
74 }
75
76 for (i = 0; i < size; ++i) {
77 ptmp = ((char *) rbuf) + (extent * disps[i]);
78
79 if (i == rank) {
80
81 if (MPI_IN_PLACE != sbuf && (0 < scount) && (0 < rcounts[i])) {
82 err = ompi_datatype_sndrcv(sbuf, scount, sdtype,
83 ptmp, rcounts[i], rdtype);
84 }
85 } else {
86
87 if (rcounts[i] > 0) {
88 err = MCA_PML_CALL(recv(ptmp, rcounts[i], rdtype, i,
89 MCA_COLL_BASE_TAG_GATHERV,
90 comm, MPI_STATUS_IGNORE));
91 }
92 }
93
94 if (MPI_SUCCESS != err) {
95 return err;
96 }
97 }
98
99
100
101 return MPI_SUCCESS;
102 }
103
104
105
106
107
108
109
110
111
112 int
113 mca_coll_basic_gatherv_inter(const void *sbuf, int scount,
114 struct ompi_datatype_t *sdtype,
115 void *rbuf, const int *rcounts, const int *disps,
116 struct ompi_datatype_t *rdtype, int root,
117 struct ompi_communicator_t *comm,
118 mca_coll_base_module_t *module)
119 {
120 int i, size, err;
121 char *ptmp;
122 ptrdiff_t lb, extent;
123 ompi_request_t **reqs = NULL;
124
125 size = ompi_comm_remote_size(comm);
126
127
128
129
130 if (MPI_PROC_NULL == root) {
131
132 err = OMPI_SUCCESS;
133 } else if (MPI_ROOT != root) {
134
135 err = MCA_PML_CALL(send(sbuf, scount, sdtype, root,
136 MCA_COLL_BASE_TAG_GATHERV,
137 MCA_PML_BASE_SEND_STANDARD, comm));
138 } else {
139
140 err = ompi_datatype_get_extent(rdtype, &lb, &extent);
141 if (OMPI_SUCCESS != err) {
142 return OMPI_ERROR;
143 }
144
145 reqs = ompi_coll_base_comm_get_reqs(module->base_data, size);
146 if( NULL == reqs ) { return OMPI_ERR_OUT_OF_RESOURCE; }
147
148 for (i = 0; i < size; ++i) {
149 ptmp = ((char *) rbuf) + (extent * disps[i]);
150 err = MCA_PML_CALL(irecv(ptmp, rcounts[i], rdtype, i,
151 MCA_COLL_BASE_TAG_GATHERV,
152 comm, &reqs[i]));
153 if (OMPI_SUCCESS != err) {
154 ompi_coll_base_free_reqs(reqs, i + 1);
155 return err;
156 }
157 }
158
159 err = ompi_request_wait_all(size, reqs, MPI_STATUSES_IGNORE);
160 if (OMPI_SUCCESS != err) {
161 ompi_coll_base_free_reqs(reqs, size);
162 }
163 }
164
165
166 return err;
167 }