This source file includes following definitions.
- NBC_Ineighbor_alltoallw_args_compare
- nbc_neighbor_alltoallw_init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 #include "nbc_internal.h"
22
23
24 #undef NBC_CACHE_SCHEDULE
25
26 #ifdef NBC_CACHE_SCHEDULE
27
28 int NBC_Ineighbor_alltoallw_args_compare(NBC_Ineighbor_alltoallw_args *a, NBC_Ineighbor_alltoallw_args *b, void *param) {
29 if ((a->sbuf == b->sbuf) &&
30 (a->scount == b->scount) &&
31 (a->stype == b->stype) &&
32 (a->rbuf == b->rbuf) &&
33 (a->rcount == b->rcount) &&
34 (a->rtype == b->rtype)) {
35 return 0;
36 }
37
38 if (a->sbuf < b->sbuf) {
39 return -1;
40 }
41
42 return 1;
43 }
44 #endif
45
46 static int nbc_neighbor_alltoallw_init(const void *sbuf, const int *scounts, const MPI_Aint *sdisps, struct ompi_datatype_t * const *stypes,
47 void *rbuf, const int *rcounts, const MPI_Aint *rdisps, struct ompi_datatype_t * const *rtypes,
48 struct ompi_communicator_t *comm, ompi_request_t ** request,
49 struct mca_coll_base_module_2_3_0_t *module, bool persistent) {
50 int res, indegree, outdegree, *srcs, *dsts;
51 ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
52 NBC_Schedule *schedule;
53
54 #ifdef NBC_CACHE_SCHEDULE
55 NBC_Ineighbor_alltoallw_args *args, *found, search;
56
57
58 search.sbuf = sbuf;
59 search.scount = scount;
60 search.stype = stype;
61 search.rbuf = rbuf;
62 search.rcount = rcount;
63 search.rtype = rtype;
64 found = (NBC_Ineighbor_alltoallw_args *) hb_tree_search ((hb_tree *) libnbc_module->NBC_Dict[NBC_NEIGHBOR_ALLTOALLW],
65 &search);
66 if(found == NULL) {
67 #endif
68 schedule = OBJ_NEW(NBC_Schedule);
69 if (OPAL_UNLIKELY(NULL == schedule)) {
70 return OMPI_ERR_OUT_OF_RESOURCE;
71 }
72
73 res = NBC_Comm_neighbors (comm, &srcs, &indegree, &dsts, &outdegree);
74 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
75 OBJ_RELEASE(schedule);
76 return res;
77 }
78
79
80 for (int i = 0 ; i < indegree ; ++i) {
81 if (srcs[i] != MPI_PROC_NULL) {
82 res = NBC_Sched_recv ((char *) rbuf + rdisps[i], false, rcounts[i], rtypes[i], srcs[i], schedule, false);
83 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
84 break;
85 }
86 }
87 }
88
89 free (srcs);
90
91 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
92 free (dsts);
93 OBJ_RELEASE(schedule);
94 return res;
95 }
96
97 for (int i = 0 ; i < outdegree ; ++i) {
98 if (dsts[i] != MPI_PROC_NULL) {
99 res = NBC_Sched_send ((char *) sbuf + sdisps[i], false, scounts[i], stypes[i], dsts[i], schedule, false);
100 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
101 break;
102 }
103 }
104 }
105
106 free (dsts);
107
108 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
109 OBJ_RELEASE(schedule);
110 return res;
111 }
112
113 res = NBC_Sched_commit(schedule);
114 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
115 OBJ_RELEASE(schedule);
116 return res;
117 }
118
119 #ifdef NBC_CACHE_SCHEDULE
120
121 args = (NBC_Ineighbor_alltoallw_args *) malloc (sizeof (args));
122 if (NULL != args) {
123 args->sbuf = sbuf;
124 args->scount = scount;
125 args->stype = stype;
126 args->rbuf = rbuf;
127 args->rcount = rcount;
128 args->rtype = rtype;
129 args->schedule = schedule;
130 res = hb_tree_insert ((hb_tree *) libnbc_module->NBC_Dict[NBC_NEIGHBOR_ALLTOALLW], args, args, 0);
131 if (0 == res) {
132 OBJ_RETAIN(schedule);
133
134
135 if (++libnbc_module->NBC_Dict_size[NBC_NEIGHBOR_ALLTOALLW] > NBC_SCHED_DICT_UPPER) {
136 NBC_SchedCache_dictwipe ((hb_tree *) libnbc_module->NBC_Dict[NBC_NEIGHBOR_ALLTOALLW],
137 &libnbc_module->NBC_Dict_size[NBC_NEIGHBOR_ALLTOALLW]);
138 }
139 } else {
140 NBC_Error("error in dict_insert() (%i)", res);
141 free (args);
142 }
143 } else {
144
145 schedule = found->schedule;
146 OBJ_RETAIN(schedule);
147 }
148 #endif
149
150 res = NBC_Schedule_request(schedule, comm, libnbc_module, persistent, request, NULL);
151 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
152 OBJ_RELEASE(schedule);
153 return res;
154 }
155
156 return OMPI_SUCCESS;
157 }
158
159 int ompi_coll_libnbc_ineighbor_alltoallw(const void *sbuf, const int *scounts, const MPI_Aint *sdisps, struct ompi_datatype_t * const *stypes,
160 void *rbuf, const int *rcounts, const MPI_Aint *rdisps, struct ompi_datatype_t * const *rtypes,
161 struct ompi_communicator_t *comm, ompi_request_t ** request,
162 struct mca_coll_base_module_2_3_0_t *module) {
163 int res = nbc_neighbor_alltoallw_init(sbuf, scounts, sdisps, stypes, rbuf, rcounts, rdisps, rtypes,
164 comm, request, module, false);
165 if (OPAL_LIKELY(OMPI_SUCCESS != res)) {
166 return res;
167 }
168 res = NBC_Start(*(ompi_coll_libnbc_request_t **)request);
169 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
170 NBC_Return_handle (*(ompi_coll_libnbc_request_t **)request);
171 *request = &ompi_request_null.request;
172 return res;
173 }
174
175 return OMPI_SUCCESS;
176 }
177
178 int ompi_coll_libnbc_neighbor_alltoallw_init(const void *sbuf, const int *scounts, const MPI_Aint *sdisps, struct ompi_datatype_t * const *stypes,
179 void *rbuf, const int *rcounts, const MPI_Aint *rdisps, struct ompi_datatype_t * const *rtypes,
180 struct ompi_communicator_t *comm, MPI_Info info, ompi_request_t ** request,
181 struct mca_coll_base_module_2_3_0_t *module) {
182 int res = nbc_neighbor_alltoallw_init(sbuf, scounts, sdisps, stypes, rbuf, rcounts, rdisps, rtypes,
183 comm, request, module, true);
184 if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
185 return res;
186 }
187
188 return OMPI_SUCCESS;
189 }