GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
libgfortran

libgfortran: Fix coarray team size calculation

libgfortran's coarray implementation now correctly determines team sizes using the image map, resolving issues with image termination and status reporting.

This commit addresses a bug in libgfortran’s coarray implementation where team sizes were incorrectly derived from barriers. When images terminated, the barrier size decreased, leading to incorrect NUM_IMAGES counts and faulty team formation and collective operations. The fix ensures team sizes are consistently determined from the team’s image map, which remains static.

In Details

In libgfortran's coarray support, caf_shmem.c previously used barrier->count to determine NUM_IMAGES. This count decreases as images in a team terminate. This commit changes the source of NUM_IMAGES and related functions (_gfortran_caf_image_status, _gfortran_caf_form_team) to use team->image_map.size(), which is invariant to image termination. This resolves issues where FORM TEAM and collectives operated on an incorrect number of images.

For Context
coarray
A Fortran language feature providing built-in support for parallel programming by allowing direct access to data on other processing units (images).
image
In Fortran coarrays, an 'image' is an independent sequential execution stream, analogous to a process or thread.
team
A subset of images within a coarray program, allowing for more flexible and structured parallel communication patterns.
barrier
A synchronization primitive that halts all participating images until every image has reached the barrier.
Filed Under: coarraybugfix