Re: [PATCH] fortran: Fix element size in collective subroutines implementation [PR126799]

Mikael Morin <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <[email protected]>
Le 13/08/2026 à 09:50, Mikael Morin a écrit :
> Le 12/08/2026 à 20:29, Steve Kargl a écrit :
>> On 8/12/26 10:24, Mikael Morin wrote:
>>> Hello,
>>>
>>> this caused a regression on something else I was working on.
>>> I found a failing example on the trunk, and here we are.
>>> Fortran-tested on aarch64-unknown-linux-gnu.  OK for mainline?
>>>
>>> Mikael
>>
>> Yes.  The patch verges on "obviously correct".
>>
> The change itself is definitely trivial; the context and impacts are 
> less so.  Thanks for the review, pushed as r17-3254-gfbc358491eac26.

There is a similar problem in the CO_BROADCAST implementation for 
non-character arrays, and I'm currently testing the attached fix.  It 
could be extended to the character case as well, but there is a strlen 
call that I'm not brave enough to touch.  Will push if tests are clean.
pr126799_v02-01.patch (text/x-patch, 1.6 KB)
From bb5f71076b1cfad11217723f3e9fcdbe359ad350 Mon Sep 17 00:00:00 2001
From: Mikael Morin <[email protected]>
Date: Thu, 13 Aug 2026 10:10:50 +0200
Subject: [PATCH] fortran: Fix element size in CO_BROADCAST implementation
 [PR126799]

Similarly to the previous element size fix touching the shared memory
implementation of collective subroutines, use the element length field
instead of the span field of the input descriptor as element size in the
CO_BROADCAST shared memory implementation.  Contrary to the collective
subroutine case, using the span could only cause extra memory usage here,
without any more harm, and there is no testcase with any observable
behaviour change.

	PR fortran/126799

libgfortran/ChangeLog:

	* caf/shmem/collective_subroutine.c (collsub_broadcast_array): Use
	the element length field instead of the span field as element size.
---
 libgfortran/caf/shmem/collective_subroutine.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/libgfortran/caf/shmem/collective_subroutine.c b/libgfortran/caf/shmem/collective_subroutine.c
index fd5d56e88b2..01389b18b0a 100644
--- a/libgfortran/caf/shmem/collective_subroutine.c
+++ b/libgfortran/caf/shmem/collective_subroutine.c
@@ -407,9 +407,7 @@ collsub_broadcast_array (gfc_descriptor_t *desc, int source_image)
 	elem_size = strlen (desc->base_addr);
     }
   else
-    elem_size = GFC_DESCRIPTOR_SPAN (desc) != 0
-		  ? ((index_type) GFC_DESCRIPTOR_SPAN (desc))
-		  : ((index_type) GFC_DESCRIPTOR_SIZE (desc));
+    elem_size = (index_type) GFC_DESCRIPTOR_SIZE (desc);
   size_bytes = elem_size * pi.num_elem;
   buffer = get_collsub_buf (size_bytes);
 
-- 
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.