[J3] asynchronous coarray collectives?

Van Snyder van.snyder at sbcglobal.net
Sat May 6 18:39:09 UTC 2023


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*,Dend 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/3dc3a5e2/attachment.htm>


More information about the J3 mailing list