Skip to content

Commit

Permalink
Update all-to-all unit tests with proper indexing
Browse files Browse the repository at this point in the history
Update tests to expect data to be read/written from/to the first PE_size
blocks in the source and destination buffers.

Signed-off-by: James Dinan <james.dinan@intel.com>
  • Loading branch information
James Dinan committed Feb 12, 2016
1 parent 1b1b2ce commit 2f9a9de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion test/unit/alltoall.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ static int is_active(int pe, int pe_start, int pe_stride, int pe_size) {
return pe >= pe_start && pe < pe_start + pe_size * stride && (pe - pe_start) % stride == 0;
}

/* Tranlate a group PE index to a global PE rank. */
static int pe_group_to_world(int group_pe, int pe_start, int pe_stride, int pe_size) {
int stride = 1 << pe_stride;

return group_pe >= pe_size ? -1 : pe_start + group_pe * stride;
}

static void alltoall_test(int32_t *out, int32_t *in, int pe_start, int pe_stride,
int pe_size)
{
Expand All @@ -63,7 +70,7 @@ static void alltoall_test(int32_t *out, int32_t *in, int pe_start, int pe_stride
int expected;

if (is_active(me, pe_start, pe_stride, pe_size))
expected = is_active(i, pe_start, pe_stride, pe_size) ? i : -1;
expected = pe_group_to_world(i, pe_start, pe_stride, pe_size);
else
expected = -1;

Expand Down
9 changes: 8 additions & 1 deletion test/unit/alltoalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ static int is_active(int pe, int pe_start, int pe_stride, int pe_size) {
return pe >= pe_start && pe < pe_start + pe_size * stride && (pe - pe_start) % stride == 0;
}

/* Tranlate a group PE index to a global PE rank. */
static int pe_group_to_world(int group_pe, int pe_start, int pe_stride, int pe_size) {
int stride = 1 << pe_stride;

return group_pe >= pe_size ? -1 : pe_start + group_pe * stride;
}

static void alltoalls_test(int32_t *out, int32_t *in, int dst, int sst, int nelem,
int pe_start, int pe_stride, int pe_size)
{
Expand Down Expand Up @@ -70,7 +77,7 @@ static void alltoalls_test(int32_t *out, int32_t *in, int dst, int sst, int nele
for (k = 0; k < dst; k++) {
int idx = i*dst*nelem + j*dst + k;
if (is_active(me, pe_start, pe_stride, pe_size))
expected = (k == 0 && is_active(i, pe_start, pe_stride, pe_size)) ? i : -1;
expected = (k % dst == 0) ? pe_group_to_world(i, pe_start, pe_stride, pe_size) : -1;
else
expected = -1;

Expand Down

0 comments on commit 2f9a9de

Please sign in to comment.