Skip to content

Commit

Permalink
DART-MPI: call into MPI every once in a while for local put/get
Browse files Browse the repository at this point in the history
  • Loading branch information
devreal committed Jun 25, 2020
1 parent 425857a commit 6105977
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dart-impl/mpi/src/dart_communication.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
#include <math.h>
#include <alloca.h>

/* the number of consecutive memcpy for local put/get before calling into MPI */
#define NUM_CONSECUTIVE_MEMCPY 16

/* number of performed local memcpy between calling into MPI */
static _Thread_local int num_local_memcpy = 0;

#define CHECK_UNITID_RANGE(_unitid, _team_data) \
do { \
Expand Down Expand Up @@ -220,13 +225,15 @@ dart__mpi__get_basic(
{
if (num_reqs) *num_reqs = 0;

if (team_data->unitid == team_unit_id.id) {
if (team_data->unitid == team_unit_id.id &&
num_local_memcpy++ < NUM_CONSECUTIVE_MEMCPY) {
// use direct memcpy if we are on the same unit
memcpy(dest, seginfo->selfbaseptr + offset,
nelem * dart__mpi__datatype_sizeof(dtype));
DART_LOG_DEBUG("dart_get: memcpy nelem:%zu "
"source (coll.): offset:%lu -> dest: %p",
nelem, offset, dest);
num_local_memcpy = 0;
return DART_OK;
}

Expand Down Expand Up @@ -354,12 +361,14 @@ dart__mpi__put_basic(
if (num_reqs) *num_reqs = 0;

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

Expand Down

0 comments on commit 6105977

Please sign in to comment.