https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78505
Bug ID: 78505
Summary: [F08] Coarray source allocation not synchronizing on
oversubscribed cores
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
Assignee: unassigned at gcc dot gnu.org
Reporter: damian at sourceryinstitute dot org
Target Milestone: ---
The transcript below demonstrates that gfortran is not performing the
synchronization required during the allocation of a coarray when the number of
images exceeds the number of cores (8 images on 4 cores in the case below). I
can't think of a way to test the allocate without "source=" because the coarray
cannot be defined before the allocate and a definition of the coarray
immediately after the allocate would happen asynchronously.
The workaround is to add some form of synchronization (e.g., sync all) after
the allocate, but requiring that does not conform with the standard. According
to the discussion in OpenCoarrays issue #243
(https://github.com/sourceryinstitute/opencoarrays/issues/243#issuecomment-262638712),
this is a compiler issue.
$ cat source-allocation-not-syncing.f90
implicit none
integer, allocatable :: f(:)[:]
integer, parameter :: num_points=32
integer :: me,ni,my_num_points,neighbor_last_element
me = this_image()
if (mod(num_points,num_images())/=0) error stop "num_points not evenly
divisible by num_images()"
my_num_points = num_points/num_images()
allocate( f(my_num_points)[*], source = 1 )
if (me>1) then
neighbor_last_element = f(my_num_points)[me-1]
if (neighbor_last_element /=1) print *,"Image ",me," gets
",neighbor_last_element
end if
end
$ caf source-allocation-not-syncing.f90
$ cafrun -np 8 ./a.out
Image 5 gets 0
$ cafrun -np 8 ./a.out
Image 3 gets 0
Image 5 gets 0
$ caf --wraps
caf wraps CAFC=/opt/mpich/3.1.4/gnu/7.0.0/bin/mpif90
$ /opt/mpich/3.1.4/gnu/7.0.0/bin/mpif90 --version
GNU Fortran (GCC) 7.0.0 20160904 (experimental)
...