This source file includes following definitions.
- osc_pt2pt_ntoh
- osc_pt2pt_hton_intr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 #ifndef OMPI_MCA_OSC_PT2PT_HDR_H
26 #define OMPI_MCA_OSC_PT2PT_HDR_H
27
28 #ifdef HAVE_NETINET_IN_H
29 #include <netinet/in.h>
30 #endif
31
32 #include "opal/types.h"
33 #include "opal/util/arch.h"
34
35 enum ompi_osc_pt2pt_hdr_type_t {
36 OMPI_OSC_PT2PT_HDR_TYPE_PUT = 0x01,
37 OMPI_OSC_PT2PT_HDR_TYPE_PUT_LONG = 0x02,
38 OMPI_OSC_PT2PT_HDR_TYPE_ACC = 0x03,
39 OMPI_OSC_PT2PT_HDR_TYPE_ACC_LONG = 0x04,
40 OMPI_OSC_PT2PT_HDR_TYPE_GET = 0x05,
41 OMPI_OSC_PT2PT_HDR_TYPE_CSWAP = 0x06,
42 OMPI_OSC_PT2PT_HDR_TYPE_CSWAP_LONG = 0x07,
43 OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC = 0x08,
44 OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC_LONG = 0x09,
45 OMPI_OSC_PT2PT_HDR_TYPE_COMPLETE = 0x10,
46 OMPI_OSC_PT2PT_HDR_TYPE_POST = 0x11,
47 OMPI_OSC_PT2PT_HDR_TYPE_LOCK_REQ = 0x12,
48 OMPI_OSC_PT2PT_HDR_TYPE_LOCK_ACK = 0x13,
49 OMPI_OSC_PT2PT_HDR_TYPE_UNLOCK_REQ = 0x14,
50 OMPI_OSC_PT2PT_HDR_TYPE_UNLOCK_ACK = 0x15,
51 OMPI_OSC_PT2PT_HDR_TYPE_FLUSH_REQ = 0x16,
52 OMPI_OSC_PT2PT_HDR_TYPE_FLUSH_ACK = 0x17,
53 OMPI_OSC_PT2PT_HDR_TYPE_FRAG = 0x20,
54 };
55 typedef enum ompi_osc_pt2pt_hdr_type_t ompi_osc_pt2pt_hdr_type_t;
56
57 #define OMPI_OSC_PT2PT_HDR_FLAG_NBO 0x01
58 #define OMPI_OSC_PT2PT_HDR_FLAG_VALID 0x02
59 #define OMPI_OSC_PT2PT_HDR_FLAG_PASSIVE_TARGET 0x04
60 #define OMPI_OSC_PT2PT_HDR_FLAG_LARGE_DATATYPE 0x08
61
62 struct ompi_osc_pt2pt_header_base_t {
63
64 uint8_t type;
65
66 uint8_t flags;
67 };
68 typedef struct ompi_osc_pt2pt_header_base_t ompi_osc_pt2pt_header_base_t;
69
70 struct ompi_osc_pt2pt_header_put_t {
71 ompi_osc_pt2pt_header_base_t base;
72
73 uint16_t tag;
74 uint32_t count;
75 uint64_t len;
76 uint64_t displacement;
77 };
78 typedef struct ompi_osc_pt2pt_header_put_t ompi_osc_pt2pt_header_put_t;
79
80 struct ompi_osc_pt2pt_header_acc_t {
81 ompi_osc_pt2pt_header_base_t base;
82
83 uint16_t tag;
84 uint32_t count;
85 uint64_t len;
86 uint64_t displacement;
87 uint32_t op;
88 };
89 typedef struct ompi_osc_pt2pt_header_acc_t ompi_osc_pt2pt_header_acc_t;
90
91 struct ompi_osc_pt2pt_header_get_t {
92 ompi_osc_pt2pt_header_base_t base;
93
94 uint16_t tag;
95 uint32_t count;
96 uint64_t len;
97 uint64_t displacement;
98 };
99 typedef struct ompi_osc_pt2pt_header_get_t ompi_osc_pt2pt_header_get_t;
100
101 struct ompi_osc_pt2pt_header_complete_t {
102 ompi_osc_pt2pt_header_base_t base;
103 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
104 uint8_t padding[2];
105 #endif
106 int frag_count;
107 };
108 typedef struct ompi_osc_pt2pt_header_complete_t ompi_osc_pt2pt_header_complete_t;
109
110 struct ompi_osc_pt2pt_header_cswap_t {
111 ompi_osc_pt2pt_header_base_t base;
112
113 uint16_t tag;
114 uint32_t len;
115 uint64_t displacement;
116 };
117 typedef struct ompi_osc_pt2pt_header_cswap_t ompi_osc_pt2pt_header_cswap_t;
118
119 struct ompi_osc_pt2pt_header_post_t {
120 ompi_osc_pt2pt_header_base_t base;
121 };
122 typedef struct ompi_osc_pt2pt_header_post_t ompi_osc_pt2pt_header_post_t;
123
124 struct ompi_osc_pt2pt_header_lock_t {
125 ompi_osc_pt2pt_header_base_t base;
126 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
127 uint8_t padding[2];
128 #endif
129 int32_t lock_type;
130 uint64_t lock_ptr;
131 };
132 typedef struct ompi_osc_pt2pt_header_lock_t ompi_osc_pt2pt_header_lock_t;
133
134 struct ompi_osc_pt2pt_header_lock_ack_t {
135 ompi_osc_pt2pt_header_base_t base;
136 uint32_t source;
137 uint64_t lock_ptr;
138 };
139 typedef struct ompi_osc_pt2pt_header_lock_ack_t ompi_osc_pt2pt_header_lock_ack_t;
140
141 struct ompi_osc_pt2pt_header_unlock_t {
142 ompi_osc_pt2pt_header_base_t base;
143 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
144 uint8_t padding[2];
145 #endif
146 int32_t lock_type;
147 uint64_t lock_ptr;
148 uint32_t frag_count;
149 };
150 typedef struct ompi_osc_pt2pt_header_unlock_t ompi_osc_pt2pt_header_unlock_t;
151
152 struct ompi_osc_pt2pt_header_unlock_ack_t {
153 ompi_osc_pt2pt_header_base_t base;
154 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
155 uint8_t padding[6];
156 #endif
157 uint64_t lock_ptr;
158 };
159 typedef struct ompi_osc_pt2pt_header_unlock_ack_t ompi_osc_pt2pt_header_unlock_ack_t;
160
161 struct ompi_osc_pt2pt_header_flush_t {
162 ompi_osc_pt2pt_header_base_t base;
163 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
164 uint8_t padding[2];
165 #endif
166 uint32_t frag_count;
167 uint64_t lock_ptr;
168 };
169 typedef struct ompi_osc_pt2pt_header_flush_t ompi_osc_pt2pt_header_flush_t;
170
171 struct ompi_osc_pt2pt_header_flush_ack_t {
172 ompi_osc_pt2pt_header_base_t base;
173 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
174 uint8_t padding[6];
175 #endif
176 uint64_t lock_ptr;
177 };
178 typedef struct ompi_osc_pt2pt_header_flush_ack_t ompi_osc_pt2pt_header_flush_ack_t;
179
180 struct ompi_osc_pt2pt_frag_header_t {
181 ompi_osc_pt2pt_header_base_t base;
182 uint32_t source;
183 opal_atomic_int32_t num_ops;
184 uint32_t pad;
185 };
186 typedef struct ompi_osc_pt2pt_frag_header_t ompi_osc_pt2pt_frag_header_t;
187
188 union ompi_osc_pt2pt_header_t {
189 ompi_osc_pt2pt_header_base_t base;
190 ompi_osc_pt2pt_header_put_t put;
191 ompi_osc_pt2pt_header_acc_t acc;
192 ompi_osc_pt2pt_header_get_t get;
193 ompi_osc_pt2pt_header_complete_t complete;
194 ompi_osc_pt2pt_header_cswap_t cswap;
195 ompi_osc_pt2pt_header_post_t post;
196 ompi_osc_pt2pt_header_lock_t lock;
197 ompi_osc_pt2pt_header_lock_ack_t lock_ack;
198 ompi_osc_pt2pt_header_unlock_t unlock;
199 ompi_osc_pt2pt_header_unlock_ack_t unlock_ack;
200 ompi_osc_pt2pt_header_flush_t flush;
201 ompi_osc_pt2pt_header_flush_ack_t flush_ack;
202 ompi_osc_pt2pt_frag_header_t frag;
203 };
204 typedef union ompi_osc_pt2pt_header_t ompi_osc_pt2pt_header_t;
205
206 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
207 #define MCA_OSC_PT2PT_FRAG_HDR_NTOH(h) \
208 (h).source = ntohl((h).source); \
209 (h).num_ops = ntohl((h).num_ops); \
210 (h).pad = ntohl((h).pad);
211 #define MCA_OSC_PT2PT_FRAG_HDR_HTON(h) \
212 (h).source = htonl((h).source); \
213 (h).num_ops = htonl((h).num_ops); \
214 (h).pad = htonl((h).pad);
215
216 #define MCA_OSC_PT2PT_PUT_HDR_NTOH(h) \
217 (h).tag = ntohs((h).tag); \
218 (h).count = ntohl((h).count); \
219 (h).len = ntoh64((h).len); \
220 (h).displacement = ntoh64((h).displacement);
221 #define MCA_OSC_PT2PT_PUT_HDR_HTON(h) \
222 (h).tag = htons((h).tag); \
223 (h).count = htonl((h).count); \
224 (h).len = hton64((h).len); \
225 (h).displacement = hton64((h).displacement);
226
227 #define MCA_OSC_PT2PT_GET_HDR_NTOH(h) \
228 (h).tag = ntohs((h).tag); \
229 (h).count = ntohl((h).count); \
230 (h).len = ntoh64((h).len); \
231 (h).displacement = ntoh64((h).displacement);
232 #define MCA_OSC_PT2PT_GET_HDR_HTON(h) \
233 (h).tag = htons((h).tag); \
234 (h).count = htonl((h).count); \
235 (h).len = hton64((h).len); \
236 (h).displacement = hton64((h).displacement);
237
238 #define MCA_OSC_PT2PT_ACC_HDR_NTOH(h) \
239 (h).tag = ntohs((h).tag); \
240 (h).count = ntohl((h).count); \
241 (h).len = ntoh64((h).len); \
242 (h).displacement = ntoh64((h).displacement);\
243 (h).op = ntohl((h).op);
244 #define MCA_OSC_PT2PT_ACC_HDR_HTON(h) \
245 (h).tag = htons((h).tag); \
246 (h).count = htonl((h).count); \
247 (h).len = hton64((h).len); \
248 (h).displacement = hton64((h).displacement);\
249 (h).op = htonl((h).op);
250
251 #define MCA_OSC_PT2PT_LOCK_HDR_NTOH(h) \
252 (h).lock_type = ntohl((h).lock_type)
253 #define MCA_OSC_PT2PT_LOCK_HDR_HTON(h) \
254 (h).lock_type = htonl((h).lock_type)
255
256 #define MCA_OSC_PT2PT_UNLOCK_HDR_NTOH(h) \
257 (h).lock_type = ntohl((h).lock_type); \
258 (h).frag_count = ntohl((h).frag_count)
259 #define MCA_OSC_PT2PT_UNLOCK_HDR_HTON(h) \
260 (h).lock_type = htonl((h).lock_type); \
261 (h).frag_count = htonl((h).frag_count)
262
263 #define MCA_OSC_PT2PT_LOCK_ACK_HDR_NTOH(h) \
264 (h).source = ntohl((h).source)
265 #define MCA_OSC_PT2PT_LOCK_ACK_HDR_HTON(h) \
266 (h).source= htonl((h).source)
267
268 #define MCA_OSC_PT2PT_UNLOCK_ACK_HDR_NTOH(h)
269 #define MCA_OSC_PT2PT_UNLOCK_ACK_HDR_HTON(h)
270
271 #define MCA_OSC_PT2PT_COMPLETE_HDR_NTOH(h) \
272 (h).frag_count = ntohl((h).frag_count)
273 #define MCA_OSC_PT2PT_COMPLETE_HDR_HTON(h) \
274 (h).frag_count = htonl((h).frag_count)
275
276 #define MCA_OSC_PT2PT_FLUSH_HDR_NTOH(h) \
277 (h).frag_count = ntohl((h).frag_count)
278 #define MCA_OSC_PT2PT_FLUSH_HDR_HTON(h) \
279 (h).frag_count = htonl((h).frag_count)
280
281 #define MCA_OSC_PT2PT_FLUSH_ACK_HDR_NTOH(h)
282 #define MCA_OSC_PT2PT_FLUSH_ACK_HDR_HTON(h)
283
284 #define MCA_OSC_PT2PT_POST_HDR_NTOH(h)
285 #define MCA_OSC_PT2PT_POST_HDR_HTON(h)
286
287 #define MCA_OSC_PT2PT_CSWAP_HDR_NTOH(h) \
288 (h).tag = ntohs((h).tag); \
289 (h).len = ntohl((h).len); \
290 (h).displacement = ntoh64((h).displacement)
291 #define MCA_OSC_PT2PT_CSWAP_HDR_HTON(h) \
292 (h).tag = htons((h).tag); \
293 (h).len = htonl((h).len); \
294 (h).displacement = hton64((h).displacement)
295 #endif
296
297 #if !defined(WORDS_BIGENDIAN) && OPAL_ENABLE_HETEROGENEOUS_SUPPORT
298 static inline __opal_attribute_always_inline__ void
299 osc_pt2pt_ntoh(ompi_osc_pt2pt_header_t *hdr)
300 {
301 if(!(hdr->base.flags & OMPI_OSC_PT2PT_HDR_FLAG_NBO))
302 return;
303
304 switch(hdr->base.type) {
305 case OMPI_OSC_PT2PT_HDR_TYPE_PUT:
306 case OMPI_OSC_PT2PT_HDR_TYPE_PUT_LONG:
307 MCA_OSC_PT2PT_PUT_HDR_NTOH(hdr->put);
308 break;
309 case OMPI_OSC_PT2PT_HDR_TYPE_ACC:
310 case OMPI_OSC_PT2PT_HDR_TYPE_ACC_LONG:
311 case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC:
312 case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC_LONG:
313 MCA_OSC_PT2PT_ACC_HDR_NTOH(hdr->acc);
314 break;
315 case OMPI_OSC_PT2PT_HDR_TYPE_GET:
316 MCA_OSC_PT2PT_GET_HDR_NTOH(hdr->get);
317 break;
318 case OMPI_OSC_PT2PT_HDR_TYPE_CSWAP:
319 case OMPI_OSC_PT2PT_HDR_TYPE_CSWAP_LONG:
320 MCA_OSC_PT2PT_CSWAP_HDR_NTOH(hdr->cswap);
321 break;
322 case OMPI_OSC_PT2PT_HDR_TYPE_COMPLETE:
323 MCA_OSC_PT2PT_COMPLETE_HDR_NTOH(hdr->complete);
324 break;
325 case OMPI_OSC_PT2PT_HDR_TYPE_POST:
326 MCA_OSC_PT2PT_POST_HDR_NTOH(hdr->post);
327 break;
328 case OMPI_OSC_PT2PT_HDR_TYPE_LOCK_REQ:
329 MCA_OSC_PT2PT_LOCK_HDR_NTOH(hdr->lock);
330 break;
331 case OMPI_OSC_PT2PT_HDR_TYPE_LOCK_ACK:
332 MCA_OSC_PT2PT_LOCK_ACK_HDR_NTOH(hdr->lock_ack);
333 break;
334 case OMPI_OSC_PT2PT_HDR_TYPE_UNLOCK_REQ:
335 MCA_OSC_PT2PT_UNLOCK_HDR_NTOH(hdr->unlock);
336 break;
337 case OMPI_OSC_PT2PT_HDR_TYPE_UNLOCK_ACK:
338 MCA_OSC_PT2PT_UNLOCK_ACK_HDR_NTOH(hdr->unlock_ack);
339 break;
340 case OMPI_OSC_PT2PT_HDR_TYPE_FLUSH_REQ:
341 MCA_OSC_PT2PT_FLUSH_HDR_NTOH(hdr->flush);
342 break;
343 case OMPI_OSC_PT2PT_HDR_TYPE_FLUSH_ACK:
344 MCA_OSC_PT2PT_FLUSH_ACK_HDR_NTOH(hdr->flush_ack);
345 break;
346 case OMPI_OSC_PT2PT_HDR_TYPE_FRAG:
347 MCA_OSC_PT2PT_FRAG_HDR_NTOH(hdr->frag);
348 break;
349 default:
350 assert(0);
351 break;
352 }
353 }
354 #else
355 #define osc_pt2pt_ntoh(h) \
356 do { } while (0)
357 #endif
358
359 #if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
360 #define osc_pt2pt_hton(h, p) \
361 osc_pt2pt_hton_intr((ompi_osc_pt2pt_header_t *)(h), (p));
362 static inline __opal_attribute_always_inline__ void
363 osc_pt2pt_hton_intr(ompi_osc_pt2pt_header_t *hdr, const ompi_proc_t *proc)
364 {
365 #ifdef WORDS_BIGENDIAN
366 hdr->base.flags |= OMPI_OSC_PT2PT_HDR_FLAG_NBO;
367 #else
368 if(!(proc->super.proc_arch & OPAL_ARCH_ISBIGENDIAN))
369 return;
370
371 hdr->base.flags |= OMPI_OSC_PT2PT_HDR_FLAG_NBO;
372 switch(hdr->base.type) {
373 case OMPI_OSC_PT2PT_HDR_TYPE_PUT:
374 case OMPI_OSC_PT2PT_HDR_TYPE_PUT_LONG:
375 MCA_OSC_PT2PT_PUT_HDR_HTON(hdr->put);
376 break;
377 case OMPI_OSC_PT2PT_HDR_TYPE_ACC:
378 case OMPI_OSC_PT2PT_HDR_TYPE_ACC_LONG:
379 case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC:
380 case OMPI_OSC_PT2PT_HDR_TYPE_GET_ACC_LONG:
381 MCA_OSC_PT2PT_ACC_HDR_HTON(hdr->acc);
382 break;
383 case OMPI_OSC_PT2PT_HDR_TYPE_GET:
384 MCA_OSC_PT2PT_GET_HDR_HTON(hdr->get);
385 break;
386 case OMPI_OSC_PT2PT_HDR_TYPE_CSWAP:
387 case OMPI_OSC_PT2PT_HDR_TYPE_CSWAP_LONG:
388 MCA_OSC_PT2PT_CSWAP_HDR_HTON(hdr->cswap);
389 break;
390 case OMPI_OSC_PT2PT_HDR_TYPE_COMPLETE:
391 MCA_OSC_PT2PT_COMPLETE_HDR_HTON(hdr->complete);
392 break;
393 case OMPI_OSC_PT2PT_HDR_TYPE_POST:
394 MCA_OSC_PT2PT_POST_HDR_HTON(hdr->post);
395 break;
396 case OMPI_OSC_PT2PT_HDR_TYPE_LOCK_REQ:
397 MCA_OSC_PT2PT_LOCK_HDR_HTON(hdr->lock);
398 break;
399 case OMPI_OSC_PT2PT_HDR_TYPE_LOCK_ACK:
400 MCA_OSC_PT2PT_LOCK_ACK_HDR_HTON(hdr->lock_ack);
401 break;
402 case OMPI_OSC_PT2PT_HDR_TYPE_UNLOCK_REQ:
403 MCA_OSC_PT2PT_UNLOCK_HDR_HTON(hdr->unlock);
404 break;
405 case OMPI_OSC_PT2PT_HDR_TYPE_UNLOCK_ACK:
406 MCA_OSC_PT2PT_UNLOCK_ACK_HDR_HTON(hdr->unlock_ack);
407 break;
408 case OMPI_OSC_PT2PT_HDR_TYPE_FLUSH_REQ:
409 MCA_OSC_PT2PT_FLUSH_HDR_HTON(hdr->flush);
410 break;
411 case OMPI_OSC_PT2PT_HDR_TYPE_FLUSH_ACK:
412 MCA_OSC_PT2PT_FLUSH_ACK_HDR_HTON(hdr->flush_ack);
413 break;
414 case OMPI_OSC_PT2PT_HDR_TYPE_FRAG:
415 MCA_OSC_PT2PT_FRAG_HDR_HTON(hdr->frag);
416 break;
417 default:
418 assert(0);
419 break;
420 }
421 #endif
422 }
423 #define OSC_PT2PT_HTON(h, m, r) \
424 osc_pt2pt_hton_intr((ompi_osc_pt2pt_header_t *)(h), ompi_comm_peer_lookup((m)->comm, (r)));
425 #else
426 #define osc_pt2pt_hton(h, p) \
427 do { } while (0)
428 #define OSC_PT2PT_HTON(h, m, r) \
429 do { } while (0)
430 #endif
431
432 #endif