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

Fortran CO_BROADCAST shared memory implementation fixes element size.

Fixes incorrect element size calculation in Fortran's CO_BROADCAST shared memory implementation.

The shared memory implementation of Fortran’s CO_BROADCAST collective subroutine incorrectly used the ‘span’ field of the input descriptor to determine element size. This commit corrects it to use the ‘element length’ field, aligning with other implementations and preventing potential issues, though no observable behavior change occurred due to this specific fix.

In Details

This commit corrects an error in the shared memory implementation of Fortran's CO_BROADCAST within libgfortran. The collsub_broadcast_array function was using the span field of the input descriptor, which could be larger than the actual element size, instead of the element_length field. While this didn't cause harm in CO_BROADCAST beyond potential memory over-allocation, it was inconsistent with other collective subroutine implementations that had already been fixed.

For Context
CO_BROADCAST
A Fortran coarray collective subroutine that broadcasts data from one process to all other processes in a team.
shared memory implementation
A method for inter-process communication where processes access a common region of physical memory. In Fortran coarrays, this is often used for efficient communication between processes on the same machine.
input descriptor
A data structure used by Fortran to describe an array, including its base address, element size, and extents (dimensions).
span
In a Fortran array descriptor, typically refers to the total size of the array in bytes, including all its elements and padding.
element length
In a Fortran array descriptor, the size in bytes of a single element of the array.
Filed Under: fortrancoarrayperformance