[PATCH] libgfortran: [PR127684] caf_shmem: SYNC IMAGES hangs when an, image of the set terminates

Jerry D jvdelisle2@gmail.com
Fri Oct 2 23:04:45 GMT 2026


See attached patch. This fixes a hang issue I found while testing under heavy 
loads. This patch goes in after the fix for PR127702 which is pending approval.

Regression tested on x86_64.

OK for mainline?

Regards,

Jerry

---


libgfortran: [PR127684] caf_shmem: SYNC IMAGES hangs when an
  image of the set terminates

A stopped image in the image set now aborts the images waiting in SYNC
IMAGES and takes back their unmatched synchronizations, under the lock
of the sync table and before the stop is visible; a failed image is
skipped and the active images are synchronized.  STAT= is set only when
an image of the set terminated during the statement.

	PR libfortran/127684

libgfortran/ChangeLog:

	* caf/shmem.c (_gfortran_caf_sync_images): Do not return early for
	a stopped or failed image.  Check the images only when one of them
	terminated.
	(mark_stopped): Use sync_table_terminated.
	(_gfortran_caf_fail_image): Likewise.
	* caf/shmem/supervisor.c (supervisor_main_loop): Likewise.  Do not
	signal all images waiting in sync_table.
	* caf/shmem/sync.c (set_table_parts): New function.
	(sync_init): Use it.
	(sync_init_supervisor): Allocate the image sets of the waiting
	images and the aborted flags.
	(stopped_image_in): New function.
	(sync_table): Return whether an image of the set terminated.  Only
	synchronize memory when an image of the set stopped.  Record the
	image set and end the wait when aborted.
	(sync_table_terminated): New function.
	* caf/shmem/sync.h (sync_t): Add waiting and aborted.
	(sync_table): Return bool.
	(sync_table_terminated): Declare.

gcc/testsuite/ChangeLog:

	* gfortran.dg/coarray/sync_images_failed_1.f90: New test.
	* gfortran.dg/coarray/sync_images_stopped_2.f90: New test.
---

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PR127684-caf-shmem-sync-images-terminated.patch
Type: text/x-patch
Size: 15714 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20261002/219453ed/attachment.bin>


More information about the Gcc-patches mailing list