[J3] asynchronous coarray collectives?
Van Snyder
van.snyder at sbcglobal.net
Sat May 6 20:08:37 UTC 2023
On Sat, 2023-05-06 at 19:32 +0000, Jeff Hammond wrote:
> I was not aware that coarray collectives were pure. They have strong
> side effects. Are you sure they are pure?
>
>
>
>
> If the do concurrent is execute in a random order on a single thread,
> which seems like a legal implementation, this will deadlock.
Jeff is right. 16.6p2 and C1602 (in 23-007) say that the sequence of
executions of collective subroutines shall be the same on every image
and that a reference to one shall not appear where an image control
statement is prohibited. C1141 says that an image control statement
shall not appear within a DO CONCURRENT construct.
> Finally, how does do concurrent inform the Fortran implementation to
> take advantage of network offloading?
>
>
>
> > On 6. May 2023, at 21.39, Van Snyder via J3 <
> > j3 at mailman.j3-fortran.org> wrote:
> >
> >
> >
> >
> >
> >
> >
> > External email: Use caution opening links or attachments
> >
> >
> >
> >
> >
> >
> >
> > Try this:
> >
> >
> >
> >
> >
> >
> > subroutine stuff(A,B,C,D)
> >
> > implicit none
> >
> > double, intent(inout) :: A, B, C
> >
> > double, intent(in) :: D(:)
> > integer :: I
> > do concurrent ( i = 1:3 )
> > select case ( i )
> > case ( 1 )
> > call co_sum(A)
> > case ( 2 )
> > call co_min(B)
> > case ( 3 )
> >
> > call co_max(C)
> > end select
> > end do
> >
> >
> > print*,D
> >
> > end subroutine stuff
> >
> >
> >
> > Bill Long pointed out several years ago that a fork/join construct
> > would be syntactic sugar for this.
> >
> >
> >
> >
> > On Sat, 2023-05-06 at 07:59 +0000, Jeff Hammond via J3 wrote:
> > > How do I make a Fortran coarry program like this...
> > >
> > >
> > > subroutine stuff(A,B,C,D)
> > > implicit none
> > > double, intent(inout) :: A, B, C
> > > double, intent(in) :: D(:)
> > > call co_sum(A)
> > > call co_min(B)
> > > call co_max(C)
> > > print*,D
> > > end subroutine stuff
> > >
> > >
> > > ...behave like this...
> > >
> > >
> > > subroutine stuff(A,B,C,D)
> > > use mpi_f08
> > > implicit none
> > > double, intent(inout) :: A, B, C
> > > double, intent(in) :: D(:)
> > > type(MPI_Request) :: R(3)
> > > call MPI_Iallreduce(MPI_IN_PLACE, A, 1, MPI_DOUBLE, MPI_SUM,
> > > MPI_COMM_WORLD, R(1))
> > > call MPI_Iallreduce(MPI_IN_PLACE, B, 1, MPI_DOUBLE, MPI_MIN,
> > > MPI_COMM_WORLD, R(2))
> > > call MPI_Iallreduce(MPI_IN_PLACE, C, 1, MPI_DOUBLE, MPI_MAX,
> > > MPI_COMM_WORLD, R(3))
> > > print*,D
> > > call MPI_Waitall(3,R,MPI_STATUSES_IGNORE)
> > > end subroutine stuff
> > >
> > >
> > > ...in the sense that it is possible for the network to execute
> > > the communication operations asynchronously relative to the print
> > > statement?
> > >
> > >
> > > Do any compilers, e.g. Cray’s, automatically convert coarry
> > > operations to asynchronous communication and push the completion
> > > of those operations as far down as possible?
> > >
> > >
> > > Jeff
> >
> >
> >
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.j3-fortran.org/pipermail/j3/attachments/20230506/53199e74/attachment.htm>
More information about the J3
mailing list