OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

btl_wv_frag.h
1 /*
2 * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
3 * University Research and Technology
4 * Corporation. All rights reserved.
5 * Copyright (c) 2004-2006 The University of Tennessee and The University
6 * of Tennessee Research Foundation. All rights
7 * reserved.
8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9 * University of Stuttgart. All rights reserved.
10 * Copyright (c) 2004-2005 The Regents of the University of California.
11 * All rights reserved.
12 * Copyright (c) 2009 IBM Corporation. All rights reserved.
13 * Copyright (c) 2006-2009 Los Alamos National Security, LLC. All rights
14 * reserved.
15 * Copyright (c) 2006-2007 Voltaire All rights reserved.
16 * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
17 * $COPYRIGHT$
18 *
19 * Additional copyrights may follow
20 *
21 * $HEADER$
22 */
23
24 #ifndef MCA_BTL_IB_FRAG_H
25 #define MCA_BTL_IB_FRAG_H
26
27 #include "ompi_config.h"
28 #include "ompi/mca/btl/btl.h"
29
30 BEGIN_C_DECLS
31
32 struct mca_btl_wv_reg_t;
33
34 struct mca_btl_wv_header_t {
35 mca_btl_base_tag_t tag;
36 uint8_t cm_seen;
37 uint16_t credits;
38 };
39 typedef struct mca_btl_wv_header_t mca_btl_wv_header_t;
40 #define BTL_WV_RDMA_CREDITS_FLAG (1<<15)
41 #define BTL_WV_IS_RDMA_CREDITS(I) ((I)&BTL_WV_RDMA_CREDITS_FLAG)
42 #define BTL_WV_CREDITS(I) ((I)&~BTL_WV_RDMA_CREDITS_FLAG)
43
44 #define BTL_WV_HEADER_HTON(h) \
45 do { \
46 (h).credits = htons((h).credits); \
47 } while (0)
48
49 #define BTL_WV_HEADER_NTOH(h) \
50 do { \
51 (h).credits = ntohs((h).credits); \
52 } while (0)
53
54 typedef struct mca_btl_wv_header_coalesced_t {
55 mca_btl_base_tag_t tag;
56 uint32_t size;
57 uint32_t alloc_size;
58 } mca_btl_wv_header_coalesced_t;
59
60 #define BTL_WV_HEADER_COALESCED_NTOH(h) \
61 do { \
62 (h).size = ntohl((h).size); \
63 (h).alloc_size = ntohl((h).alloc_size); \
64 } while(0)
65
66 #define BTL_WV_HEADER_COALESCED_HTON(h) \
67 do { \
68 (h).size = htonl((h).size); \
69 (h).alloc_size = htonl((h).alloc_size); \
70 } while(0)
71
72 struct mca_btl_wv_footer_t {
73 #if OPAL_ENABLE_DEBUG
74 uint32_t seq;
75 #endif
76 union {
77 uint32_t size;
78 uint8_t buf[4];
79 } u;
80 };
81 typedef struct mca_btl_wv_footer_t mca_btl_wv_footer_t;
82
83 #ifdef WORDS_BIGENDIAN
84 #define MCA_BTL_WV_FTR_SIZE_REVERSE(ftr)
85 #else
86 #define MCA_BTL_WV_FTR_SIZE_REVERSE(ftr) \
87 do { \
88 uint8_t tmp = (ftr).u.buf[0]; \
89 (ftr).u.buf[0]=(ftr).u.buf[2]; \
90 (ftr).u.buf[2]=tmp; \
91 } while (0)
92 #endif
93
94 #if OPAL_ENABLE_DEBUG
95 #define BTL_WV_FOOTER_SEQ_HTON(h) ((h).seq = htonl((h).seq))
96 #define BTL_WV_FOOTER_SEQ_NTOH(h) ((h).seq = ntohl((h).seq))
97 #else
98 #define BTL_WV_FOOTER_SEQ_HTON(h)
99 #define BTL_WV_FOOTER_SEQ_NTOH(h)
100 #endif
101
102 #define BTL_WV_FOOTER_HTON(h) \
103 do { \
104 BTL_WV_FOOTER_SEQ_HTON(h); \
105 MCA_BTL_WV_FTR_SIZE_REVERSE(h); \
106 } while (0)
107
108 #define BTL_WV_FOOTER_NTOH(h) \
109 do { \
110 BTL_WV_FOOTER_SEQ_NTOH(h); \
111 MCA_BTL_WV_FTR_SIZE_REVERSE(h); \
112 } while (0)
113
114 #define MCA_BTL_WV_CONTROL_CREDITS 0
115 #define MCA_BTL_WV_CONTROL_RDMA 1
116 #define MCA_BTL_WV_CONTROL_COALESCED 2
117 #define MCA_BTL_WV_CONTROL_CTS 3
118 #if BTL_WV_FAILOVER_ENABLED
119 #define MCA_BTL_WV_CONTROL_EP_BROKEN 4
120 #define MCA_BTL_WV_CONTROL_EP_EAGER_RDMA_ERROR 5
121 #endif
122
123 struct mca_btl_wv_control_header_t {
124 uint8_t type;
125 #if OMPI_WV_PAD_HDR
126 uint8_t padding[15];
127 #endif
128 };
129 typedef struct mca_btl_wv_control_header_t mca_btl_wv_control_header_t;
130
131 struct mca_btl_wv_eager_rdma_header_t {
132 mca_btl_wv_control_header_t control;
133 uint8_t padding[3];
134 uint32_t rkey;
135 ompi_ptr_t rdma_start;
136 };
137 typedef struct mca_btl_wv_eager_rdma_header_t mca_btl_wv_eager_rdma_header_t;
138
139 #define BTL_WV_EAGER_RDMA_CONTROL_HEADER_HTON(h) \
140 do { \
141 (h).rkey = htonl((h).rkey); \
142 (h).rdma_start.lval = hton64((h).rdma_start.lval); \
143 } while (0)
144
145 #define BTL_WV_EAGER_RDMA_CONTROL_HEADER_NTOH(h) \
146 do { \
147 (h).rkey = ntohl((h).rkey); \
148 (h).rdma_start.lval = ntoh64((h).rdma_start.lval); \
149 } while (0)
150
151
152 struct mca_btl_wv_rdma_credits_header_t {
153 mca_btl_wv_control_header_t control;
154 uint8_t qpn;
155 uint16_t rdma_credits;
156 };
157 typedef struct mca_btl_wv_rdma_credits_header_t mca_btl_wv_rdma_credits_header_t;
158
159 #define BTL_WV_RDMA_CREDITS_HEADER_HTON(h) \
160 do { \
161 (h).rdma_credits = htons((h).rdma_credits); \
162 } while (0)
163
164 #define BTL_WV_RDMA_CREDITS_HEADER_NTOH(h) \
165 do { \
166 (h).rdma_credits = ntohs((h).rdma_credits); \
167 } while (0)
168
169 #if BTL_WV_FAILOVER_ENABLED
170 struct mca_btl_wv_broken_connection_header_t {
171 mca_btl_wv_control_header_t control;
172 uint8_t padding[3];
173 uint32_t lid;
174 uint64_t subnet_id;
175 uint32_t vpid;
176 uint32_t index; /* for eager RDMA only */
177 };
178 typedef struct mca_btl_wv_broken_connection_header_t mca_btl_wv_broken_connection_header_t;
179
180 #define BTL_WV_BROKEN_CONNECTION_HEADER_HTON(h) \
181 do { \
182 (h).lid = htonl((h).lid); \
183 (h).subnet_id = hton64((h).subnet_id); \
184 (h).vpid = htonl((h).vpid); \
185 (h).index = htonl((h).index); \
186 } while (0)
187
188 #define BTL_WV_BROKEN_CONNECTION_HEADER_NTOH(h) \
189 do { \
190 (h).lid = ntohl((h).lid); \
191 (h).subnet_id = ntoh64((h).subnet_id); \
192 (h).vpid = ntohl((h).vpid); \
193 (h).index = ntohl((h).index); \
194 } while (0)
195 #endif
196 enum mca_btl_wv_frag_type_t {
197 MCA_BTL_WV_FRAG_RECV,
198 MCA_BTL_WV_FRAG_RECV_USER,
199 MCA_BTL_WV_FRAG_SEND,
200 MCA_BTL_WV_FRAG_SEND_USER,
201 MCA_BTL_WV_FRAG_EAGER_RDMA,
202 MCA_BTL_WV_FRAG_CONTROL,
203 MCA_BTL_WV_FRAG_COALESCED
204 };
205 typedef enum mca_btl_wv_frag_type_t mca_btl_wv_frag_type_t;
206
207 #define wv_frag_type(f) (to_base_frag(f)->type)
208 /**
209 * IB fragment derived type.
210 */
211
212 /* base wv frag */
213 typedef struct mca_btl_wv_frag_t {
214 mca_btl_base_descriptor_t base;
215 mca_btl_base_segment_t segment;
216 mca_btl_wv_frag_type_t type;
217 ompi_free_list_t* list;
218 } mca_btl_wv_frag_t;
219 OBJ_CLASS_DECLARATION(mca_btl_wv_frag_t);
220
221 #define to_base_frag(f) ((mca_btl_wv_frag_t*)(f))
222
223 /* frag used for communication */
224 typedef struct mca_btl_wv_com_frag_t {
225 mca_btl_wv_frag_t super;
226 WV_SGE sg_entry;
227 struct mca_btl_wv_reg_t *registration;
228 struct mca_btl_base_endpoint_t *endpoint;
229 } mca_btl_wv_com_frag_t;
230 OBJ_CLASS_DECLARATION(mca_btl_wv_com_frag_t);
231
232 #define to_com_frag(f) ((mca_btl_wv_com_frag_t*)(f))
233
234 typedef struct mca_btl_wv_out_frag_t {
235 mca_btl_wv_com_frag_t super;
236 WV_SEND_REQUEST sr_desc;
237 } mca_btl_wv_out_frag_t;
238 OBJ_CLASS_DECLARATION(mca_btl_wv_out_frag_t);
239
240 #define to_out_frag(f) ((mca_btl_wv_out_frag_t*)(f))
241
242 typedef struct mca_btl_wv_com_frag_t mca_btl_wv_in_frag_t;
243 OBJ_CLASS_DECLARATION(mca_btl_wv_in_frag_t);
244
245 #define to_in_frag(f) ((mca_btl_wv_in_frag_t*)(f))
246
247 typedef struct mca_btl_wv_send_frag_t {
248 mca_btl_wv_out_frag_t super;
249 mca_btl_wv_header_t *hdr, *chdr;
250 mca_btl_wv_footer_t *ftr;
251 uint8_t qp_idx;
252 uint32_t coalesced_length;
253 opal_list_t coalesced_frags;
254 } mca_btl_wv_send_frag_t;
255 OBJ_CLASS_DECLARATION(mca_btl_wv_send_frag_t);
256
257 #define to_send_frag(f) ((mca_btl_wv_send_frag_t*)(f))
258
259 typedef struct mca_btl_wv_recv_frag_t {
260 mca_btl_wv_in_frag_t super;
261 mca_btl_wv_header_t *hdr;
262 mca_btl_wv_footer_t *ftr;
263 struct wv_recv_wr rd_desc;
264 uint8_t qp_idx;
265 } mca_btl_wv_recv_frag_t;
266 OBJ_CLASS_DECLARATION(mca_btl_wv_recv_frag_t);
267
268 #define to_recv_frag(f) ((mca_btl_wv_recv_frag_t*)(f))
269
270 typedef struct mca_btl_wv_out_frag_t mca_btl_wv_put_frag_t;
271 OBJ_CLASS_DECLARATION(mca_btl_wv_put_frag_t);
272
273 #define to_put_frag(f) ((mca_btl_wv_put_frag_t*)(f))
274
275 typedef struct mca_btl_wv_get_frag_t {
276 mca_btl_wv_in_frag_t super;
277 WV_SEND_REQUEST sr_desc;
278 } mca_btl_wv_get_frag_t;
279 OBJ_CLASS_DECLARATION(mca_btl_wv_get_frag_t);
280
281 #define to_get_frag(f) ((mca_btl_wv_get_frag_t*)(f))
282
283 typedef struct mca_btl_wv_send_frag_t mca_btl_wv_send_control_frag_t;
284 OBJ_CLASS_DECLARATION(mca_btl_wv_send_control_frag_t);
285
286 #define to_send_control_frag(f) ((mca_btl_wv_send_control_frag_t*)(f))
287
288 typedef struct mca_btl_wv_coalesced_frag_t {
289 mca_btl_wv_frag_t super;
290 mca_btl_wv_send_frag_t *send_frag;
291 mca_btl_wv_header_coalesced_t *hdr;
292 } mca_btl_wv_coalesced_frag_t;
293 OBJ_CLASS_DECLARATION(mca_btl_wv_coalesced_frag_t);
294
295 #define to_coalesced_frag(f) ((mca_btl_wv_coalesced_frag_t*)(f))
296
297 /*
298 * Allocate an IB send descriptor
299 *
300 */
301
302 static inline mca_btl_wv_send_control_frag_t *
303 alloc_control_frag(mca_btl_wv_module_t *btl)
304 {
305 int rc;
306 ompi_free_list_item_t *item;
307
308 OMPI_FREE_LIST_WAIT(&btl->device->send_free_control, item, rc);
309
310 return to_send_control_frag(item);
311 }
312
313 static inline uint8_t frag_size_to_order(mca_btl_wv_module_t* btl,
314 size_t size)
315 {
316 int qp;
317 for(qp = 0; qp < mca_btl_wv_component.num_qps; qp++)
318 if(mca_btl_wv_component.qp_infos[qp].size >= size)
319 return qp;
320
321 return MCA_BTL_NO_ORDER;
322 }
323
324 static inline mca_btl_wv_com_frag_t *alloc_send_user_frag(void)
325 {
326 int rc;
327 ompi_free_list_item_t *item;
328
329 OMPI_FREE_LIST_GET(&mca_btl_wv_component.send_user_free, item, rc);
330
331 return to_com_frag(item);
332 }
333
334 static inline mca_btl_wv_com_frag_t *alloc_recv_user_frag(void)
335 {
336 int rc;
337 ompi_free_list_item_t *item;
338
339 OMPI_FREE_LIST_GET(&mca_btl_wv_component.recv_user_free, item, rc);
340
341 return to_com_frag(item);
342 }
343
344 static inline mca_btl_wv_coalesced_frag_t *alloc_coalesced_frag(void)
345 {
346 int rc;
347 ompi_free_list_item_t *item;
348
349 OMPI_FREE_LIST_GET(&mca_btl_wv_component.send_free_coalesced, item, rc);
350
351 return to_coalesced_frag(item);
352 }
353
354 #define MCA_BTL_IB_FRAG_RETURN(frag) \
355 do { \
356 OMPI_FREE_LIST_RETURN(to_base_frag(frag)->list, \
357 (ompi_free_list_item_t*)(frag)); \
358 } while(0);
359
360 #define MCA_BTL_WV_CLEAN_PENDING_FRAGS(list) \
361 while(!opal_list_is_empty(list)){ \
362 opal_list_item_t *frag_item; \
363 frag_item = opal_list_remove_first(list); \
364 MCA_BTL_IB_FRAG_RETURN(frag_item); \
365 } \
366
367 struct mca_btl_wv_module_t;
368
369 struct mca_btl_wv_frag_init_data_t {
370 uint8_t order;
371 ompi_free_list_t* list;
372 };
373 typedef struct mca_btl_wv_frag_init_data_t mca_btl_wv_frag_init_data_t;
374
375 void mca_btl_wv_frag_init(ompi_free_list_item_t* item, void* ctx);
376
377
378 END_C_DECLS
379 #endif
mca_btl_wv_component_t::recv_user_free
ompi_free_list_t recv_user_free
frags for coalesced massages
Definition: btl_wv.h:268
mca_btl_wv_module_t
IB BTL Interface.
Definition: btl_wv.h:391
mca_btl_wv_reg_t
Definition: btl_wv.h:429
mca_btl_base_descriptor_t
A descriptor that holds the parameters to a send/put/get operation along w/ a callback routine that i...
Definition: btl.h:275
mca_btl_wv_frag_init_data_t
Definition: btl_wv_frag.h:369
wv_recv_wr
Definition: btl_wv_def.h:85
mca_btl_wv_control_header_t
Definition: btl_wv_frag.h:123
ompi_ptr_t
Definition: types.h:52
mca_btl_wv_frag_t
IB fragment derived type.
Definition: btl_wv_frag.h:213
mca_btl_wv_component_t::qp_infos
mca_btl_wv_qp_info_t * qp_infos
Eager send limit of first fragment, in Bytes.
Definition: btl_wv.h:184
mca_btl_wv_recv_frag_t
Definition: btl_wv_frag.h:259
mca_btl_wv_eager_rdma_header_t
Definition: btl_wv_frag.h:131
mca_btl_wv_com_frag_t
Definition: btl_wv_frag.h:224
mca_btl_wv_rdma_credits_header_t
Definition: btl_wv_frag.h:152
btl.h
Byte Transfer Layer (BTL)
mca_btl_wv_out_frag_t
Definition: btl_wv_frag.h:234
ompi_free_list_t
Definition: ompi_free_list.h:39
mca_btl_wv_component_t::send_user_free
ompi_free_list_t send_user_free
free list of frags only; used for pining user memory
Definition: btl_wv.h:266
mca_btl_base_endpoint_t
State of ELAN endpoint connection.
Definition: btl_elan_endpoint.h:33
ompi_free_list_item_t
Definition: ompi_free_list.h:62
mca_btl_wv_send_frag_t
Definition: btl_wv_frag.h:247
opal_list_t
Definition: opal_list.h:147
mca_btl_wv_header_t
Definition: btl_wv_frag.h:34
mca_btl_wv_coalesced_frag_t
Definition: btl_wv_frag.h:288
mca_btl_wv_get_frag_t
Definition: btl_wv_frag.h:275
mca_btl_base_segment_t
Describes a region/segment of memory that is addressable by an BTL.
Definition: btl.h:236
OBJ_CLASS_DECLARATION
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236
mca_btl_wv_header_coalesced_t
Definition: btl_wv_frag.h:54