Skip to content

Commit

Permalink
Fix team creation with invalid parent or xrange
Browse files Browse the repository at this point in the history
* Set xrange to be less than or equal to the parent_team size
* Return nonzero in strided split when parent is invalid
* Return nonzero in 2D split when parent is invalid
* Correct shmemx_team_reuse_teams example accordingly

Signed-off-by: David M. Ozog <[email protected]>
  • Loading branch information
David M. Ozog committed Jan 7, 2020
1 parent b7c9a08 commit 65b5163
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/shmem_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ int shmem_internal_team_split_strided(shmem_internal_team_t *parent_team, int PE
*new_team = SHMEMX_TEAM_INVALID;

if (parent_team == SHMEMX_TEAM_INVALID) {
return 0;
return 1;
}

int global_PE_start = shmem_internal_team_pe(parent_team, PE_start);
Expand Down Expand Up @@ -365,6 +365,17 @@ int shmem_internal_team_split_2d(shmem_internal_team_t *parent_team, int xrange,
shmem_internal_team_t **xaxis_team, const shmemx_team_config_t *yaxis_config,
long yaxis_mask, shmem_internal_team_t **yaxis_team)
{
*xaxis_team = SHMEMX_TEAM_INVALID;
*yaxis_team = SHMEMX_TEAM_INVALID;

if (parent_team == SHMEMX_TEAM_INVALID) {
return 1;
}

if (xrange > parent_team->size) {
xrange = parent_team->size;
}

const int parent_start = parent_team->start;
const int parent_stride = parent_team->stride;
const int parent_size = parent_team->size;
Expand All @@ -373,7 +384,6 @@ int shmem_internal_team_split_2d(shmem_internal_team_t *parent_team, int xrange,

int start = 0;
int ret = 0;
*xaxis_team = SHMEMX_TEAM_INVALID;

for (int i = 0; i < num_xteams; i++) {
shmem_internal_team_t *my_xteam;
Expand All @@ -393,7 +403,6 @@ int shmem_internal_team_split_2d(shmem_internal_team_t *parent_team, int xrange,
}

start = 0;
*yaxis_team = SHMEMX_TEAM_INVALID;

for (int i = 0; i < num_yteams; i++) {
shmem_internal_team_t *my_yteam;
Expand Down
2 changes: 1 addition & 1 deletion test/shmemx/shmemx_team_reuse_teams.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(void)
}

ret = shmemx_team_split_strided(old_team, 1, 1, shmemx_team_n_pes(old_team)-1, NULL, 0, &new_team);
if (ret) ++errors;
if (old_team != SHMEMX_TEAM_INVALID && ret) ++errors;

shmemx_team_destroy(old_team);
old_team = new_team;
Expand Down

0 comments on commit 65b5163

Please sign in to comment.