https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127347

--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <[email protected]>:

https://gcc.gnu.org/g:c9239e63c63c1b1558e9b35e3d7940a36d11aaa0

commit r17-4635-gc9239e63c63c1b1558e9b35e3d7940a36d11aaa0
Author: Jerry DeLisle <[email protected]>
Date:   Sat Sep 19 12:24:04 2026 -0700

    libgfortran: [PR127347] caf_shmem: fix STAT= for stopped images

    Image control statements and collective subroutines did not follow
    F2023 when an image of the team had stopped.

    SYNC ALL and SYNC TEAM with a stopped image still synchronized the
    remaining images, although F2023 11.7.11 gives them the effect of SYNC
    MEMORY, so a conforming program could deadlock.  A stopping image now
    marks the barriers of its teams as aborting: SYNC ALL and SYNC TEAM no
    longer wait in them, and a round they already wait in is aborted.
    Images waiting in END TEAM, CHANGE TEAM or at program end take part in
    the next round instead.

    Collective subroutines blocked forever.  They now report
    STAT_STOPPED_IMAGE, or STAT_FAILED_IMAGE, when the current team
    contains a terminated image (F2023 16.6), and a collective already
    running gives up with an error instead of blocking.

    STAT= was classified with the program-wide counts of stopped and
    failed images, so an image that stopped in one team made SYNC ALL in a
    sibling team report STAT_STOPPED_IMAGE.  It is now classified over the
    images involved in the statement, and SYNC TEAM reports them at all.

    Not addressed: END TEAM does not set STAT=.

    Assisted-by: Claude Opus 5

            PR libfortran/127347

    libgfortran/ChangeLog:

            * caf/shmem.c (_gfortran_caf_sync_all, _gfortran_caf_sync_team):
            Have the effect of SYNC MEMORY with a stopped image.  Check the
            images of the team synchronized.
            (_gfortran_caf_sync_images): Check the images synchronized.  Fix
            the format of the duplicate image error.
            (mark_stopped, _gfortran_caf_fail_image): Tell leave_teams whether
            the image stopped.
            (_gfortran_caf_co_broadcast, _gfortran_caf_co_sum)
            (_gfortran_caf_co_min, _gfortran_caf_co_max)
            (_gfortran_caf_co_reduce): Report terminated images of the team.
            * caf/shmem/collective_subroutine.c (collsub_sync): Give up when an
            image of the team terminated.
            * caf/shmem/counter_barrier.c (counter_barrier_init): Initialize
the
            new fields.
            (next_round, wait_round): New functions.
            (counter_barrier_wait): Use wait_round.  Take part in the next
round
            when a round is aborted.
            (counter_barrier_wait_abortable, counter_barrier_abort_locked): New
            functions.
            * caf/shmem/counter_barrier.h (counter_barrier): Make
            curr_wait_group a round number.  Add aborted_round,
            abortable_arrivals and aborting.
            (counter_barrier_wait_abortable, counter_barrier_abort_locked):
            Declare.
            * caf/shmem/sync.c (sync_all): Return whether the images were
            synchronized.
            (sync_team_unless_stopped): New function.
            * caf/shmem/sync.h (sync_all): Adjust.
            (sync_team_unless_stopped): Declare.
            * caf/shmem/teams_mgmt.c (count_images, team_terminated_images)
            (update_teams_images_locked, leave_team): New functions.
            (update_teams_images): Use update_teams_images_locked.
            (leave_teams): Add stopped argument.  Use leave_team.
            (check_health): Classify the given images.  Return the stat value.
            * caf/shmem/teams_mgmt.h (leave_teams, check_health): Adjust.
            (TEAM_HEALTH_CHECK): New macro.
            (HEALTH_CHECK): Use it.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/coarray/stop_sync_1.f90: Check STAT=.
            * gfortran.dg/coarray/collective_stopped_1.f90: New test.
            * gfortran.dg/coarray/stop_end_team_1.f90: New test.
            * gfortran.dg/coarray/stop_sync_team_1.f90: New test.
            * gfortran.dg/coarray/sync_memory_stopped_1.f90: New test.

Reply via email to