Skip to content

Commit 6105977

Browse files
committed
DART-MPI: call into MPI every once in a while for local put/get
1 parent 425857a commit 6105977

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

dart-impl/mpi/src/dart_communication.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
#include <math.h>
3131
#include <alloca.h>
3232

33+
/* the number of consecutive memcpy for local put/get before calling into MPI */
34+
#define NUM_CONSECUTIVE_MEMCPY 16
35+
36+
/* number of performed local memcpy between calling into MPI */
37+
static _Thread_local int num_local_memcpy = 0;
3338

3439
#define CHECK_UNITID_RANGE(_unitid, _team_data) \
3540
do { \
@@ -220,13 +225,15 @@ dart__mpi__get_basic(
220225
{
221226
if (num_reqs) *num_reqs = 0;
222227

223-
if (team_data->unitid == team_unit_id.id) {
228+
if (team_data->unitid == team_unit_id.id &&
229+
num_local_memcpy++ < NUM_CONSECUTIVE_MEMCPY) {
224230
// use direct memcpy if we are on the same unit
225231
memcpy(dest, seginfo->selfbaseptr + offset,
226232
nelem * dart__mpi__datatype_sizeof(dtype));
227233
DART_LOG_DEBUG("dart_get: memcpy nelem:%zu "
228234
"source (coll.): offset:%lu -> dest: %p",
229235
nelem, offset, dest);
236+
num_local_memcpy = 0;
230237
return DART_OK;
231238
}
232239

@@ -354,12 +361,14 @@ dart__mpi__put_basic(
354361
if (num_reqs) *num_reqs = 0;
355362

356363
/* copy data directly if we are on the same unit */
357-
if (team_unit_id.id == team_data->unitid) {
364+
if (team_unit_id.id == team_data->unitid &&
365+
num_local_memcpy++ < NUM_CONSECUTIVE_MEMCPY) {
358366
if (flush_required_ptr) *flush_required_ptr = false;
359367
memcpy(seginfo->selfbaseptr + offset, src,
360368
nelem * dart__mpi__datatype_sizeof(dtype));
361369
DART_LOG_DEBUG("dart_put: memcpy nelem:%zu (from global allocation)"
362370
"offset: %"PRIu64"", nelem, offset);
371+
num_local_memcpy = 0;
363372
return DART_OK;
364373
}
365374

0 commit comments

Comments
 (0)