This source file includes following definitions.
- ompi_osc_sm_rput
- ompi_osc_sm_rget
- ompi_osc_sm_raccumulate
- ompi_osc_sm_rget_accumulate
- ompi_osc_sm_put
- ompi_osc_sm_get
- ompi_osc_sm_accumulate
- ompi_osc_sm_get_accumulate
- ompi_osc_sm_compare_and_swap
- ompi_osc_sm_fetch_and_op
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #include "ompi_config.h"
16
17 #include "ompi/mca/osc/osc.h"
18 #include "ompi/mca/osc/base/base.h"
19 #include "ompi/mca/osc/base/osc_base_obj_convert.h"
20
21 #include "osc_sm.h"
22
23 int
24 ompi_osc_sm_rput(const void *origin_addr,
25 int origin_count,
26 struct ompi_datatype_t *origin_dt,
27 int target,
28 ptrdiff_t target_disp,
29 int target_count,
30 struct ompi_datatype_t *target_dt,
31 struct ompi_win_t *win,
32 struct ompi_request_t **ompi_req)
33 {
34 int ret;
35 ompi_osc_sm_module_t *module =
36 (ompi_osc_sm_module_t*) win->w_osc_module;
37 void *remote_address;
38
39 OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
40 "rput: 0x%lx, %d, %s, %d, %d, %d, %s, 0x%lx",
41 (unsigned long) origin_addr, origin_count,
42 origin_dt->name, target, (int) target_disp,
43 target_count, target_dt->name,
44 (unsigned long) win));
45
46 remote_address = ((char*) (module->bases[target])) + module->disp_units[target] * target_disp;
47
48 ret = ompi_datatype_sndrcv((void *)origin_addr, origin_count, origin_dt,
49 remote_address, target_count, target_dt);
50 if (OMPI_SUCCESS != ret) {
51 return ret;
52 }
53
54
55
56
57 *ompi_req = &ompi_request_empty;
58
59 return OMPI_SUCCESS;
60 }
61
62
63 int
64 ompi_osc_sm_rget(void *origin_addr,
65 int origin_count,
66 struct ompi_datatype_t *origin_dt,
67 int target,
68 ptrdiff_t target_disp,
69 int target_count,
70 struct ompi_datatype_t *target_dt,
71 struct ompi_win_t *win,
72 struct ompi_request_t **ompi_req)
73 {
74 int ret;
75 ompi_osc_sm_module_t *module =
76 (ompi_osc_sm_module_t*) win->w_osc_module;
77 void *remote_address;
78
79 OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
80 "rget: 0x%lx, %d, %s, %d, %d, %d, %s, 0x%lx",
81 (unsigned long) origin_addr, origin_count,
82 origin_dt->name, target, (int) target_disp,
83 target_count, target_dt->name,
84 (unsigned long) win));
85
86 remote_address = ((char*) (module->bases[target])) + module->disp_units[target] * target_disp;
87
88 ret = ompi_datatype_sndrcv(remote_address, target_count, target_dt,
89 origin_addr, origin_count, origin_dt);
90 if (OMPI_SUCCESS != ret) {
91 return ret;
92 }
93
94
95
96
97 *ompi_req = &ompi_request_empty;
98
99 return OMPI_SUCCESS;
100 }
101
102
103 int
104 ompi_osc_sm_raccumulate(const void *origin_addr,
105 int origin_count,
106 struct ompi_datatype_t *origin_dt,
107 int target,
108 ptrdiff_t target_disp,
109 int target_count,
110 struct ompi_datatype_t *target_dt,
111 struct ompi_op_t *op,
112 struct ompi_win_t *win,
113 struct ompi_request_t **ompi_req)
114 {
115 int ret;
116 ompi_osc_sm_module_t *module =
117 (ompi_osc_sm_module_t*) win->w_osc_module;
118 void *remote_address;
119
120 OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
121 "raccumulate: 0x%lx, %d, %s, %d, %d, %d, %s, %s, 0x%lx",
122 (unsigned long) origin_addr, origin_count,
123 origin_dt->name, target, (int) target_disp,
124 target_count, target_dt->name,
125 op->o_name,
126 (unsigned long) win));
127
128 remote_address = ((char*) (module->bases[target])) + module->disp_units[target] * target_disp;
129
130 opal_atomic_lock(&module->node_states[target].accumulate_lock);
131 if (op == &ompi_mpi_op_replace.op) {
132 ret = ompi_datatype_sndrcv((void *)origin_addr, origin_count, origin_dt,
133 remote_address, target_count, target_dt);
134 } else {
135 ret = ompi_osc_base_sndrcv_op(origin_addr, origin_count, origin_dt,
136 remote_address, target_count, target_dt,
137 op);
138 }
139 opal_atomic_unlock(&module->node_states[target].accumulate_lock);
140
141
142
143
144 *ompi_req = &ompi_request_empty;
145
146 return ret;
147 }
148
149
150
151 int
152 ompi_osc_sm_rget_accumulate(const void *origin_addr,
153 int origin_count,
154 struct ompi_datatype_t *origin_dt,
155 void *result_addr,
156 int result_count,
157 struct ompi_datatype_t *result_dt,
158 int target,
159 MPI_Aint target_disp,
160 int target_count,
161 struct ompi_datatype_t *target_dt,
162 struct ompi_op_t *op,
163 struct ompi_win_t *win,
164 struct ompi_request_t **ompi_req)
165 {
166 int ret;
167 ompi_osc_sm_module_t *module =
168 (ompi_osc_sm_module_t*) win->w_osc_module;
169 void *remote_address;
170
171 OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
172 "rget_accumulate: 0x%lx, %d, %s, %d, %d, %d, %s, %s, 0x%lx",
173 (unsigned long) origin_addr, origin_count,
174 origin_dt->name, target, (int) target_disp,
175 target_count, target_dt->name,
176 op->o_name,
177 (unsigned long) win));
178
179 remote_address = ((char*) (module->bases[target])) + module->disp_units[target] * target_disp;
180
181 opal_atomic_lock(&module->node_states[target].accumulate_lock);
182
183 ret = ompi_datatype_sndrcv(remote_address, target_count, target_dt,
184 result_addr, result_count, result_dt);
185 if (OMPI_SUCCESS != ret || op == &ompi_mpi_op_no_op.op) goto done;
186
187 if (op == &ompi_mpi_op_replace.op) {
188 ret = ompi_datatype_sndrcv((void *)origin_addr, origin_count, origin_dt,
189 remote_address, target_count, target_dt);
190 } else {
191 ret = ompi_osc_base_sndrcv_op(origin_addr, origin_count, origin_dt,
192 remote_address, target_count, target_dt,
193 op);
194 }
195
196 done:
197 opal_atomic_unlock(&module->node_states[target].accumulate_lock);
198
199
200
201
202 *ompi_req = &ompi_request_empty;
203
204 return ret;
205 }
206
207
208 int
209 ompi_osc_sm_put(const void *origin_addr,
210 int origin_count,
211 struct ompi_datatype_t *origin_dt,
212 int target,
213 ptrdiff_t target_disp,
214 int target_count,
215 struct ompi_datatype_t *target_dt,
216 struct ompi_win_t *win)
217 {
218 int ret;
219 ompi_osc_sm_module_t *module =
220 (ompi_osc_sm_module_t*) win->w_osc_module;
221 void *remote_address;
222
223 OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
224 "put: 0x%lx, %d, %s, %d, %d, %d, %s, 0x%lx",
225 (unsigned long) origin_addr, origin_count,
226 origin_dt->name, target, (int) target_disp,
227 target_count, target_dt->name,
228 (unsigned long) win));
229
230 remote_address = ((char*) (module->bases[target])) + module->disp_units[target] * target_disp;
231
232 ret = ompi_datatype_sndrcv((void *)origin_addr, origin_count, origin_dt,
233 remote_address, target_count, target_dt);
234
235 return ret;
236 }
237
238
239 int
240 ompi_osc_sm_get(void *origin_addr,
241 int origin_count,
242 struct ompi_datatype_t *origin_dt,
243 int target,
244 ptrdiff_t target_disp,
245 int target_count,
246 struct ompi_datatype_t *target_dt,
247 struct ompi_win_t *win)
248 {
249 int ret;
250 ompi_osc_sm_module_t *module =
251 (ompi_osc_sm_module_t*) win->w_osc_module;
252 void *remote_address;
253
254 OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
255 "get: 0x%lx, %d, %s, %d, %d, %d, %s, 0x%lx",
256 (unsigned long) origin_addr, origin_count,
257 origin_dt->name, target, (int) target_disp,
258 target_count, target_dt->name,
259 (unsigned long) win));
260
261 remote_address = ((char*) (module->bases[target])) + module->disp_units[target] * target_disp;
262
263 ret = ompi_datatype_sndrcv(remote_address, target_count, target_dt,
264 origin_addr, origin_count, origin_dt);
265
266 return ret;
267 }
268
269
270 int
271 ompi_osc_sm_accumulate(const void *origin_addr,
272 int origin_count,
273 struct ompi_datatype_t *origin_dt,
274 int target,
275 ptrdiff_t target_disp,
276 int target_count,
277 struct ompi_datatype_t *target_dt,
278 struct ompi_op_t *op,
279 struct ompi_win_t *win)
280 {
281 int ret;
282 ompi_osc_sm_module_t *module =
283 (ompi_osc_sm_module_t*) win->w_osc_module;
284 void *remote_address;
285
286 OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
287 "accumulate: 0x%lx, %d, %s, %d, %d, %d, %s, %s, 0x%lx",
288 (unsigned long) origin_addr, origin_count,
289 origin_dt->name, target, (int) target_disp,
290 target_count, target_dt->name,
291 op->o_name,
292 (unsigned long) win));
293
294 remote_address = ((char*) (module->bases[target])) + module->disp_units[target] * target_disp;
295
296 opal_atomic_lock(&module->node_states[target].accumulate_lock);
297 if (op == &ompi_mpi_op_replace.op) {
298 ret = ompi_datatype_sndrcv((void *)origin_addr, origin_count, origin_dt,
299 remote_address, target_count, target_dt);
300 } else {
301 ret = ompi_osc_base_sndrcv_op(origin_addr, origin_count, origin_dt,
302 remote_address, target_count, target_dt,
303 op);
304 }
305 opal_atomic_unlock(&module->node_states[target].accumulate_lock);
306
307 return ret;
308 }
309
310
311 int
312 ompi_osc_sm_get_accumulate(const void *origin_addr,
313 int origin_count,
314 struct ompi_datatype_t *origin_dt,
315 void *result_addr,
316 int result_count,
317 struct ompi_datatype_t *result_dt,
318 int target,
319 MPI_Aint target_disp,
320 int target_count,
321 struct ompi_datatype_t *target_dt,
322 struct ompi_op_t *op,
323 struct ompi_win_t *win)
324 {
325 int ret;
326 ompi_osc_sm_module_t *module =
327 (ompi_osc_sm_module_t*) win->w_osc_module;
328 void *remote_address;
329
330 OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
331 "get_accumulate: 0x%lx, %d, %s, %d, %d, %d, %s, %s, 0x%lx",
332 (unsigned long) origin_addr, origin_count,
333 origin_dt->name, target, (int) target_disp,
334 target_count, target_dt->name,
335 op->o_name,
336 (unsigned long) win));
337
338 remote_address = ((char*) (module->bases[target])) + module->disp_units[target] * target_disp;
339
340 opal_atomic_lock(&module->node_states[target].accumulate_lock);
341
342 ret = ompi_datatype_sndrcv(remote_address, target_count, target_dt,
343 result_addr, result_count, result_dt);
344 if (OMPI_SUCCESS != ret || op == &ompi_mpi_op_no_op.op) goto done;
345
346 if (op == &ompi_mpi_op_replace.op) {
347 ret = ompi_datatype_sndrcv((void *)origin_addr, origin_count, origin_dt,
348 remote_address, target_count, target_dt);
349 } else {
350 ret = ompi_osc_base_sndrcv_op(origin_addr, origin_count, origin_dt,
351 remote_address, target_count, target_dt,
352 op);
353 }
354
355 done:
356 opal_atomic_unlock(&module->node_states[target].accumulate_lock);
357
358 return ret;
359 }
360
361
362 int
363 ompi_osc_sm_compare_and_swap(const void *origin_addr,
364 const void *compare_addr,
365 void *result_addr,
366 struct ompi_datatype_t *dt,
367 int target,
368 ptrdiff_t target_disp,
369 struct ompi_win_t *win)
370 {
371 ompi_osc_sm_module_t *module =
372 (ompi_osc_sm_module_t*) win->w_osc_module;
373 void *remote_address;
374 size_t size;
375
376 OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
377 "compare_and_swap: 0x%lx, %s, %d, %d, 0x%lx",
378 (unsigned long) origin_addr,
379 dt->name, target, (int) target_disp,
380 (unsigned long) win));
381
382 remote_address = ((char*) (module->bases[target])) + module->disp_units[target] * target_disp;
383
384 ompi_datatype_type_size(dt, &size);
385
386 opal_atomic_lock(&module->node_states[target].accumulate_lock);
387
388
389 ompi_datatype_copy_content_same_ddt(dt, 1, (char*) result_addr, (char*) remote_address);
390
391 if (0 == memcmp(result_addr, compare_addr, size)) {
392
393 ompi_datatype_copy_content_same_ddt(dt, 1, (char*) remote_address, (char*) origin_addr);
394 }
395
396 opal_atomic_unlock(&module->node_states[target].accumulate_lock);
397
398 return OMPI_SUCCESS;
399 }
400
401
402 int
403 ompi_osc_sm_fetch_and_op(const void *origin_addr,
404 void *result_addr,
405 struct ompi_datatype_t *dt,
406 int target,
407 ptrdiff_t target_disp,
408 struct ompi_op_t *op,
409 struct ompi_win_t *win)
410 {
411 ompi_osc_sm_module_t *module =
412 (ompi_osc_sm_module_t*) win->w_osc_module;
413 void *remote_address;
414
415 OPAL_OUTPUT_VERBOSE((50, ompi_osc_base_framework.framework_output,
416 "fetch_and_op: 0x%lx, %s, %d, %d, %s, 0x%lx",
417 (unsigned long) origin_addr,
418 dt->name, target, (int) target_disp,
419 op->o_name,
420 (unsigned long) win));
421
422 remote_address = ((char*) (module->bases[target])) + module->disp_units[target] * target_disp;
423
424 opal_atomic_lock(&module->node_states[target].accumulate_lock);
425
426
427 ompi_datatype_copy_content_same_ddt(dt, 1, (char*) result_addr, (char*) remote_address);
428 if (op == &ompi_mpi_op_no_op.op) goto done;
429
430
431 if (op == &ompi_mpi_op_replace.op) {
432 ompi_datatype_copy_content_same_ddt(dt, 1, (char*) remote_address, (char*) origin_addr);
433 } else {
434 ompi_op_reduce(op, (void *)origin_addr, remote_address, 1, dt);
435 }
436
437 done:
438 opal_atomic_unlock(&module->node_states[target].accumulate_lock);
439
440 return OMPI_SUCCESS;;
441 }