This source file includes following definitions.
- MCA_PML_YALLA_RREQ_INIT
- MCA_PML_YALLA_SREQ_INIT
- PML_YALLA_SET_RECV_STATUS
1
2
3
4
5
6
7
8
9
10
11
12
13 #ifndef PML_YALLA_REQUEST_H_
14 #define PML_YALLA_REQUEST_H_
15
16 #include "pml_yalla.h"
17 #include "pml_yalla_datatype.h"
18
19
20 #define MCA_PML_YALLA_REQUEST_FLAG_SEND 0x1
21 #define MCA_PML_YALLA_REQUEST_FLAG_BSEND 0x2
22 #define MCA_PML_YALLA_REQUEST_FLAG_FREE_CALLED 0x4
23
24 struct pml_yalla_base_request {
25 ompi_request_t ompi;
26 mca_pml_yalla_convertor_t *convertor;
27 int flags;
28 };
29
30 struct pml_yalla_send_request {
31 mca_pml_yalla_base_request_t super;
32 mxm_send_req_t mxm;
33 };
34
35 struct pml_yalla_bsend_request {
36 opal_free_list_item_t super;
37 mxm_send_req_t mxm;
38 };
39
40 struct pml_yalla_recv_request {
41 mca_pml_yalla_base_request_t super;
42 mxm_recv_req_t mxm;
43 };
44
45
46 OBJ_CLASS_DECLARATION(mca_pml_yalla_send_request_t);
47 OBJ_CLASS_DECLARATION(mca_pml_yalla_bsend_request_t);
48 OBJ_CLASS_DECLARATION(mca_pml_yalla_recv_request_t);
49
50 void mca_pml_yalla_init_reqs(void);
51
52 #define PML_YALLA_MXM_REQBASE( x ) ( &((x)->mxm.base) )
53
54 #define PML_YALLA_RESET_OMPI_REQ(_ompi_req, _state) \
55 { \
56 (_ompi_req)->req_state = _state; \
57 (_ompi_req)->req_complete = REQUEST_PENDING; \
58 (_ompi_req)->req_status._cancelled = false; \
59 }
60
61 #define PML_YALLA_INIT_OMPI_REQ(_ompi_req, _comm, _state) \
62 { \
63 PML_YALLA_RESET_OMPI_REQ(_ompi_req, _state); \
64 (_ompi_req)->req_mpi_object.comm = _comm; \
65 OBJ_RETAIN(_comm); \
66 }
67
68 #define PML_YALLA_RESET_PML_REQ(_pml_req, mxm_base) \
69 { \
70 mxm_base->state = MXM_REQ_NEW; \
71 PML_YALLA_RESET_PML_REQ_DATA(_pml_req); \
72 }
73
74 #define PML_YALLA_INIT_MXM_REQ_BASE(_req_base, _comm) \
75 { \
76 (_req_base)->state = MXM_REQ_NEW; \
77 (_req_base)->mq = (mxm_mq_h)(_comm)->c_pml_comm; \
78 }
79
80 #define PML_YALLA_PEER_CONN(_comm, _rank) \
81 ompi_comm_peer_lookup(_comm, _rank)->proc_endpoints[OMPI_PROC_ENDPOINT_TAG_PML]
82
83 #define PML_YALLA_INIT_MXM_SEND_REQ(_sreq, _buf, _count, _dtype, _rank, _tag, _mode, _comm, _stream_type, ...) \
84 { \
85 PML_YALLA_INIT_MXM_REQ_BASE(&(_sreq)->base, _comm); \
86 PML_YALLA_INIT_MXM_REQ_DATA(&(_sreq)->base, _buf, _count, _dtype, _stream_type, ## __VA_ARGS__); \
87 (_sreq)->base.conn = PML_YALLA_PEER_CONN(_comm, _rank); \
88 (_sreq)->opcode = ((_mode) == MCA_PML_BASE_SEND_SYNCHRONOUS) ? MXM_REQ_OP_SEND_SYNC : MXM_REQ_OP_SEND; \
89 (_sreq)->op.send.tag = _tag; \
90 (_sreq)->op.send.imm_data = ompi_comm_rank(_comm); \
91 }
92
93 #define PML_YALLA_INIT_MXM_RECV_REQ_ENVELOPE(_rreq, _rank, _tag, _comm) \
94 { \
95 (_rreq)->base.conn = ((_rank) == MPI_ANY_SOURCE) ? NULL : PML_YALLA_PEER_CONN(_comm, _rank); \
96 if ((_tag) == MPI_ANY_TAG) { \
97 (_rreq)->tag = 0; \
98 (_rreq)->tag_mask = 0x80000000u; \
99 } else { \
100 (_rreq)->tag = _tag; \
101 (_rreq)->tag_mask = 0xffffffffu; \
102 } \
103 }
104
105 #define PML_YALLA_INIT_MXM_RECV_REQ(_rreq, _buf, _count, _dtype, _rank, _tag, _comm, _stream_type, ...) \
106 { \
107 PML_YALLA_INIT_MXM_REQ_BASE(&(_rreq)->base, _comm); \
108 PML_YALLA_INIT_MXM_REQ_DATA(&(_rreq)->base, _buf, _count, _dtype, _stream_type, ## __VA_ARGS__); \
109 PML_YALLA_INIT_MXM_RECV_REQ_ENVELOPE(_rreq, _rank, _tag, _comm); \
110 }
111
112 #define PML_YALLA_INIT_BLOCKING_MXM_SEND_REQ(_sreq) \
113 { \
114 (_sreq)->base.completed_cb = NULL; \
115 (_sreq)->flags = MXM_REQ_SEND_FLAG_BLOCKING; \
116 }
117
118 #define PML_YALLA_INIT_BLOCKING_MXM_RECV_REQ(_rreq) \
119 { \
120 (_rreq)->base.completed_cb = NULL; \
121 }
122
123 #define PML_YALLA_FREE_BLOCKING_MXM_REQ(_req) \
124 { \
125 if ((_req)->data_type == MXM_REQ_DATA_STREAM) { \
126 mca_pml_yalla_convertor_free((mca_pml_yalla_convertor_t*)((_req)->context)); \
127 } \
128 }
129
130 static inline mca_pml_yalla_recv_request_t* MCA_PML_YALLA_RREQ_INIT(void *_buf, size_t _count, ompi_datatype_t *_datatype,
131 int _src, int _tag, struct ompi_communicator_t* _comm, int _state)
132 {
133 mca_pml_yalla_recv_request_t *rreq = (mca_pml_yalla_recv_request_t *)PML_YALLA_FREELIST_GET(&ompi_pml_yalla.recv_reqs);
134 PML_YALLA_INIT_OMPI_REQ(&rreq->super.ompi, _comm, _state);
135 PML_YALLA_INIT_MXM_RECV_REQ(&rreq->mxm, _buf, _count, _datatype, _src, _tag, _comm, irecv, rreq);
136 return rreq;
137 }
138
139 static inline mca_pml_yalla_send_request_t* MCA_PML_YALLA_SREQ_INIT(void *_buf, size_t _count, ompi_datatype_t *_datatype,
140 int _dst, int _tag, mca_pml_base_send_mode_t _mode, struct ompi_communicator_t* _comm, int _state)
141 {
142 mca_pml_yalla_send_request_t *sreq = (mca_pml_yalla_send_request_t *)PML_YALLA_FREELIST_GET(&ompi_pml_yalla.send_reqs);
143 PML_YALLA_INIT_OMPI_REQ(&sreq->super.ompi, _comm, _state);
144 PML_YALLA_INIT_MXM_SEND_REQ(&sreq->mxm, _buf, _count, _datatype, _dst, _tag, _mode, _comm, isend, sreq);
145 sreq->super.ompi.req_status.MPI_TAG = _tag;
146 sreq->super.ompi.req_status.MPI_SOURCE = (_comm)->c_my_rank;
147 sreq->super.ompi.req_status._ucount = _count;
148 return sreq;
149 }
150
151 #define PML_YALLA_INIT_MXM_PROBE_REQ(_rreq, _rank, _tag, _comm) \
152 { \
153 PML_YALLA_INIT_MXM_REQ_BASE(&(_rreq)->base, _comm); \
154 PML_YALLA_INIT_MXM_RECV_REQ_ENVELOPE(_rreq, _rank, _tag, _comm); \
155 }
156
157
158
159
160
161 #define PML_YALLA_WAIT_MXM_REQ(_req_base) \
162 { \
163 if (opal_using_threads()) { \
164 while (!mxm_req_test(_req_base)) { \
165 sched_yield(); \
166 opal_progress(); \
167 } \
168 } else if (!mxm_req_test(_req_base)) { \
169 mxm_wait_t wait; \
170 wait.progress_cb = (mxm_progress_cb_t)opal_progress; \
171 wait.progress_arg = NULL; \
172 wait.req = (_req_base); \
173 wait.state = MXM_REQ_COMPLETED; \
174 mxm_wait(&wait); \
175 } \
176 }
177
178 static inline int PML_YALLA_SET_RECV_STATUS(mxm_recv_req_t *_rreq,
179 size_t _length,
180 ompi_status_public_t *_mpi_status)
181 {
182 int rc;
183
184 switch (_rreq->base.error) {
185 case MXM_OK:
186 rc = OMPI_SUCCESS;
187 break;
188 case MXM_ERR_CANCELED:
189 rc = OMPI_SUCCESS;
190 break;
191 case MXM_ERR_MESSAGE_TRUNCATED:
192 rc = MPI_ERR_TRUNCATE;
193 break;
194 default:
195 rc = MPI_ERR_INTERN;
196 break;
197 }
198
199
200 if (_mpi_status != MPI_STATUS_IGNORE) {
201 _mpi_status->MPI_ERROR = rc;
202 if (MXM_ERR_CANCELED == _rreq->base.error) {
203 _mpi_status->_cancelled = true;
204 }
205 _mpi_status->MPI_TAG = _rreq->completion.sender_tag;
206 _mpi_status->MPI_SOURCE = _rreq->completion.sender_imm;
207 _mpi_status->_ucount = _length;
208 }
209 return rc;
210 }
211
212 #define PML_YALLA_SET_MESSAGE(_rreq, _comm, _mxm_msg, _message) \
213 { \
214 *(_message) = ompi_message_alloc(); \
215 (*(_message))->comm = (_comm); \
216 (*(_message))->count = (_rreq)->completion.sender_len; \
217 (*(_message))->peer = (_rreq)->completion.sender_imm; \
218 (*(_message))->req_ptr = (_mxm_msg); \
219 }
220
221 #define PML_YALLA_MESSAGE_RELEASE(_message) \
222 { \
223 ompi_message_return(*(_message)); \
224 *(_message) = MPI_MESSAGE_NULL; \
225 }
226
227 #endif