Skip to content

Commit fd9eb39

Browse files
committed
Avoid datatype pack/unpack for contiguous data on homogenous systems.
Signed-off-by: Jithin Jose <[email protected]>
1 parent bc105af commit fd9eb39

File tree

3 files changed

+76
-4
lines changed

3 files changed

+76
-4
lines changed

ompi/mca/mtl/base/mtl_base_datatype.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ ompi_mtl_datatype_pack(struct opal_convertor_t *convertor,
3838
struct iovec iov;
3939
uint32_t iov_count = 1;
4040

41+
#if !(OPAL_ENABLE_HETEROGENEOUS_SUPPORT)
42+
if (convertor->pDesc &&
43+
opal_datatype_is_contiguous_memory_layout(convertor->pDesc,
44+
convertor->count)) {
45+
*freeAfter = false;
46+
*buffer = convertor->pBaseBuf;
47+
*buffer_len = convertor->local_size;
48+
return OPAL_SUCCESS;
49+
}
50+
#endif
51+
4152
opal_convertor_get_packed_size(convertor, buffer_len);
4253
*freeAfter = false;
4354
if( 0 == *buffer_len ) {

ompi/mca/pml/cm/pml_cm_send.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,26 @@ mca_pml_cm_send(void *buf,
153153
opal_convertor_t convertor;
154154
ompi_proc_t *ompi_proc = ompi_comm_peer_lookup(comm, dst);
155155

156-
opal_convertor_copy_and_prepare_for_send(
156+
#if !(OPAL_ENABLE_HETEROGENEOUS_SUPPORT)
157+
if (opal_datatype_is_contiguous_memory_layout(&datatype->super, count)) {
158+
159+
convertor.remoteArch = ompi_proc->super.proc_convertor->remoteArch;
160+
convertor.flags = ompi_proc->super.proc_convertor->flags;
161+
convertor.master = ompi_proc->super.proc_convertor->master;
162+
163+
convertor.local_size = count * datatype->super.size;
164+
convertor.pBaseBuf = (unsigned char*)buf;
165+
convertor.count = count;
166+
convertor.pDesc = &datatype->super;
167+
} else
168+
#endif
169+
{
170+
opal_convertor_copy_and_prepare_for_send(
157171
ompi_proc->super.proc_convertor,
158-
&datatype->super, count, buf, 0,
159-
&convertor);
160-
172+
&datatype->super, count, buf, 0,
173+
&convertor);
174+
}
175+
161176
ret = OMPI_MTL_CALL(send(ompi_mtl,
162177
comm,
163178
dst,

ompi/mca/pml/cm/pml_cm_sendreq.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ do { \
9292
}
9393

9494

95+
#if (OPAL_ENABLE_HETEROGENEOUS_SUPPORT)
9596
#define MCA_PML_CM_SEND_REQUEST_INIT_COMMON(req_send, \
9697
ompi_proc, \
9798
comm, \
@@ -121,6 +122,51 @@ do { \
121122
(req_send)->req_base.req_free_called = false; \
122123
}
123124

125+
#else
126+
#define MCA_PML_CM_SEND_REQUEST_INIT_COMMON(req_send, \
127+
ompi_proc, \
128+
comm, \
129+
tag, \
130+
datatype, \
131+
sendmode, \
132+
buf, \
133+
count) \
134+
{ \
135+
OBJ_RETAIN(comm); \
136+
OBJ_RETAIN(datatype); \
137+
(req_send)->req_base.req_comm = comm; \
138+
(req_send)->req_base.req_datatype = datatype; \
139+
if (opal_datatype_is_contiguous_memory_layout(&datatype->super, count)) { \
140+
(req_send)->req_base.req_convertor.remoteArch = \
141+
ompi_proc->super.proc_convertor->remoteArch; \
142+
(req_send)->req_base.req_convertor.flags = \
143+
ompi_proc->super.proc_convertor->flags; \
144+
(req_send)->req_base.req_convertor.master = \
145+
ompi_proc->super.proc_convertor->master; \
146+
(req_send)->req_base.req_convertor.local_size = \
147+
count * datatype->super.size; \
148+
(req_send)->req_base.req_convertor.pBaseBuf = (unsigned char*)buf; \
149+
(req_send)->req_base.req_convertor.count = count; \
150+
(req_send)->req_base.req_convertor.pDesc = &datatype->super; \
151+
} else { \
152+
opal_convertor_copy_and_prepare_for_send( \
153+
ompi_proc->super.proc_convertor, \
154+
&(datatype->super), \
155+
count, \
156+
buf, \
157+
0, \
158+
&(req_send)->req_base.req_convertor ); \
159+
} \
160+
(req_send)->req_base.req_ompi.req_mpi_object.comm = comm; \
161+
(req_send)->req_base.req_ompi.req_status.MPI_SOURCE = \
162+
comm->c_my_rank; \
163+
(req_send)->req_base.req_ompi.req_status.MPI_TAG = tag; \
164+
(req_send)->req_base.req_ompi.req_status._ucount = count; \
165+
(req_send)->req_send_mode = sendmode; \
166+
(req_send)->req_base.req_free_called = false; \
167+
}
168+
#endif
169+
124170
#define MCA_PML_CM_HVY_SEND_REQUEST_INIT( sendreq, \
125171
ompi_proc, \
126172
comm, \

0 commit comments

Comments
 (0)