This source file includes following definitions.
- mca_coll_inter_allgatherv_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_inter.h"
24
25 #include "mpi.h"
26 #include "ompi/datatype/ompi_datatype.h"
27 #include "ompi/communicator/communicator.h"
28 #include "ompi/constants.h"
29 #include "ompi/mca/coll/coll.h"
30 #include "ompi/mca/coll/base/coll_tags.h"
31 #include "ompi/mca/coll/base/coll_base_util.h"
32 #include "ompi/mca/pml/pml.h"
33
34
35
36
37
38
39
40
41
42 int
43 mca_coll_inter_allgatherv_inter(const void *sbuf, int scount,
44 struct ompi_datatype_t *sdtype,
45 void *rbuf, const int *rcounts, const int *disps,
46 struct ompi_datatype_t *rdtype,
47 struct ompi_communicator_t *comm,
48 mca_coll_base_module_t *module)
49 {
50 int i, rank, size, size_local, total=0, err;
51 int *count=NULL,*displace=NULL;
52 char *ptmp_free=NULL, *ptmp=NULL;
53 ompi_datatype_t *ndtype = NULL;
54
55 rank = ompi_comm_rank(comm);
56 size_local = ompi_comm_size(comm->c_local_comm);
57 size = ompi_comm_remote_size(comm);
58
59 if (0 == rank) {
60 count = (int *)malloc(sizeof(int) * size_local);
61 displace = (int *)malloc(sizeof(int) * size_local);
62 if ((NULL == count) || (NULL == displace)) {
63 err = OMPI_ERR_OUT_OF_RESOURCE;
64 goto exit;
65 }
66 }
67
68 err = comm->c_local_comm->c_coll->coll_gather(&scount, 1, MPI_INT,
69 count, 1, MPI_INT,
70 0, comm->c_local_comm,
71 comm->c_local_comm->c_coll->coll_gather_module);
72 if (OMPI_SUCCESS != err) {
73 goto exit;
74 }
75 if(0 == rank) {
76 displace[0] = 0;
77 for (i = 1; i < size_local; i++) {
78 displace[i] = displace[i-1] + count[i-1];
79 }
80 total = 0;
81 for (i = 0; i < size_local; i++) {
82 total = total + count[i];
83 }
84 if ( total > 0 ) {
85 ptrdiff_t gap, span;
86 span = opal_datatype_span(&sdtype->super, total, &gap);
87 ptmp_free = (char*)malloc(span);
88 if (NULL == ptmp_free) {
89 err = OMPI_ERR_OUT_OF_RESOURCE;
90 goto exit;
91 }
92 ptmp = ptmp_free - gap;
93 }
94 }
95 err = comm->c_local_comm->c_coll->coll_gatherv(sbuf, scount, sdtype,
96 ptmp, count, displace,
97 sdtype,0, comm->c_local_comm,
98 comm->c_local_comm->c_coll->coll_gatherv_module);
99 if (OMPI_SUCCESS != err) {
100 goto exit;
101 }
102
103 ompi_datatype_create_indexed(size,rcounts,disps,rdtype,&ndtype);
104 ompi_datatype_commit(&ndtype);
105
106 if (0 == rank) {
107
108 err = ompi_coll_base_sendrecv_actual(ptmp, total, sdtype, 0,
109 MCA_COLL_BASE_TAG_ALLGATHERV,
110 rbuf, 1, ndtype, 0,
111 MCA_COLL_BASE_TAG_ALLGATHERV,
112 comm, MPI_STATUS_IGNORE);
113 if (OMPI_SUCCESS != err) {
114 goto exit;
115 }
116 }
117
118
119 err = comm->c_local_comm->c_coll->coll_bcast(rbuf, 1, ndtype,
120 0, comm->c_local_comm,
121 comm->c_local_comm->c_coll->coll_bcast_module);
122 exit:
123 if( NULL != ndtype ) {
124 ompi_datatype_destroy(&ndtype);
125 }
126 if (NULL != ptmp_free) {
127 free(ptmp_free);
128 }
129 if (NULL != displace) {
130 free(displace);
131 }
132 if (NULL != count) {
133 free(count);
134 }
135
136 return err;
137
138 }