Fortran collective subroutines shared memory implementation fixes element size.
Corrects element size calculation in Fortran's shared memory collective subroutines to prevent incorrect data.
This commit fixes an issue in the shared memory implementation of Fortran’s collective subroutines where the array descriptor’s ‘span’ field was incorrectly used as the element size. This larger-than-actual size estimate led to memory over-allocation and, crucially, a mismatch in element indexing between the collective subroutine and its packing/unpacking functions, resulting in corrupted data. The fix uses the correct ‘element length’ field instead.
In Details
This patch corrects the calculation of element size within the shared memory implementation of Fortran's collective subroutines in libgfortran. The collsub_reduce_array function was using the array descriptor's span field, which can overestimate the size when dealing with array subreferences. This incorrect size not only caused potential memory over-allocation but also desynchronized element indexing between the collective operation and the associated packing/unpacking routines, leading to data corruption. The fix replaces span with the accurate element_length field. A new test case,…
- collective subroutines
- Fortran coarray subroutines that perform operations involving multiple processes, such as
CO_REDUCE,CO_BROADCAST, etc., coordinated across participating processes. - 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.
- array 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.
- packing and unpacking functions
- Routines that convert data between an internal representation and a format suitable for transmission or storage, often used in collective operations to serialize or deserialize data.