This source file includes following definitions.
- ompi_osc_portals4_fence
- ompi_osc_portals4_start
- ompi_osc_portals4_complete
- ompi_osc_portals4_post
- ompi_osc_portals4_wait
- ompi_osc_portals4_test
1
2
3
4
5
6
7
8
9
10
11
12
13 #include "ompi_config.h"
14
15 #include "ompi/mca/osc/osc.h"
16 #include "ompi/mca/osc/base/base.h"
17 #include "ompi/mca/osc/base/osc_base_obj_convert.h"
18
19 #include "osc_portals4.h"
20
21
22 int
23 ompi_osc_portals4_fence(int assert, struct ompi_win_t *win)
24 {
25 ompi_osc_portals4_module_t *module =
26 (ompi_osc_portals4_module_t*) win->w_osc_module;
27 int comm_ret, ret;
28
29
30 if (module->passive_target_access_epoch) {
31 return OMPI_ERR_RMA_SYNC;
32 }
33
34 comm_ret = ompi_osc_portals4_complete_all(module);
35
36 ret = module->comm->c_coll->coll_barrier(module->comm,
37 module->comm->c_coll->coll_barrier_module);
38
39 return (OMPI_SUCCESS == comm_ret) ? ret : comm_ret;
40 }
41
42
43 int
44 ompi_osc_portals4_start(struct ompi_group_t *group,
45 int assert,
46 struct ompi_win_t *win)
47 {
48 ompi_osc_portals4_module_t *module =
49 (ompi_osc_portals4_module_t*) win->w_osc_module;
50
51
52 if (module->passive_target_access_epoch) {
53 return OMPI_ERR_RMA_SYNC;
54 }
55
56 if (0 == (assert & MPI_MODE_NOCHECK)) {
57 int size;
58
59 OBJ_RETAIN(group);
60 module->start_group = group;
61 size = ompi_group_size(module->start_group);
62
63 while (module->state.post_count != size) opal_progress();
64 } else {
65 module->start_group = NULL;
66 }
67
68 return OMPI_SUCCESS;
69 }
70
71
72 int
73 ompi_osc_portals4_complete(struct ompi_win_t *win)
74 {
75 ompi_osc_portals4_module_t *module =
76 (ompi_osc_portals4_module_t*) win->w_osc_module;
77 int ret, i, size;
78
79 ret = ompi_osc_portals4_complete_all(module);
80 if (ret != OMPI_SUCCESS) return ret;
81
82 if (NULL != module->start_group) {
83 module->state.post_count = 0;
84 PtlAtomicSync();
85
86 size = ompi_group_size(module->start_group);
87 for (i = 0 ; i < size ; ++i) {
88
89 ret = PtlAtomic(module->md_h,
90 (ptl_size_t) &module->one,
91 sizeof(module->one),
92 PTL_ACK_REQ,
93 ompi_osc_portals4_get_peer_group(module->start_group, i),
94 module->pt_idx,
95 module->match_bits | OSC_PORTALS4_MB_CONTROL,
96 offsetof(ompi_osc_portals4_node_state_t, complete_count),
97 NULL,
98 0,
99 PTL_SUM,
100 PTL_INT32_T);
101 if (ret != OMPI_SUCCESS) return ret;
102 OPAL_THREAD_ADD_FETCH64(&module->opcount, 1);
103 }
104
105 ret = ompi_osc_portals4_complete_all(module);
106 if (ret != OMPI_SUCCESS) return ret;
107
108 OBJ_RELEASE(module->start_group);
109 module->start_group = NULL;
110 }
111
112 return OMPI_SUCCESS;
113 }
114
115
116 int
117 ompi_osc_portals4_post(struct ompi_group_t *group,
118 int assert,
119 struct ompi_win_t *win)
120 {
121 ompi_osc_portals4_module_t *module =
122 (ompi_osc_portals4_module_t*) win->w_osc_module;
123 int ret, i, size;
124
125 if (0 == (assert & MPI_MODE_NOCHECK)) {
126 OBJ_RETAIN(group);
127 module->post_group = group;
128
129 module->state.complete_count = 0;
130 PtlAtomicSync();
131
132 size = ompi_group_size(module->post_group);
133 for (i = 0 ; i < size ; ++i) {
134 ret = PtlAtomic(module->md_h,
135 (ptl_size_t) &module->one,
136 sizeof(module->one),
137 PTL_ACK_REQ,
138 ompi_osc_portals4_get_peer_group(module->post_group, i),
139 module->pt_idx,
140 module->match_bits | OSC_PORTALS4_MB_CONTROL,
141 offsetof(ompi_osc_portals4_node_state_t, post_count),
142 NULL,
143 0,
144 PTL_SUM,
145 PTL_INT32_T);
146 if (ret != OMPI_SUCCESS) return ret;
147 OPAL_THREAD_ADD_FETCH64(&module->opcount, 1);
148 }
149 } else {
150 module->post_group = NULL;
151 }
152
153 return OMPI_SUCCESS;
154 }
155
156
157 int
158 ompi_osc_portals4_wait(struct ompi_win_t *win)
159 {
160 ompi_osc_portals4_module_t *module =
161 (ompi_osc_portals4_module_t*) win->w_osc_module;
162
163 if (NULL != module->post_group) {
164 int size = ompi_group_size(module->post_group);
165
166 while (module->state.complete_count != size) opal_progress();
167
168 OBJ_RELEASE(module->post_group);
169 module->post_group = NULL;
170 }
171
172 return OMPI_SUCCESS;
173 }
174
175
176 int
177 ompi_osc_portals4_test(struct ompi_win_t *win,
178 int *flag)
179 {
180 ompi_osc_portals4_module_t *module =
181 (ompi_osc_portals4_module_t*) win->w_osc_module;
182
183 if (NULL != module->post_group) {
184 int size = ompi_group_size(module->post_group);
185
186 if (module->state.complete_count == size) {
187 OBJ_RELEASE(module->post_group);
188 module->post_group = NULL;
189 *flag = 1;
190 }
191 } else {
192 *flag = 0;
193 }
194
195 return OMPI_SUCCESS;
196 }