Skip to content

Commit

Permalink
Merge pull request #21 from bhourahine/IETF
Browse files Browse the repository at this point in the history
IETF article 19 naming suggestion
  • Loading branch information
bhourahine authored Jun 15, 2020
2 parents 75d2eb0 + fe60bcf commit a9a55b8
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 96 deletions.
2 changes: 1 addition & 1 deletion doc/sphinx/about.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Additional to the object to be broadcasted and the communicator, you also

- size of the array (which is redundant, as it is *known* at run-time)

- root node of the broadcast (setting it to the master node as default would
- root node of the broadcast (setting it to the lead node as default would
be a definitely safe choice)

- error flag (one could per default just omit it and rely on the program to stop
Expand Down
2 changes: 1 addition & 1 deletion external/fypp/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ repository::

git clone https://github.com/aradi/fypp.git

and check out the `master` branch.
and check out the default branch.

The command line tool is a single stand-alone script. You can run it directly
from the source folder ::
Expand Down
2 changes: 1 addition & 1 deletion lib/mpifx_allgatherv.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ module mpifx_allgatherv_module
!!
!! write(*, *) mycomm%rank, "Send1 buffer:", send1(:)
!! call mpifx_allgatherv(mycomm, send1, recv1, recvcounts)
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! write(*, *) mycomm%rank, "Recv1 buffer:", recv1
!! end if
!!
Expand Down
6 changes: 3 additions & 3 deletions lib/mpifx_bcast.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module mpifx_bcast_module
!! integer :: buffer(3)
!!
!! call mycomm%init()
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! buffer(:) = [ 1, 2, 3 ]
!! end if
!! call mpifx_bcast(mycomm, buffer)
Expand Down Expand Up @@ -61,7 +61,7 @@ contains
!> Msg to be broadcasted on root and received on non-root nodes.
${TYPE}$ :: msg${RANKSUFFIX(RANK)}$

!> Root node for the broadcast (default: mycomm%masterrank).
!> Root node for the broadcast (default: mycomm%leadrank).
integer, intent(in), optional :: root

!> Optional error handling flag.
Expand All @@ -72,7 +72,7 @@ contains
#:set SIZE = '1' if RANK == 0 else 'size(msg)'
#:set COUNT = ('len(msg) * ' + SIZE if HASLENGTH else SIZE)

call getoptarg(mycomm%masterrank, root0, root)
call getoptarg(mycomm%leadrank, root0, root)
call mpi_bcast(msg, ${COUNT}$, ${MPITYPE}$, root0, mycomm%id, error0)
call handle_errorflag(error0, "MPI_BCAST in mpifx_bcast_${SUFFIX}$", error)

Expand Down
8 changes: 4 additions & 4 deletions lib/mpifx_comm.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ module mpifx_comm_module
integer :: id !< Communicator id.
integer :: size !< Nr. of processes (size).
integer :: rank !< Rank of the current process.
integer :: masterrank !< Index of the master node.
logical :: master !< True if current process is the master (rank == 0).
integer :: leadrank !< Index of the lead node.
logical :: lead !< True if current process is the lead (rank == 0).
contains
!> Initializes the MPI environment.
procedure :: init => mpifx_comm_init
Expand Down Expand Up @@ -50,8 +50,8 @@ contains
if (error0 /= 0) then
return
end if
self%masterrank = 0
self%master = (self%rank == self%masterrank)
self%leadrank = 0
self%lead = (self%rank == self%leadrank)

end subroutine mpifx_comm_init

Expand Down
28 changes: 14 additions & 14 deletions lib/mpifx_gather.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,43 @@ module mpifx_gather_module
!!
!! ! I0 -> I1
!! send0 = mycomm%rank * 2 ! Arbitrary number to send
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! allocate(recv1(1 * mycomm%size))
!! recv1(:) = 0
!! else
!! allocate(recv1(0))
!! end if
!! write(*, *) mycomm%rank, "Send0 buffer:", send0
!! call mpifx_gather(mycomm, send0, recv1)
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! write(*, *) mycomm%rank, "Recv1 buffer:", recv1(:)
!! end if
!! deallocate(recv1)
!!
!! ! I1 -> I1
!! allocate(send1(2))
!! send1(:) = [ mycomm%rank, mycomm%rank + 1 ] ! Arbitrary numbers
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! allocate(recv1(size(send1) * mycomm%size))
!! recv1(:) = 0
!! else
!! allocate(recv1(0))
!! end if
!! write(*, *) mycomm%rank, "Send1 buffer:", send1(:)
!! call mpifx_gather(mycomm, send1, recv1)
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! write(*, *) mycomm%rank, "Recv1 buffer:", recv1
!! end if
!!
!! ! I1 -> I2
!! send1(:) = [ mycomm%rank, mycomm%rank + 1 ]
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! allocate(recv2(size(send1), mycomm%size))
!! recv2(:,:) = 0
!! end if
!! write(*, *) mycomm%rank, "Send1 buffer:", send1(:)
!! call mpifx_gather(mycomm, send1, recv2)
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! write(*, *) mycomm%rank, "Recv2 buffer:", recv2
!! end if
!!
Expand Down Expand Up @@ -112,7 +112,7 @@ contains
!! \param mycomm MPI communicator.
!! \param send Quantity to be sent for gathering.
!! \param recv Received data on receive node (undefined on other nodes)
!! \param root Root process for the result (default: mycomm%masterrank)
!! \param root Root process for the result (default: mycomm%leadrank)
!! \param error Error code on exit.
!!
subroutine mpifx_gather_${SUFFIX}$(mycomm, send, recv, root, error)
Expand All @@ -127,11 +127,11 @@ contains
#:set SIZE = 'size(send)'
#:set COUNT = ('len(send) * ' + SIZE if HASLENGTH else SIZE)

@:ASSERT(.not. mycomm%master .or. size(recv) == size(send) * mycomm%size)
@:ASSERT(.not. mycomm%master .or.&
@:ASSERT(.not. mycomm%lead .or. size(recv) == size(send) * mycomm%size)
@:ASSERT(.not. mycomm%lead .or.&
& size(recv, dim=${RANK}$) == size(send, dim=${RANK}$) * mycomm%size)

call getoptarg(mycomm%masterrank, root0, root)
call getoptarg(mycomm%leadrank, root0, root)
call mpi_gather(send, ${COUNT}$, ${MPITYPE}$, recv, ${COUNT}$, ${MPITYPE}$, root0,&
& mycomm%id, error0)
call handle_errorflag(error0, "MPI_GATHER in mpifx_gather_${SUFFIX}$", error)
Expand All @@ -150,7 +150,7 @@ contains
!! \param mycomm MPI communicator.
!! \param send Quantity to be sent for gathering.
!! \param recv Received data on receive node (indefined on other nodes)
!! \param root Root process for the result (default: mycomm%masterrank)
!! \param root Root process for the result (default: mycomm%leadrank)
!! \param error Error code on exit.
!!
subroutine mpifx_gather_${SUFFIX}$(mycomm, send, recv, root, error)
Expand All @@ -165,10 +165,10 @@ contains
#:set SIZE = '1' if RANK == 0 else 'size(send)'
#:set COUNT = ('len(send) * ' + SIZE if HASLENGTH else SIZE)

@:ASSERT(.not. mycomm%master .or. size(recv) == ${SIZE}$ * mycomm%size)
@:ASSERT(.not. mycomm%master .or. size(recv, dim=${RANK + 1}$) == mycomm%size)
@:ASSERT(.not. mycomm%lead .or. size(recv) == ${SIZE}$ * mycomm%size)
@:ASSERT(.not. mycomm%lead .or. size(recv, dim=${RANK + 1}$) == mycomm%size)

call getoptarg(mycomm%masterrank, root0, root)
call getoptarg(mycomm%leadrank, root0, root)
call mpi_gather(send, ${SIZE}$, ${MPITYPE}$, recv, ${SIZE}$, ${MPITYPE}$, root0, mycomm%id,&
& error0)
call handle_errorflag(error0, "MPI_GATHER in mpifx_gather_${SUFFIX}$", error)
Expand Down
12 changes: 6 additions & 6 deletions lib/mpifx_gatherv.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
!! \param recvcounts Counts of received data from each process
!! \param displs Entry i specifies where to place data from process rank i-1
!! (default: computed from recvcounts assuming order with rank)
!! \param root Root process for the result (default: mycomm%masterrank)
!! \param root Root process for the result (default: mycomm%leadrank)
!! \param error Error code on exit.
!!
subroutine mpifx_gatherv_${SUFFIX}$(mycomm, send, recv, recvcounts, displs, root, error)
Expand All @@ -33,7 +33,7 @@
integer, allocatable :: displs0(:)
logical, allocatable :: testBuffer(:)

@:inoptflags(root0, root, mycomm%masterrank)
@:inoptflags(root0, root, mycomm%leadrank)

if (mycomm%rank == root0) then
allocate(displs0(mycomm%size))
Expand Down Expand Up @@ -87,7 +87,7 @@
!! \param recvcounts Counts of received data from each process
!! \param displs Entry i specifies where to place data from process rank i-1
!! (default: computed from recvcounts assuming order with rank)
!! \param root Root process for the result (default: mycomm%masterrank)
!! \param root Root process for the result (default: mycomm%leadrank)
!! \param error Error code on exit.
!!
subroutine mpifx_gatherv_${SUFFIX}$(mycomm, send, recv, recvcounts, displs, root, error)
Expand All @@ -102,7 +102,7 @@
integer :: ii, root0, error0
integer, allocatable :: displs0(:)

@:inoptflags(root0, root, mycomm%masterrank)
@:inoptflags(root0, root, mycomm%leadrank)

if (mycomm%rank == root0) then
@:ASSERT(size(recv) == sum(recvcounts))
Expand Down Expand Up @@ -173,7 +173,7 @@ module mpifx_gatherv_module
!! ! I1 -> I1
!! allocate(send1(mycomm%rank+1))
!! send1 = 1.0*mycomm%rank
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! ! recv1 size is 1+2+3+...+mycomm%size
!! nrecv = mycomm%size*(mycomm%size+1)/2
!! allocate(recv1(nrecv))
Expand All @@ -188,7 +188,7 @@ module mpifx_gatherv_module
!!
!! write(*, *) mycomm%rank, "Send1 buffer:", send1(:)
!! call mpifx_gatherv(mycomm, send1, recv1, recvcounts)
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! write(*, *) mycomm%rank, "Recv1 buffer:", recv1
!! end if
!!
Expand Down
6 changes: 3 additions & 3 deletions lib/mpifx_recv.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ module mpifx_recv_module
!!
!! call mpifx_init()
!! call mycomm%init()
!! if (.not. mycomm%master) then
!! if (.not. mycomm%lead) then
!! write(msg, "(A,I0,A)") "Hello from process ", mycomm%rank, "!"
!! call mpifx_send(mycomm, msg, mycomm%masterrank)
!! call mpifx_send(mycomm, msg, mycomm%leadrank)
!! else
!! write(*, "(A)") "Master node:"
!! write(*, "(A)") "Lead node:"
!! do source = 1, mycomm%size - 1
!! call mpifx_recv(mycomm, msg, source)
!! write(*,"(A,A)") "Message received: ", trim(msg)
Expand Down
8 changes: 4 additions & 4 deletions lib/mpifx_reduce.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ contains
!! \param orig Quantity to be reduced.
!! \param reduced Contains result on exit.
!! \param reduceop Reduction operator.
!! \param root Root process for the reduced (default: mycomm%masterrank)
!! \param root Root process for the reduced (default: mycomm%leadrank)
!! \param error Error code on exit.
!!
subroutine mpifx_reduce_${SUFFIX}$(mycomm, orig, reduced, reduceop, root, error)
Expand All @@ -122,7 +122,7 @@ contains

integer :: root0, error0

call getoptarg(mycomm%masterrank, root0, root)
call getoptarg(mycomm%leadrank, root0, root)

#:set SIZE = '1' if RANK == 0 else 'size(orig)'
#:set COUNT = SIZE
Expand All @@ -144,7 +144,7 @@ contains
!! \param mycomm MPI communicator.
!! \param origred Quantity to be reduced on input, result on exit
!! \param reduceop Reduction reduceop
!! \param root Root process for the result (default: mycomm%masterrank)
!! \param root Root process for the result (default: mycomm%leadrank)
!! \param error Error code on exit.
!!
subroutine mpifx_reduceip_${SUFFIX}$(mycomm, origred, reduceop, root, error)
Expand All @@ -157,7 +157,7 @@ contains
integer :: root0, error0
${TYPE}$ :: dummy

call getoptarg(mycomm%masterrank, root0, root)
call getoptarg(mycomm%leadrank, root0, root)

#:set SIZE = '1' if RANK == 0 else 'size(origred)'
#:set COUNT = SIZE
Expand Down
24 changes: 12 additions & 12 deletions lib/mpifx_scatter.fpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ module mpifx_scatter_module
!! call mycomm%init()
!!
!! ! I1 -> I0
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! allocate(send1(mycomm%size))
!! send1(:) = [ (ii, ii = 1, size(send1)) ]
!! write(*, *) mycomm%rank, "Send1 buffer:", send1
Expand All @@ -53,7 +53,7 @@ module mpifx_scatter_module
!! write(*, *) mycomm%rank, "Recv0 buffer:", recv0
!!
!! ! I1 -> I1
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! deallocate(send1)
!! allocate(send1(2 * mycomm%size))
!! send1(:) = [ (ii, ii = 1, size(send1)) ]
Expand All @@ -65,7 +65,7 @@ module mpifx_scatter_module
!! write(*, *) mycomm%rank, "Recv1 buffer:", recv1
!!
!! ! I2 -> I1
!! if (mycomm%master) then
!! if (mycomm%lead) then
!! allocate(send2(2, mycomm%size))
!! send2(:,:) = reshape(send1, [ 2, mycomm%size ])
!! write(*, *) mycomm%rank, "Send2 buffer:", send2
Expand Down Expand Up @@ -101,7 +101,7 @@ contains
!! \param mycomm MPI communicator.
!! \param send Quantity to be sent for scattering.
!! \param recv Received data on receive node (undefined on other nodes)
!! \param root Root process for the result (default: mycomm%masterrank)
!! \param root Root process for the result (default: mycomm%leadrank)
!! \param error Error code on exit.
!!
subroutine mpifx_scatter_${SUFFIX}$(mycomm, send, recv, root, error)
Expand All @@ -116,11 +116,11 @@ contains
#:set SIZE = 'size(recv)'
#:set COUNT = ('len(recv) * ' + SIZE if HASLENGTH else SIZE)

@:ASSERT(.not. mycomm%master .or. size(send) == size(recv) * mycomm%size)
@:ASSERT(.not. mycomm%master&
@:ASSERT(.not. mycomm%lead .or. size(send) == size(recv) * mycomm%size)
@:ASSERT(.not. mycomm%lead&
& .or. size(send, dim=${RANK}$) == size(recv, dim=${RANK}$) * mycomm%size)

call getoptarg(mycomm%masterrank, root0, root)
call getoptarg(mycomm%leadrank, root0, root)
call mpi_scatter(send, ${COUNT}$, ${MPITYPE}$, recv, ${COUNT}$, ${MPITYPE}$, root0,&
& mycomm%id, error0)
call handle_errorflag(error0, "MPI_SCATTER in mpifx_scatter_${SUFFIX}$", error)
Expand All @@ -139,7 +139,7 @@ contains
!! \param mycomm MPI communicator.
!! \param send Quantity to be sent for scattering.
!! \param recv Received data on receive node (indefined on other nodes)
!! \param root Root process for the result (default: mycomm%masterrank)
!! \param root Root process for the result (default: mycomm%leadrank)
!! \param error Error code on exit.
!!
subroutine mpifx_scatter_${SUFFIX}$(mycomm, send, recv, root, error)
Expand All @@ -154,13 +154,13 @@ contains
#:set SIZE = '1' if RANK == 1 else 'size(recv)'
#:set COUNT = ('len(recv) * ' + SIZE if HASLENGTH else SIZE)

@:ASSERT(.not. mycomm%master .or. size(send) == ${SIZE}$ * mycomm%size)
@:ASSERT(.not. mycomm%master .or. size(send, dim=${RANK}$) == mycomm%size)
@:ASSERT(.not. mycomm%lead .or. size(send) == ${SIZE}$ * mycomm%size)
@:ASSERT(.not. mycomm%lead .or. size(send, dim=${RANK}$) == mycomm%size)
#:if HASLENGTH
@:ASSERT(.not. mycomm%master .or. len(send) == len(recv))
@:ASSERT(.not. mycomm%lead .or. len(send) == len(recv))
#:endif

call getoptarg(mycomm%masterrank, root0, root)
call getoptarg(mycomm%leadrank, root0, root)
call mpi_scatter(send, ${COUNT}$, ${MPITYPE}$, recv, ${COUNT}$, ${MPITYPE}$, root0,&
& mycomm%id, error0)
call handle_errorflag(error0, "MPI_SCATTER in mpifx_scatter_${SUFFIX}$", error)
Expand Down
Loading

0 comments on commit a9a55b8

Please sign in to comment.