[PATCH 16/22] Coarray caf_shmem final patch set
Jerry D <[email protected]>
| Newsgroups | gmane.comp.gcc.patches,gmane.comp.gcc.fortran |
|---|---|
| Message-ID | <[email protected]> |
Ref: https://gcc.gnu.org/pipermail/fortran/2026-February/063551.html See attached. Awaiting approval.
caf_shmem-16-of-22.patch
(text/x-patch, 1.8 KB)
From 8c9507475be905ae8ee927a0cb8d5b11e56844aa Mon Sep 17 00:00:00 2001 From: Jerry DeLisle <[email protected]> Date: Sat, 14 Feb 2026 15:46:44 -0800 Subject: [PATCH] Fortran: Adjust test to work with multiple images. The testcase would fail occasionally with multiple images because the use of acquired_lock is a non-blocking LOCK. Only UNLOCK this if the LOCK was acquired. Keep track of the loop count and bail out if the limit is reached. During testing it was observed that the loop count could go as high as 33 times depending on system conditions, running the test outside the testsuite 1000's of times. PR fortran/121429 gcc/testsuite/ChangeLog: * gfortran.dg/coarray/lock_1.f90: Updated. --- gcc/testsuite/gfortran.dg/coarray/lock_1.f90 | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/coarray/lock_1.f90 b/gcc/testsuite/gfortran.dg/coarray/lock_1.f90 index 1ec5984a4d3..d990fd3f908 100644 --- a/gcc/testsuite/gfortran.dg/coarray/lock_1.f90 +++ b/gcc/testsuite/gfortran.dg/coarray/lock_1.f90 @@ -4,12 +4,12 @@ ! ! PR fortran/18918 ! - use iso_fortran_env implicit none type(lock_type) :: lock[*] integer :: stat +integer :: counter logical :: acquired LOCK(lock) @@ -18,15 +18,19 @@ UNLOCK(lock) stat = 99 LOCK(lock, stat=stat) if (stat /= 0) STOP 1 + stat = 99 UNLOCK(lock, stat=stat) if (stat /= 0) STOP 2 -if (this_image() == 1) then - acquired = .false. +acquired = .false. +counter = 0 +do while (.not. acquired) + counter = counter + 1 LOCK (lock[this_image()], acquired_lock=acquired) - if (.not. acquired) STOP 3 - UNLOCK (lock[1]) -end if + if (acquired) UNLOCK (lock) + if ((num_images() .eq. 8) .and. (counter .gt. 100)) exit +end do +! counter here can vary depending on conditions, picked 100. +if (counter .gt. 100) stop counter end - -- 2.53.0