Skip to content

Commit

Permalink
Merge pull request Sandia-OpenSHMEM#1136 from davidozog/pr/stride_zer…
Browse files Browse the repository at this point in the history
…o_fix

Teams: allow split stride of zero iff size is 1
  • Loading branch information
David Ozog authored Jun 18, 2024
2 parents cca11d0 + e61852e commit f3689bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion modules/tests-sos
3 changes: 2 additions & 1 deletion src/shmem_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,8 @@ void shmem_internal_bit_to_string(char *str, size_t str_size,
static inline
int shmem_internal_pe_in_active_set(int global_pe, int PE_start, int PE_stride, int PE_size)
{
shmem_internal_assert(PE_stride != 0);
if (PE_size == 1) return PE_start == global_pe ? 0 : -1;
if (PE_stride == 0) return -1;
int n = (global_pe - PE_start) / PE_stride;
if ((global_pe < PE_start && PE_stride > 0) || (global_pe > PE_start && PE_stride < 0) ||
(global_pe - PE_start) % PE_stride || n >= PE_size)
Expand Down
6 changes: 3 additions & 3 deletions src/shmem_team.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ int shmem_internal_team_split_strided(shmem_internal_team_t *parent_team, int PE

if (PE_start < 0 || PE_start >= parent_team->size ||
PE_size <= 0 || PE_size > parent_team->size ||
PE_stride == 0) {
(PE_stride == 0 && PE_size != 1)) {
RAISE_WARN_MSG("Invalid <start, stride, size>: child <%d, %d, %d>, parent <%d, %d, %d>\n",
PE_start, PE_stride, PE_size,
parent_team->start, parent_team->stride, parent_team->size);
Expand Down Expand Up @@ -332,7 +332,7 @@ int shmem_internal_team_split_strided(shmem_internal_team_t *parent_team, int PE

myteam->my_pe = my_pe;
myteam->start = global_PE_start;
myteam->stride = PE_stride;
myteam->stride = (PE_stride == 0 || PE_size == 1) ? 1 : PE_stride;
myteam->size = PE_size;

if (config_mask == 0) {
Expand Down Expand Up @@ -424,7 +424,7 @@ int shmem_internal_team_split_strided(shmem_internal_team_t *parent_team, int PE
/* If no team was available, print some team triplet info and return nonzero. */
if (my_pe >= 0 && myteam != NULL && myteam->psync_idx == -1) {
RAISE_WARN_MSG("Team split strided failed: child <%d, %d, %d>, parent <%d, %d, %d>\n",
global_PE_start, PE_stride, PE_size,
myteam->start, myteam->stride, myteam->size,
parent_team->start, parent_team->stride, parent_team->size);
}
return *team_ret_val_reduced;
Expand Down

0 comments on commit f3689bb

Please sign in to comment.