Skip to content

Commit

Permalink
team_context example: improve return value checks
Browse files Browse the repository at this point in the history
Signed-off-by: David M. Ozog <[email protected]>
  • Loading branch information
davidozog committed Mar 16, 2020
1 parent 4ce9805 commit d3b8242
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions example_code/shmem_team_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,33 @@ int main(void)
long cmask = SHMEM_TEAM_NUM_CONTEXTS;

/* Create team_2 with PEs numbered 0, 2, 4, ... */
shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, (npes + 1) / 2, &conf, cmask, &team_2);
int ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, (npes + 1) / 2, &conf, cmask, &team_2);

if (ret != 0) {
printf("%d: Error creating team team_2 (%d)\n", mype, ret);
shmem_global_exit(ret);
}

/* Create team_3 with PEs numbered 0, 3, 6, ... */
shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 3, (npes + 2) / 3, &conf, cmask, &team_3);
ret = shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 3, (npes + 2) / 3, &conf, cmask, &team_3);

if (ret != 0) {
printf("%d: Error creating team team_3 (%d)\n", mype, ret);
shmem_global_exit(ret);
}

/* Create a context on team_2. */
int ret = shmem_team_create_ctx(team_2, 0, &ctx_2);
ret = shmem_team_create_ctx(team_2, 0, &ctx_2);

if (ret != 0) {
if (ret != 0 && team_2 != SHMEM_TEAM_INVALID) {
printf("%d: Error creating context ctx_2 (%d)\n", mype, ret);
shmem_global_exit(ret);
}

/* Create a context on team_3. */
ret = shmem_team_create_ctx(team_3, 0, &ctx_3);

if (ret != 0) {
if (ret != 0 && team_3 != SHMEM_TEAM_INVALID) {
printf("%d: Error creating context ctx_3 (%d)\n", mype, ret);
shmem_global_exit(ret);
}
Expand Down

0 comments on commit d3b8242

Please sign in to comment.