co-arrays and libgfortran

Thomas Koenig tkoenig@netcologne.de
Fri Dec 18 12:26:37 GMT 2020


Am 18.12.20 um 05:28 schrieb Steve Kargl via Fortran:
> Dear All,
> 
> At the risk of causing consternation among the few
> active gfortran developers, I'll offer the observation
> that libgfortran likely need to be built with -fcoarray=lib
> if one wants to use OpenCoarrays.

I hope there can be another solution :-)

> I'm not sure what
> the status of shared memory coarrays is.

It is starting to be usable.  It works for Toon's "random weather"
test program, and there is a growing number of test cases that work
(see 
https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=gcc/testsuite/gfortran.dg/caf-shared;hb=refs/heads/devel/coarray_native 
)
but there are still quite a large number of things that don't.

> Why, you ask?

> J3 defined RANDOM_INIT() in a manner that requires it to be
> aware of the backing coarray communication method.  That is,
> RANDOM_INIT(repeatable=.false., image_distinct=.false.)
> requires communication between image 1 and all other images
> (if num_image > 1).  'repeatable=.false.' means that each
> time a program is run, a different set of processor-dependent
> seeds are used on image 1.  This is trivial to do with
> Janne's reworking of random_seed() when he introduce gfortran
> to xshiro++.  Now, if num_images() > 1, then all other images
> are required to use the same set of seeds as image 1 to initial
> their PRNG.  Therefore, the other images must ask image 1 for
> its seeds.  I don't use co-arrays, so I'm unsure of the
>   semantics; but, I have used MPI.  With MPI, one would have
> image 1 broadcast the seeds and all other images would receive
> the seeds.

The best way is probably to call different random_init routines
depending on the value of flag_coarray.

However, I am seeing some problems with synchronization with that
approach. The standard does not say anything about needing SYNC ALL
after random_init, or about implied synchronization.  That means
copying could be problematic.

Hmm... I'll have to think about this somre more.

Regards

	Thomas


More information about the Fortran mailing list