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
26
27 #ifndef MCA_PML_OB1_RECVFRAG_H
28 #define MCA_PML_OB1_RECVFRAG_H
29
30 #include "pml_ob1_hdr.h"
31
32 BEGIN_C_DECLS
33
34 struct mca_pml_ob1_buffer_t {
35 size_t len;
36 void * addr;
37 };
38 typedef struct mca_pml_ob1_buffer_t mca_pml_ob1_buffer_t;
39
40
41 struct mca_pml_ob1_recv_frag_t {
42 opal_free_list_item_t super;
43 mca_pml_ob1_hdr_t hdr;
44 size_t num_segments;
45 struct mca_pml_ob1_recv_frag_t* range;
46 mca_btl_base_module_t* btl;
47 mca_btl_base_segment_t segments[MCA_BTL_DES_MAX_SEGMENTS];
48 mca_pml_ob1_buffer_t buffers[MCA_BTL_DES_MAX_SEGMENTS];
49 unsigned char addr[1];
50 };
51 typedef struct mca_pml_ob1_recv_frag_t mca_pml_ob1_recv_frag_t;
52
53 OBJ_CLASS_DECLARATION(mca_pml_ob1_recv_frag_t);
54
55
56 #define MCA_PML_OB1_RECV_FRAG_ALLOC(frag) \
57 do { \
58 frag = (mca_pml_ob1_recv_frag_t *) \
59 opal_free_list_wait (&mca_pml_ob1.recv_frags); \
60 } while(0)
61
62
63 #define MCA_PML_OB1_RECV_FRAG_INIT(frag, hdr, segs, cnt, btl ) \
64 do { \
65 size_t i, _size; \
66 mca_btl_base_segment_t* macro_segments = frag->segments; \
67 mca_pml_ob1_buffer_t* buffers = frag->buffers; \
68 unsigned char* _ptr = (unsigned char*)frag->addr; \
69 \
70 frag->btl = btl; \
71 ob1_hdr_copy( (mca_pml_ob1_hdr_t*)hdr, &frag->hdr ); \
72 frag->num_segments = 1; \
73 _size = segs[0].seg_len; \
74 for( i = 1; i < cnt; i++ ) { \
75 _size += segs[i].seg_len; \
76 } \
77 \
78 if(_size <= mca_pml_ob1.unexpected_limit ) { \
79 macro_segments[0].seg_addr.pval = frag->addr; \
80 } else { \
81 buffers[0].len = _size; \
82 buffers[0].addr = (char*) \
83 mca_pml_ob1.allocator->alc_alloc( mca_pml_ob1.allocator, \
84 buffers[0].len, \
85 0); \
86 _ptr = (unsigned char*)(buffers[0].addr); \
87 macro_segments[0].seg_addr.pval = buffers[0].addr; \
88 } \
89 macro_segments[0].seg_len = _size; \
90 for( i = 0; i < cnt; i++ ) { \
91 memcpy( _ptr, segs[i].seg_addr.pval, segs[i].seg_len); \
92 _ptr += segs[i].seg_len; \
93 } \
94 } while(0)
95
96
97 #define MCA_PML_OB1_RECV_FRAG_RETURN(frag) \
98 do { \
99 if( frag->segments[0].seg_len > mca_pml_ob1.unexpected_limit ) { \
100 \
101 mca_pml_ob1.allocator->alc_free( mca_pml_ob1.allocator, \
102 frag->buffers[0].addr ); \
103 } \
104 frag->num_segments = 0; \
105 \
106 \
107 opal_free_list_return (&mca_pml_ob1.recv_frags, \
108 (opal_free_list_item_t*)frag); \
109 } while(0)
110
111
112
113
114
115
116 extern void mca_pml_ob1_recv_frag_callback_match( mca_btl_base_module_t *btl,
117 mca_btl_base_tag_t tag,
118 mca_btl_base_descriptor_t* descriptor,
119 void* cbdata );
120
121
122
123
124
125 extern void mca_pml_ob1_recv_frag_callback_rndv( mca_btl_base_module_t *btl,
126 mca_btl_base_tag_t tag,
127 mca_btl_base_descriptor_t* descriptor,
128 void* cbdata );
129
130
131
132
133 extern void mca_pml_ob1_recv_frag_callback_rget( mca_btl_base_module_t *btl,
134 mca_btl_base_tag_t tag,
135 mca_btl_base_descriptor_t* descriptor,
136 void* cbdata );
137
138
139
140
141
142 extern void mca_pml_ob1_recv_frag_callback_ack( mca_btl_base_module_t *btl,
143 mca_btl_base_tag_t tag,
144 mca_btl_base_descriptor_t* descriptor,
145 void* cbdata );
146
147
148
149
150 extern void mca_pml_ob1_recv_frag_callback_frag( mca_btl_base_module_t *btl,
151 mca_btl_base_tag_t tag,
152 mca_btl_base_descriptor_t* descriptor,
153 void* cbdata );
154
155
156
157
158 extern void mca_pml_ob1_recv_frag_callback_put( mca_btl_base_module_t *btl,
159 mca_btl_base_tag_t tag,
160 mca_btl_base_descriptor_t* descriptor,
161 void* cbdata );
162
163
164
165
166 extern void mca_pml_ob1_recv_frag_callback_fin( mca_btl_base_module_t *btl,
167 mca_btl_base_tag_t tag,
168 mca_btl_base_descriptor_t* descriptor,
169 void* cbdata );
170
171
172
173
174
175 extern mca_pml_ob1_recv_frag_t*
176 check_cantmatch_for_match(mca_pml_ob1_comm_proc_t *proc);
177
178 void append_frag_to_ordered_list(mca_pml_ob1_recv_frag_t** queue,
179 mca_pml_ob1_recv_frag_t* frag,
180 uint16_t seq);
181
182 extern void mca_pml_ob1_dump_cant_match(mca_pml_ob1_recv_frag_t* queue);
183 END_C_DECLS
184
185 #endif
186