diff --git a/content/shmem_ctx_create.tex b/content/shmem_ctx_create.tex index a6298a921..37316e884 100644 --- a/content/shmem_ctx_create.tex +++ b/content/shmem_ctx_create.tex @@ -1,5 +1,5 @@ \apisummary{ - Create a communication context locally. + Create a communication context. } \begin{apidefinition} diff --git a/content/shmem_sync.tex b/content/shmem_sync.tex index ceacc2115..310e3b674 100644 --- a/content/shmem_sync.tex +++ b/content/shmem_sync.tex @@ -1,8 +1,7 @@ \apisummary{ - Registers the arrival of a \ac{PE} at a synchronization point and suspends - execution until all other \acp{PE} in a given \openshmem team or active set - arrive at a synchronization point. For multithreaded programs, execution is suspended - as specified by the threading model (Section \ref{subsec:thread_support}). + Registers the arrival of a \ac{PE} at a synchronization point. + This routine does not return until all other \acp{PE} in a given OpenSHMEM team + or active set arrive at this synchronization point. } \begin{apidefinition} diff --git a/content/shmem_team_create_ctx.tex b/content/shmem_team_create_ctx.tex index dce63be92..f92eb45d3 100644 --- a/content/shmem_team_create_ctx.tex +++ b/content/shmem_team_create_ctx.tex @@ -1,5 +1,5 @@ \apisummary{ - Create a communication context from a team locally. + Create a communication context from a team. } \begin{apidefinition} @@ -20,7 +20,8 @@ \apidescription{ The \FUNC{shmem\_team\_create\_ctx} routine creates a new communication context and returns its handle through the \VAR{ctx} argument. - This context is created from the team specified by the \VAR{team} argument. + This context is created from the team specified by the \VAR{team} argument; + however, the context creation operation is not collective. In addition to the team, the \FUNC{shmem\_team\_create\_ctx} routine accepts the same arguments and provides all the same return conditions as the diff --git a/content/teams_intro.tex b/content/teams_intro.tex index ddca69dcc..82ce2d4a7 100644 --- a/content/teams_intro.tex +++ b/content/teams_intro.tex @@ -80,9 +80,9 @@ \subsubsection*{Team Creation} This configuration argument is of type \CTYPE{shmem\_team\_config\_t}, which is detailed further in Section~\ref{subsec:shmem_team_config_t}. -\acp{PE} in a newly created teams are consecutively numbered with starting with -\ac{PE} number 0. \acp{PE} are always ordered by the existing global \ac{PE} number that -would be returned by the \FUNC{shmem\_my\_pe} routine. Team relative \ac{PE} +\acp{PE} in a newly created team are consecutively numbered starting with +\ac{PE} number 0. \acp{PE} are ordered by their \ac{PE} number in +the parent team. Team relative \ac{PE} numbers can be used for point-to-point operations through team-based contexts (see Section~\ref{sec:ctx}) or using the translation routine \FUNC{shmem\_team\_translate\_pe}. diff --git a/example_code/shmem_sync_example.c b/example_code/shmem_sync_example.c index 2e367a428..9f8f7fcf5 100644 --- a/example_code/shmem_sync_example.c +++ b/example_code/shmem_sync_example.c @@ -5,7 +5,8 @@ int main(void) { static int x = 10101; - shmem_team_t twos_team, threes_team; + shmem_team_t twos_team = SHMEM_TEAM_INVALID; + shmem_team_t threes_team = SHMEM_TEAM_INVALID; shmem_team_config_t *config; shmem_init(); @@ -13,36 +14,42 @@ int main(void) int me = shmem_my_pe(); int npes = shmem_n_pes(); - int odd_npes = npes % 2; + if (npes > 2) + shmem_team_split_strided(SHMEM_TEAM_WORLD, 2, 2, (npes-1) / 2, config, + 0, &twos_team); - shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 2, npes / 2, config, 0, - &twos_team); + if (npes > 3) + shmem_team_split_strided(SHMEM_TEAM_WORLD, 3, 3, (npes-1) / 3, config, + 0, &threes_team); - shmem_team_split_strided(SHMEM_TEAM_WORLD, 0, 3, npes / 3 + odd_npes, - config, 0, &threes_team); - - int my_pe_twos = shmem_team_my_pe(twos_team); + int my_pe_twos = shmem_team_my_pe(twos_team); int my_pe_threes = shmem_team_my_pe(threes_team); + int npes_twos = shmem_team_n_pes(twos_team); + int npes_threes = shmem_team_n_pes(threes_team); if (twos_team != SHMEM_TEAM_INVALID) { /* put the value 2 to the next team member in a circular fashion */ - shmem_p(&x, 2, (me + 2) % npes); + shmem_p(&x, 2, shmem_team_translate_pe(twos_team, (my_pe_twos + 1) % + npes_twos, SHMEM_TEAM_WORLD)); shmem_quiet(); shmem_sync(twos_team); } + shmem_sync(SHMEM_TEAM_WORLD); + if (threes_team != SHMEM_TEAM_INVALID) { /* put the value 3 to the next team member in a circular fashion */ - shmem_p(&x, 3, (me + 3) % npes); + shmem_p(&x, 3, shmem_team_translate_pe(threes_team, (my_pe_threes + 1) % + npes_threes, SHMEM_TEAM_WORLD)); shmem_quiet(); shmem_sync(threes_team); } - if (me % 3 == 0 && x != 3) { - shmem_global_exit(3); + if (me && me % 3 == 0) { + if (x != 3) shmem_global_exit(3); } - else if (me % 2 == 0 && x != 2) { - shmem_global_exit(2); + else if (me && me % 2 == 0) { + if (x != 2) shmem_global_exit(2); } else if (x != 10101) { shmem_global_exit(1); diff --git a/example_code/shmem_team_context.c b/example_code/shmem_team_context.c index 57d8c9621..5b1e07ffc 100644 --- a/example_code/shmem_team_context.c +++ b/example_code/shmem_team_context.c @@ -11,7 +11,7 @@ int my_ctx_translate_pe(shmem_ctx_t src_ctx, int src_pe, shmem_ctx_t dest_ctx) if (dest_ctx == SHMEM_CTX_INVALID) { return -1; } - + shmem_team_t src_team, dest_team; shmem_ctx_get_team(src_ctx, &src_team); shmem_ctx_get_team(dest_ctx, &dest_team); @@ -37,7 +37,7 @@ void my_send_to_neighbor(shmem_ctx_t ctx, int *val) fprintf (stderr, "Send to neighbor fail due to invalid context\n"); return; } - + shmem_team_t team; shmem_ctx_get_team(ctx, &team); int pe = shmem_team_my_pe(team); @@ -56,7 +56,7 @@ int main() int npes = shmem_n_pes(); isum = 0; - + shmem_team_t team_2s, team_3s; shmem_ctx_t ctx_2s, ctx_3s; shmem_team_config_t conf; @@ -76,7 +76,7 @@ int main() my_send_to_neighbor(ctx_3s, &ival3); // Quiet all contexts and synchronize all PEs to complete the data transfers - shmem_ctx_quiet(ctx_2s); + shmem_ctx_quiet(ctx_2s); shmem_ctx_quiet(ctx_3s); shmem_team_sync(SHMEM_TEAM_WORLD); @@ -89,10 +89,10 @@ int main() } else { // Add up the results on pe 4 of the 3s team, using the 2s team context - shmem_ctx_int_atomic_add(ctx_2s, &isum, ival2 + ival3, _pe4_of_3s_in_2s); + shmem_ctx_int_atomic_add(ctx_2s, &isum, ival2 + ival3, pe4_of_3s_in_2s); } } - + // Quiet the context and synchronize PEs to complete the operation shmem_ctx_quiet(ctx_2s); shmem_team_sync(SHMEM_TEAM_WORLD);