https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127702

            Bug ID: 127702
           Summary: The result of NUM_IMAGES depends on the number of
                    failed or stopped images
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mikael at gcc dot gnu.org
  Target Milestone: ---

Testcase:

program prog
   use, intrinsic :: iso_fortran_env, only: stat_stopped_image
   implicit none
   if (num_images() < 2) stop
   print *, this_image(), num_images()
   sync all
   if (this_image() == 1) then
      stop
   else
      do while (image_status(1) /= stat_stopped_image)
      end do
   end if
   print *, this_image(), num_images()
end program

When run with shmem caf library, it shows an output similar to this:
           8           8
           5           8
           3           8
           1           8
           4           8
           7           8
           2           8
           6           8
STOP 
           6           7
           7           7
           4           7
           8           7
           3           7
           5           7
           2           7


I expect the second column to have the same value all along.  A similar result
is obtained with failed images instead of stopped images.

F2023 (5.3.4 Program execution) contains:
> Execution of a program consists of the asynchronous execution of a fixed
> number (which may be one) of its images.

(16.9.156 NUM_IMAGES):
> Result Value. The number of images in the specified team, or in the current
> team if no team is specified.

So it's not indicated that the number may change because of a change of
execution state of an image.  And it also makes more sense to have a fixed
value, because it may be used as loop bound to query the execution state of all
the other images; having a decreasing number would mean that the execution
state would no longer be queried for some of the images.

Reply via email to