J3/17-148r3 To: J3 From: Jon Steidel Subject: Unclear intent for TEAM behavior Date: 2017 June 29 Discussion: This paper is a response for Ballot Comment US017. 11.1.5.2 p5 states "All active images of the current team shall execute the same CHANGE TEAM statement." It is unclear what behavior these words are trying to protect against. The synchronization rules that apply when a CHANGE TEAM statement is executed require all images of a (sub)team that will be the new current team inside the CHANGE TEAM construct arrive before any images can continue. I suspect these words are trying to prohibit something like the following: USE,INTRINSIC :: ISO_FORTRAN_ENV TYPE(TEAM_TYPE) :: team_a, team_b FORM TEAM (, team_a) FORM TEAM (, team_b) IF (MOD(THIS_IMAGE(), 2) CHANGE TEAM (team_a) ELSE CHANGE TEAM (team_b) ENDIF which is a good thing to prohibit. But they also prohibit USE,INTRINSIC :: ISO_FORTRAN_ENV TYPE(TEAM_TYPE) :: odd_even FORM TEAM (2-MOD(THIS_IMAGE(), 2) odd_even) ... IF (MOD(THIS_IMAGE(), 2) == 0) ! Set up for TEAM 2 .... CHANGE TEAM (odd_even) ! Even numbered images execute this ... END TEAM ELSE ! Set up for TEAM 1 ... CHANGE TEAM (odd_even) ! Odd numbered images execute this ! Team 1 tasks ... END TEAM ENDIF which may be a straight forward way of expressing different work for different subteams. These words do seem to permit different images on the current team to execute a CHANGE TEAM statement a differing number of times and at independent times from other images on the current team, as long as all images of the current team execute the CHANGE TEAM at least once during the execution of the program. The following appears to be conforming. All images execute the change team at least once, but team 1 enters the CHANGE TEAM construct twice while team 2 enters it once. USE,INTRINSIC :: ISO_FORTRAN_ENV TYPE(TEAM_TYPE) :: odd_even ... ! Form 2 teams, odd image indices on team 1, even indices on team 2 FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even) DO i = 1, 3 IF (2-MOD(THIS_IMAGE()) == (2-MOD(i,2))) CHANGE TEAM (odd_even) ! Team 1 executes twice, team 2 once ... END TEAM END IF END DO A simple modification of the DO loop makes it non-conforming: USE,INTRINSIC :: ISO_FORTRAN_ENV TYPE(TEAM_TYPE) :: odd_even ... ! Form 2 teams, odd image indices on team 1, even indices on team 2 FORM TEAM (2-MOD(THIS_IMAGE(), 2), odd_even) DO i = 1, 3, 2 IF (2-MOD(THIS_IMAGE()) == (2-MOD(i,2))) CHANGE TEAM (odd_even) ! Team 2 doesn't execute this ... END TEAM END IF END DO It is surprising the intent is to allow two sibling subteams to enter a CHANGE TEAM construct a different number of times, but zero is not a valid number of times for one subteam if another sibling subteam enters the construct at all. I believe the words we have underspecify some desired restriction(s) while at the same time may over-restrict some desirable practice. As i do not understand exactly what is meant to be prohibited and what is meant to be allowed, i am unable to suggest how to fix it. Response Subgroup decision is that the requirement that all images of the current team execute the same CHANGE TEAM statement is unnecessary, but all images of the new team still have to execute the same CHANGE TEAM statement. An edit is provided to change that requirement. Another edit corrects an error found in NOTE 11.6. Edits to N2123 (17-007r1) [xx:3-] At the end of the last bullet in para 2 of Introduction, which begins "Changes to features previously described by ISO/IEC TS 18508:2015:", add a new sentence: "All images of the current team are no longer required to execute the same CHANGE TEAM statement." [188:20, 22] In 11.1.5.2 Execution of a CHANGE TEAM construct, move the only sentence of para 5 that reads "All active images of the current team shall execute the same CHANGE TEAM statement." to follow the first sentence of para 6 and modified the text to replace "current team" by "new team" making it read "All active images of the new team shall execute the same CHANGE TEAM statement." [188:32+] In 11.1.5.2 Execution of a CHANGE TEAM construct, NOTE 11.6, para 2, change "If it is desired to synchronize all of the images in the team that is current when CHANGE TEAM begins execution, a SYNC ALL statement can be inserted just before the CHANGE TEAM statement." to "If it is desired to synchronize all of the images in the team that was current when the CHANGE TEAM construct began execution, a SYNC TEAM statement that specifies the parent team can be executed immediately after the CHANGE TEAM statement." ===END===