Skip to content

Commit aadeb40

Browse files
committed
Allow SYNC TEAM team-value to be a child team
1 parent 6aff6d3 commit aadeb40

File tree

4 files changed

+45
-10
lines changed

4 files changed

+45
-10
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ if(opencoarrays_aware_compiler)
744744
add_caf_test(teams_coarray_send 5 teams_coarray_send)
745745
add_caf_test(teams_coarray_send_by_ref 5 teams_coarray_send_by_ref)
746746
add_caf_test(teams_coarray_sendget 5 teams_coarray_sendget)
747+
add_caf_test(sync_team 8 sync_team)
747748
add_caf_test(alloc_comp_multidim_shape 2 alloc_comp_multidim_shape)
748749
endif()
749750
endif()

src/mpi/mpi_caf.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8324,24 +8324,25 @@ void PREFIX(sync_team) (caf_team_t *team , int unused __attribute__((unused)))
83248324
void *tmp_team;
83258325
MPI_Comm *tmp_comm;
83268326

8327-
/* Check if the team is the current, and ancestor or a descendant.
8328-
* To be implemented. */
8329-
83308327
tmp_used = used_teams;
83318328
tmp_list = (struct caf_teams_list *)*team;
83328329
tmp_team = (void *)tmp_list->team;
83338330
tmp_comm = (MPI_Comm *)tmp_team;
83348331

8335-
while (tmp_used)
8336-
{
8337-
if (tmp_used->team_list_elem == tmp_list)
8338-
break;
8339-
tmp_used = tmp_used->prev;
8340-
}
8332+
/* if the team is not a child */
8333+
if (tmp_used->team_list_elem != tmp_list->prev)
8334+
/* then search backwards through the team list, first checking if it's the
8335+
* current team, then if it is an ancestor team */
8336+
while (tmp_used)
8337+
{
8338+
if (tmp_used->team_list_elem == tmp_list)
8339+
break;
8340+
tmp_used = tmp_used->prev;
8341+
}
83418342

83428343
if (tmp_used == NULL)
83438344
caf_runtime_error("SYNC TEAM called on team different from current, "
8344-
"or ancestor, or descendant");
8345+
"or ancestor, or child");
83458346

83468347
int ierr = MPI_Barrier(*tmp_comm); chk_err(ierr);
83478348
}

src/tests/unit/teams/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ caf_compile_executable(teams_coarray_get_by_ref teams_coarray_get.f90)
66
caf_compile_executable(teams_coarray_send teams_coarray_send.f90)
77
caf_compile_executable(teams_coarray_send_by_ref teams_coarray_send.f90)
88
caf_compile_executable(teams_coarray_sendget teams_coarray_sendget.f90)
9+
caf_compile_executable(sync_team sync-team.f90)

src/tests/unit/teams/sync-team.f90

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
program main
2+
use, intrinsic :: iso_fortran_env, only: team_type
3+
implicit none
4+
integer, parameter :: PARENT_TEAM = 1, CURRENT_TEAM = 2, CHILD_TEAM = 3
5+
type(team_type) :: team(3)
6+
7+
if (num_images() < 8) error stop "I need at least 8 images to function."
8+
9+
form team (1, team(PARENT_TEAM))
10+
change team (team(PARENT_TEAM))
11+
form team (mod(this_image(),2)+1, team(CURRENT_TEAM))
12+
change team (team(CURRENT_TEAM))
13+
form team(mod(this_image(),2)+1, team(CHILD_TEAM))
14+
sync team(team(PARENT_TEAM))
15+
! change order / number of syncs between teams to try to expose deadlocks
16+
if (team_number() == 1) then
17+
sync team(team(CURRENT_TEAM))
18+
sync team(team(CHILD_TEAM))
19+
else
20+
sync team(team(CHILD_TEAM))
21+
sync team(team(CURRENT_TEAM))
22+
sync team(team(CHILD_TEAM))
23+
sync team(team(CURRENT_TEAM))
24+
end if
25+
end team
26+
end team
27+
28+
sync all
29+
30+
if (this_image() == 1) write(*,*) "Test passed."
31+
32+
end program

0 commit comments

Comments
 (0)