This source file includes following definitions.
- ompi_osc_pt2pt_sync_constructor
- ompi_osc_pt2pt_sync_destructor
- ompi_osc_pt2pt_sync_allocate
- ompi_osc_pt2pt_sync_return
- ompi_osc_pt2pt_sync_array_peer
- ompi_osc_pt2pt_sync_pscw_peer
1
2
3
4
5
6
7
8
9
10
11
12 #include "osc_pt2pt.h"
13 #include "osc_pt2pt_sync.h"
14
15 static void ompi_osc_pt2pt_sync_constructor (ompi_osc_pt2pt_sync_t *sync)
16 {
17 sync->type = OMPI_OSC_PT2PT_SYNC_TYPE_NONE;
18 sync->eager_send_active = false;
19 sync->epoch_active = false;
20 OBJ_CONSTRUCT(&sync->lock, opal_mutex_t);
21 OBJ_CONSTRUCT(&sync->cond, opal_condition_t);
22 }
23
24 static void ompi_osc_pt2pt_sync_destructor (ompi_osc_pt2pt_sync_t *sync)
25 {
26 OBJ_DESTRUCT(&sync->lock);
27 OBJ_DESTRUCT(&sync->cond);
28 }
29
30 OBJ_CLASS_INSTANCE(ompi_osc_pt2pt_sync_t, opal_free_list_item_t,
31 ompi_osc_pt2pt_sync_constructor,
32 ompi_osc_pt2pt_sync_destructor);
33
34 ompi_osc_pt2pt_sync_t *ompi_osc_pt2pt_sync_allocate (struct ompi_osc_pt2pt_module_t *module)
35 {
36 ompi_osc_pt2pt_sync_t *sync;
37
38
39 (void) module;
40
41 sync = OBJ_NEW (ompi_osc_pt2pt_sync_t);
42 if (OPAL_UNLIKELY(NULL == sync)) {
43 return NULL;
44 }
45
46 sync->module = module;
47 return sync;
48 }
49
50 void ompi_osc_pt2pt_sync_return (ompi_osc_pt2pt_sync_t *sync)
51 {
52 OBJ_RELEASE(sync);
53 }
54
55 static inline bool ompi_osc_pt2pt_sync_array_peer (int rank, ompi_osc_pt2pt_peer_t **peers, size_t nranks,
56 struct ompi_osc_pt2pt_peer_t **peer)
57 {
58 int mid = nranks / 2;
59
60
61 if (0 == nranks || (1 == nranks && peers[0]->rank != rank)) {
62 if (peer) {
63 *peer = NULL;
64 }
65 return false;
66 } else if (peers[0]->rank == rank) {
67 if (peer) {
68 *peer = peers[0];
69 }
70 return true;
71 }
72
73 if (peers[mid]->rank > rank) {
74 return ompi_osc_pt2pt_sync_array_peer (rank, peers, mid, peer);
75 }
76
77 return ompi_osc_pt2pt_sync_array_peer (rank, peers + mid, nranks - mid, peer);
78 }
79
80 bool ompi_osc_pt2pt_sync_pscw_peer (ompi_osc_pt2pt_module_t *module, int target, struct ompi_osc_pt2pt_peer_t **peer)
81 {
82 ompi_osc_pt2pt_sync_t *pt2pt_sync = &module->all_sync;
83
84
85 if (OMPI_OSC_PT2PT_SYNC_TYPE_PSCW != pt2pt_sync->type) {
86 if (peer) {
87 *peer = NULL;
88 }
89 return false;
90 }
91
92 return ompi_osc_pt2pt_sync_array_peer (target, pt2pt_sync->peer_list.peers, pt2pt_sync->num_peers, peer);
93 }