co-arrays and libgfortran
Steve Kargl
sgk@troutmask.apl.washington.edu
Sat Dec 19 21:59:44 GMT 2020
On Fri, Dec 18, 2020 at 07:52:52AM -0800, Steve Kargl wrote:
>
> I don't know if memory barriers are needed. As random_init.f90 is
> Fortran, the psuedocode might be
>
> if (hidden < 2) then
> ! get seeds on image 1
> call random_seed()
> call random_seed(get=seeds)
> else
> call co_broadcast(seeds,1)
> end if
>
Well, one possible solution would have conv_intrinsic_random_init()
convert random_init(repeatable, image_distinct) into
_gfortran_random_init(repeatable, image_distinct, hidden, sub)
where hidden is the value of this_image() as before, and sub is the
name (or pointer?) to a subroutine. For -fcoarrays=none or single,
sub could be a stub that is never called. For -fcoarrays=lib, sub
would be whatever gfor_fndecl_co_broadcast is associated (opencoarray
is _gfortran_caf_co_broadcast). The Fortran code in random_init.f90
would then be
if (hidden < 2) then
! get seeds on image 1
call random_seed()
call random_seed(get=seeds)
else
call sub(seeds,1)
end if
A second possibility is to use a weak reference. libgfortran
can contain a weak reference to _gfortran_caf_co_broadcast
when linked with -fcoarrays=none or single the weak reference
will never be called. With -fcoarrays=lib, the linker should
resolve to the version provided by opencoarrays.
Not sure how this would play out with shared memory coarray.
--
Steve
More information about the Fortran
mailing list