Skip to content

Commit 0704389

Browse files
committed
Avoid extra lookup for ompi_proc in homogenous build
Signed-off-by: Jithin Jose <[email protected]>
1 parent 5008997 commit 0704389

File tree

3 files changed

+135
-26
lines changed

3 files changed

+135
-26
lines changed

ompi/mca/pml/cm/pml_cm.h

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ mca_pml_cm_irecv_init(void *addr,
7474
struct ompi_request_t **request)
7575
{
7676
mca_pml_cm_hvy_recv_request_t *recvreq;
77+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
7778
ompi_proc_t* ompi_proc;
79+
#endif
7880

7981
MCA_PML_CM_HVY_RECV_REQUEST_ALLOC(recvreq);
8082
if( OPAL_UNLIKELY(NULL == recvreq) ) return OMPI_ERR_OUT_OF_RESOURCE;
@@ -98,8 +100,10 @@ mca_pml_cm_irecv(void *addr,
98100
{
99101
int ret;
100102
mca_pml_cm_thin_recv_request_t *recvreq;
101-
ompi_proc_t* ompi_proc;
102-
103+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
104+
ompi_proc_t* ompi_proc = NULL;
105+
#endif
106+
103107
MCA_PML_CM_THIN_RECV_REQUEST_ALLOC(recvreq);
104108
if( OPAL_UNLIKELY(NULL == recvreq) ) return OMPI_ERR_OUT_OF_RESOURCE;
105109

@@ -136,7 +140,9 @@ mca_pml_cm_recv(void *addr,
136140
ompi_status_public_t * status)
137141
{
138142
int ret;
143+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
139144
ompi_proc_t *ompi_proc;
145+
#endif
140146
opal_convertor_t convertor;
141147
mca_pml_cm_request_t req;
142148
mca_mtl_request_t *req_mtl =
@@ -154,19 +160,30 @@ mca_pml_cm_recv(void *addr,
154160
req.req_ompi.req_status.MPI_ERROR = OMPI_SUCCESS;
155161
req.req_ompi.req_status._cancelled = 0;
156162

163+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
157164
if( MPI_ANY_SOURCE == src ) {
158165
ompi_proc = ompi_proc_local_proc;
159166
} else {
160167
ompi_proc = ompi_comm_peer_lookup( comm, src );
161168
}
162169

163170
opal_convertor_copy_and_prepare_for_recv(
164-
ompi_proc->super.proc_convertor,
165-
&(datatype->super),
166-
count,
167-
addr,
168-
0,
169-
&convertor );
171+
ompi_proc->super.proc_convertor,
172+
&(datatype->super),
173+
count,
174+
addr,
175+
0,
176+
&convertor );
177+
#else
178+
opal_convertor_copy_and_prepare_for_recv(
179+
ompi_mpi_local_convertor,
180+
&(datatype->super),
181+
count,
182+
addr,
183+
0,
184+
&convertor );
185+
#endif
186+
170187
ret = OMPI_MTL_CALL(irecv(ompi_mtl,
171188
comm,
172189
src,
@@ -198,7 +215,9 @@ mca_pml_cm_isend_init(void* buf,
198215
ompi_request_t** request)
199216
{
200217
mca_pml_cm_hvy_send_request_t *sendreq;
218+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
201219
ompi_proc_t* ompi_proc;
220+
#endif
202221

203222
MCA_PML_CM_HVY_SEND_REQUEST_ALLOC(sendreq, comm, dst, ompi_proc);
204223
if (OPAL_UNLIKELY(NULL == sendreq)) return OMPI_ERR_OUT_OF_RESOURCE;
@@ -225,7 +244,9 @@ mca_pml_cm_isend(void* buf,
225244

226245
if(sendmode == MCA_PML_BASE_SEND_BUFFERED ) {
227246
mca_pml_cm_hvy_send_request_t* sendreq;
228-
ompi_proc_t* ompi_proc;
247+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
248+
ompi_proc_t* ompi_proc = NULL;
249+
#endif
229250

230251
MCA_PML_CM_HVY_SEND_REQUEST_ALLOC(sendreq, comm, dst, ompi_proc);
231252
if (OPAL_UNLIKELY(NULL == sendreq)) return OMPI_ERR_OUT_OF_RESOURCE;
@@ -248,7 +269,9 @@ mca_pml_cm_isend(void* buf,
248269

249270
} else {
250271
mca_pml_cm_thin_send_request_t* sendreq;
251-
ompi_proc_t* ompi_proc;
272+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
273+
ompi_proc_t* ompi_proc = NULL;
274+
#endif
252275
MCA_PML_CM_THIN_SEND_REQUEST_ALLOC(sendreq, comm, dst, ompi_proc);
253276
if (OPAL_UNLIKELY(NULL == sendreq)) return OMPI_ERR_OUT_OF_RESOURCE;
254277

@@ -288,10 +311,11 @@ mca_pml_cm_send(void *buf,
288311
ompi_communicator_t* comm)
289312
{
290313
int ret = OMPI_ERROR;
314+
ompi_proc_t * ompi_proc;
291315

292316
if(sendmode == MCA_PML_BASE_SEND_BUFFERED) {
293317
mca_pml_cm_hvy_send_request_t *sendreq;
294-
ompi_proc_t * ompi_proc;
318+
295319
MCA_PML_CM_HVY_SEND_REQUEST_ALLOC(sendreq, comm, dst, ompi_proc);
296320
if (OPAL_UNLIKELY(NULL == sendreq)) return OMPI_ERR_OUT_OF_RESOURCE;
297321

@@ -315,14 +339,13 @@ mca_pml_cm_send(void *buf,
315339
ompi_request_free( (ompi_request_t**)&sendreq );
316340
} else {
317341
opal_convertor_t convertor;
318-
ompi_proc_t *ompi_proc = ompi_comm_peer_lookup(comm, dst);
319342

320343
#if !(OPAL_ENABLE_HETEROGENEOUS_SUPPORT)
321344
if (opal_datatype_is_contiguous_memory_layout(&datatype->super, count)) {
322345

323-
convertor.remoteArch = ompi_proc->super.proc_convertor->remoteArch;
324-
convertor.flags = ompi_proc->super.proc_convertor->flags;
325-
convertor.master = ompi_proc->super.proc_convertor->master;
346+
convertor.remoteArch = ompi_mpi_local_convertor->remoteArch;
347+
convertor.flags = ompi_mpi_local_convertor->flags;
348+
convertor.master = ompi_mpi_local_convertor->master;
326349

327350
convertor.local_size = count * datatype->super.size;
328351
convertor.pBaseBuf = (unsigned char*)buf;
@@ -331,6 +354,7 @@ mca_pml_cm_send(void *buf,
331354
} else
332355
#endif
333356
{
357+
ompi_proc = ompi_comm_peer_lookup(comm, dst);
334358
opal_convertor_copy_and_prepare_for_send(
335359
ompi_proc->super.proc_convertor,
336360
&datatype->super, count, buf, 0,
@@ -422,17 +446,18 @@ mca_pml_cm_imrecv(void *buf,
422446
{
423447
int ret;
424448
mca_pml_cm_thin_recv_request_t *recvreq;
449+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
425450
ompi_proc_t* ompi_proc;
451+
#endif
426452
ompi_communicator_t *comm = (*message)->comm;
427-
int peer = (*message)->peer;
428453

429454
MCA_PML_CM_THIN_RECV_REQUEST_ALLOC(recvreq);
430455
if( OPAL_UNLIKELY(NULL == recvreq) ) return OMPI_ERR_OUT_OF_RESOURCE;
431456

432457
MCA_PML_CM_THIN_RECV_REQUEST_INIT(recvreq,
433458
ompi_proc,
434459
comm,
435-
peer,
460+
(*message)->peer,
436461
datatype,
437462
buf,
438463
count);
@@ -453,17 +478,18 @@ mca_pml_cm_mrecv(void *buf,
453478
{
454479
int ret;
455480
mca_pml_cm_thin_recv_request_t *recvreq;
481+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
456482
ompi_proc_t* ompi_proc;
483+
#endif
457484
ompi_communicator_t *comm = (*message)->comm;
458-
int peer = (*message)->peer;
459485

460486
MCA_PML_CM_THIN_RECV_REQUEST_ALLOC(recvreq);
461487
if( OPAL_UNLIKELY(NULL == recvreq) ) return OMPI_ERR_OUT_OF_RESOURCE;
462488

463489
MCA_PML_CM_THIN_RECV_REQUEST_INIT(recvreq,
464490
ompi_proc,
465491
comm,
466-
peer,
492+
(*message)->peer,
467493
datatype,
468494
buf,
469495
count);

ompi/mca/pml/cm/pml_cm_recvreq.h

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ do { \
8585
* @param comm (IN) Communicator.
8686
* @param persistent (IN) Is this a ersistent request.
8787
*/
88+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
8889
#define MCA_PML_CM_THIN_RECV_REQUEST_INIT( request, \
8990
ompi_proc, \
9091
comm, \
@@ -115,7 +116,35 @@ do { \
115116
0, \
116117
&(request)->req_base.req_convertor ); \
117118
} while(0)
119+
#else
120+
#define MCA_PML_CM_THIN_RECV_REQUEST_INIT( request, \
121+
ompi_proc, \
122+
comm, \
123+
src, \
124+
datatype, \
125+
addr, \
126+
count ) \
127+
do { \
128+
OMPI_REQUEST_INIT(&(request)->req_base.req_ompi, false); \
129+
(request)->req_base.req_ompi.req_mpi_object.comm = comm; \
130+
(request)->req_base.req_pml_complete = false; \
131+
(request)->req_base.req_free_called = false; \
132+
request->req_base.req_comm = comm; \
133+
request->req_base.req_datatype = datatype; \
134+
OBJ_RETAIN(comm); \
135+
OBJ_RETAIN(datatype); \
136+
\
137+
opal_convertor_copy_and_prepare_for_recv( \
138+
ompi_mpi_local_convertor, \
139+
&(datatype->super), \
140+
count, \
141+
addr, \
142+
0, \
143+
&(request)->req_base.req_convertor ); \
144+
} while(0)
145+
#endif
118146

147+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
119148
#define MCA_PML_CM_HVY_RECV_REQUEST_INIT( request, \
120149
ompi_proc, \
121150
comm, \
@@ -152,7 +181,39 @@ do { \
152181
0, \
153182
&(request)->req_base.req_convertor ); \
154183
} while(0)
155-
184+
#else
185+
#define MCA_PML_CM_HVY_RECV_REQUEST_INIT( request, \
186+
ompi_proc, \
187+
comm, \
188+
tag, \
189+
src, \
190+
datatype, \
191+
addr, \
192+
count, \
193+
persistent) \
194+
do { \
195+
OMPI_REQUEST_INIT(&(request)->req_base.req_ompi, persistent); \
196+
(request)->req_base.req_ompi.req_mpi_object.comm = comm; \
197+
(request)->req_base.req_pml_complete = OPAL_INT_TO_BOOL(persistent); \
198+
(request)->req_base.req_free_called = false; \
199+
request->req_base.req_comm = comm; \
200+
request->req_base.req_datatype = datatype; \
201+
request->req_tag = tag; \
202+
request->req_peer = src; \
203+
request->req_addr = addr; \
204+
request->req_count = count; \
205+
OBJ_RETAIN(comm); \
206+
OBJ_RETAIN(datatype); \
207+
\
208+
opal_convertor_copy_and_prepare_for_recv( \
209+
ompi_mpi_local_convertor, \
210+
&(datatype->super), \
211+
count, \
212+
addr, \
213+
0, \
214+
&(request)->req_base.req_convertor ); \
215+
} while(0)
216+
#endif
156217

157218
/**
158219
* Start an initialized request.
@@ -315,7 +376,6 @@ do { \
315376
}
316377

317378
extern void mca_pml_cm_recv_request_completion(struct mca_mtl_request_t *mtl_request);
318-
extern void mca_pml_cm_recv_fast_completion(struct mca_mtl_request_t *mtl_request);
319379

320380
#endif
321381

ompi/mca/pml/cm/pml_cm_sendreq.h

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ typedef struct mca_pml_cm_hvy_send_request_t mca_pml_cm_hvy_send_request_t;
5959
OBJ_CLASS_DECLARATION(mca_pml_cm_hvy_send_request_t);
6060

6161

62+
#if OPAL_ENABLE_HETEROGENEOUS_SUPPORT
6263
#define MCA_PML_CM_THIN_SEND_REQUEST_ALLOC(sendreq, comm, dst, \
6364
ompi_proc) \
6465
do { \
@@ -74,8 +75,20 @@ do { \
7475
sendreq->req_mtl.completion_callback = mca_pml_cm_send_request_completion; \
7576
} \
7677
} while(0)
78+
#else
79+
#define MCA_PML_CM_THIN_SEND_REQUEST_ALLOC(sendreq, comm, dst, \
80+
ompi_proc) \
81+
do { \
82+
sendreq = (mca_pml_cm_thin_send_request_t*) \
83+
opal_free_list_wait (&mca_pml_base_send_requests); \
84+
sendreq->req_send.req_base.req_pml_type = MCA_PML_CM_REQUEST_SEND_THIN; \
85+
sendreq->req_mtl.ompi_req = (ompi_request_t*) sendreq; \
86+
sendreq->req_mtl.completion_callback = mca_pml_cm_send_request_completion; \
87+
} while(0)
88+
#endif
7789

7890

91+
#if (OPAL_ENABLE_HETEROGENEOUS_SUPPORT)
7992
#define MCA_PML_CM_HVY_SEND_REQUEST_ALLOC(sendreq, comm, dst, \
8093
ompi_proc) \
8194
{ \
@@ -90,7 +103,17 @@ do { \
90103
sendreq->req_mtl.completion_callback = mca_pml_cm_send_request_completion; \
91104
} \
92105
}
93-
106+
#else
107+
#define MCA_PML_CM_HVY_SEND_REQUEST_ALLOC(sendreq, comm, dst, \
108+
ompi_proc) \
109+
{ \
110+
sendreq = (mca_pml_cm_hvy_send_request_t*) \
111+
opal_free_list_wait (&mca_pml_base_send_requests); \
112+
sendreq->req_send.req_base.req_pml_type = MCA_PML_CM_REQUEST_SEND_HEAVY; \
113+
sendreq->req_mtl.ompi_req = (ompi_request_t*) sendreq; \
114+
sendreq->req_mtl.completion_callback = mca_pml_cm_send_request_completion; \
115+
}
116+
#endif
94117

95118
#if (OPAL_ENABLE_HETEROGENEOUS_SUPPORT)
96119
#define MCA_PML_CM_SEND_REQUEST_INIT_COMMON(req_send, \
@@ -138,19 +161,19 @@ do { \
138161
(req_send)->req_base.req_datatype = datatype; \
139162
if (opal_datatype_is_contiguous_memory_layout(&datatype->super, count)) { \
140163
(req_send)->req_base.req_convertor.remoteArch = \
141-
ompi_proc->super.proc_convertor->remoteArch; \
164+
ompi_mpi_local_convertor->remoteArch; \
142165
(req_send)->req_base.req_convertor.flags = \
143-
ompi_proc->super.proc_convertor->flags; \
166+
ompi_mpi_local_convertor->flags; \
144167
(req_send)->req_base.req_convertor.master = \
145-
ompi_proc->super.proc_convertor->master; \
168+
ompi_mpi_local_convertor->master; \
146169
(req_send)->req_base.req_convertor.local_size = \
147170
count * datatype->super.size; \
148171
(req_send)->req_base.req_convertor.pBaseBuf = (unsigned char*)buf; \
149172
(req_send)->req_base.req_convertor.count = count; \
150173
(req_send)->req_base.req_convertor.pDesc = &datatype->super; \
151174
} else { \
152175
opal_convertor_copy_and_prepare_for_send( \
153-
ompi_proc->super.proc_convertor, \
176+
ompi_mpi_local_convertor, \
154177
&(datatype->super), \
155178
count, \
156179
buf, \

0 commit comments

Comments
 (0)