Dear George, Dear Jeff, Dear All, Thanks Thanks a lot
Here, the new version of the program. Now there is only one barrier. There is no more allocate\deallocate in the receive part. What do you think? Is all right? did I miss something or I need to improve something else? I have not complete understood your point Jeff, about WAITALL, eve looking at the examples. George what do you mean? Again Thanks a lot Diego On 9 January 2015 at 00:58, George Bosilca <bosi...@icl.utk.edu> wrote: > I'm confused by this statement. The examples pointed to are handling > blocking sends and receives, while this example is purely based on > non-blocking communications. In this particular case I see no hard of > waiting on the requests in any random order as long as all of them are > posted before the first wait. > > George. > > > On Thu, Jan 8, 2015 at 5:24 PM, Jeff Squyres (jsquyres) < > jsquy...@cisco.com> wrote: > >> Also, you are calling WAITALL on all your sends and then WAITALL on all >> your receives. This is also incorrect and may deadlock. >> >> WAITALL on *all* your pending requests (sends and receives -- put them >> all in a single array). >> >> Look at examples 3.8 and 3.9 in the MPI-3.0 document. >> >> >> >> On Jan 8, 2015, at 5:15 PM, George Bosilca <bosi...@icl.utk.edu> wrote: >> >> > Diego, >> > >> > Non-blocking communications only indicate a communication will happen, >> it does not force them to happen. They will only complete on the >> corresponding MPI_Wait, which also marks the moment starting from where the >> data can be safely altered or accessed (in the case of the MPI_Irecv). Thus >> deallocating your buffer after the MPI_Isend and MPI_Irecv is incorrect. >> Also printing the supposedly received values (line 127) is incorrect as >> there is no reason to have the non-blocking receive completed at that >> moment. >> > >> > George. >> > >> > >> > On Thu, Jan 8, 2015 at 5:06 PM, Diego Avesani <diego.aves...@gmail.com> >> wrote: >> > Dear Tom, Dear Jeff, Dear all, >> > Thanks again >> > >> > for Tom: >> > you are right, I fixed it. >> > >> > for Jeff: >> > if I do not insert the CALL MPI_BARRIER(MPI_COMM_WORLD, MPIdata%iErr) >> > in the line 112, the program does not stop. >> > >> > Am I right? >> > Here the new version >> > >> > >> > >> > Diego >> > >> > >> > On 8 January 2015 at 21:12, Tom Rosmond <rosm...@reachone.com> wrote: >> > With array bounds checking your program returns an out-of-bounds error >> > in the mpi_isend call at line 104. Looks like 'send_request' should be >> > indexed with 'sendcount', not 'icount'. >> > >> > T. Rosmond >> > >> > >> > >> > On Thu, 2015-01-08 at 20:28 +0100, Diego Avesani wrote: >> > > the attachment >> > > >> > > Diego >> > > >> > > >> > > >> > > On 8 January 2015 at 19:44, Diego Avesani <diego.aves...@gmail.com> >> > > wrote: >> > > Dear all, >> > > I found the error. >> > > There is a Ndata2send(iCPU) instead of Ndata2recv(iCPU). >> > > In the attachment there is the correct version of the program. >> > > >> > > >> > > Only one thing, could do you check if the use of MPI_WAITALL >> > > and MPI_BARRIER is correct? >> > > >> > > >> > > Thanks again >> > > >> > > >> > > >> > > >> > > >> > > Diego >> > > >> > > >> > > >> > > On 8 January 2015 at 18:48, Diego Avesani >> > > <diego.aves...@gmail.com> wrote: >> > > Dear all, >> > > thanks thank a lot, I am learning a lot. >> > > >> > > >> > > >> > > I have written a simple program that send vectors of >> > > integers from a CPU to another. >> > > >> > > >> > > The program is written (at least for now) for 4 CPU. >> > > >> > > >> > > The program is quite simple: >> > > Each CPU knows how many data has to send to the other >> > > CPUs. This info is than send to the other CPUS. In >> > > this way each CPU knows how may data has to receive >> > > from other CPUs. >> > > >> > > >> > > This part of the program works. >> > > >> > > >> > > The problem is in the second part. >> > > >> > > >> > > In the second part, each processor sends a vector of >> > > integer to the other processor. The size is given and >> > > each CPU knows the size of the incoming vector form >> > > the first part of the program. >> > > >> > > >> > > In this second part the program fails and I do not >> > > know why. >> > > >> > > >> > > In the attachment you can find the program. Could you >> > > please help me. Problably I didn't understand properly >> > > the ISEND and IRECV subroutine. >> > > >> > > >> > > Thanks again >> > > >> > > >> > > >> > > Diego >> > > >> > > >> > > >> > > >> > > >> > > >> > > _______________________________________________ >> > > users mailing list >> > > us...@open-mpi.org >> > > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users >> > > Link to this post: >> http://www.open-mpi.org/community/lists/users/2015/01/26131.php >> > >> > >> > _______________________________________________ >> > users mailing list >> > us...@open-mpi.org >> > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users >> > Link to this post: >> http://www.open-mpi.org/community/lists/users/2015/01/26132.php >> > >> > >> > _______________________________________________ >> > users mailing list >> > us...@open-mpi.org >> > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users >> > Link to this post: >> http://www.open-mpi.org/community/lists/users/2015/01/26137.php >> > >> > _______________________________________________ >> > users mailing list >> > us...@open-mpi.org >> > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users >> > Link to this post: >> http://www.open-mpi.org/community/lists/users/2015/01/26138.php >> >> >> -- >> Jeff Squyres >> jsquy...@cisco.com >> For corporate legal information go to: >> http://www.cisco.com/web/about/doing_business/legal/cri/ >> >> _______________________________________________ >> users mailing list >> us...@open-mpi.org >> Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users >> Link to this post: >> http://www.open-mpi.org/community/lists/users/2015/01/26139.php >> > > > _______________________________________________ > users mailing list > us...@open-mpi.org > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users > Link to this post: > http://www.open-mpi.org/community/lists/users/2015/01/26145.php >
MODULE MOD_PRECISION integer, parameter :: dp = selected_real_kind(15, 307) ENDMODULE MOD_PRECISION PROGRAM TEST USE MOD_PRECISION USE MPI IMPLICIT NONE ! INTEGER :: iCPU,icount,iTag,ip,sendcount,sendrecv,i,iStart,iEnd ! TYPE tMPI INTEGER :: myrank, nCPU, iErr, status END TYPE tMPI ! INTEGER, ALLOCATABLE,DIMENSION(:) :: Ndata2send INTEGER, ALLOCATABLE,DIMENSION(:) :: Ndata2recv REAL(DP), ALLOCATABLE,DIMENSION(:) :: DATASEND REAL(DP), ALLOCATABLE,DIMENSION(:) :: DATARECV ! INTEGER :: send_request ( 3) INTEGER :: recv_request ( 3) INTEGER :: send_status_list (MPI_STATUS_SIZE,3) INTEGER :: recv_status_list (MPI_STATUS_SIZE,3) ! TYPE(tMPI) :: MPIdata CALL MPI_INIT(MPIdata%iErr) CALL MPI_COMM_RANK(MPI_COMM_WORLD, MPIdata%myrank, MPIdata%iErr) CALL MPI_COMM_SIZE(MPI_COMM_WORLD, MPIdata%nCPU, MPIdata%iErr) ! ALLOCATE(Ndata2send(0:MPIdata%nCPU-1)) ALLOCATE(Ndata2recv(0:MPIdata%nCPU-1)) ! Ndata2send=0 Ndata2recv=0 ! IF(MPIdata%myrank==0)THEN Ndata2send(0)=0 Ndata2send(1)=100 Ndata2send(2)=100 Ndata2send(3)=160 ENDIF IF(MPIdata%myrank==1)THEN Ndata2send(0)=130 Ndata2send(1)=0 Ndata2send(2)=160 Ndata2send(3)=160 ENDIF IF(MPIdata%myrank==2)THEN Ndata2send(0)=130 Ndata2send(1)=160 Ndata2send(2)=0 Ndata2send(3)=160 ENDIF IF(MPIdata%myrank==3)THEN Ndata2send(0)=160 Ndata2send(1)=160 Ndata2send(2)=160 Ndata2send(3)=0 ENDIF ! CALL MPI_BARRIER(MPI_COMM_WORLD, MPIdata%iErr) icount=1 DO iCPU=0,MPIdata%nCPU-1 IF(iCPU.NE.MPIdata%myrank)THEN iTag=iCPU CALL MPI_ISEND(Ndata2send(iCPU),1,MPI_INTEGER,iCPU,iTag,MPI_COMM_WORLD,send_request(icount),MPIdata%iErr) icount=icount+1 ENDIF ENDDO ! icount=1 DO iCPU=0,MPIdata%nCPU-1 IF(iCPU.NE.MPIdata%myrank)THEN iTag=MPIdata%myrank CALL MPI_IRECV(Ndata2recv(iCPU),1,MPI_INTEGER,iCPU,iTag,MPI_COMM_WORLD,recv_request(icount),MPIdata%iErr) icount=icount+1 ENDIF ENDDO ! CALL MPI_WAITALL(MPIdata%nCPU-1,send_request,send_status_list,MPIdata%iErr) CALL MPI_WAITALL(MPIdata%nCPU-1,recv_request,recv_status_list,MPIdata%iErr) ! !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ! sendcount=1 DO iCPU=0,MPIdata%nCPU-1 IF(MPIdata%myrank.NE.iCPU)THEN ! ALLOCATE(DATASEND(Ndata2send(iCPU))) ! DO ip=1,Ndata2send(iCPU) DATASEND(ip) = REAL(ip+MPIdata%myrank,dp) ENDDO ! iTag=iCPU CALL MPI_ISEND(DATASEND(:),Ndata2send(iCPU),MPI_DOUBLE_PRECISION,iCPU,iTag,MPI_COMM_WORLD,send_request(sendcount),MPIdata%iErr) sendcount=sendcount+1 DEALLOCATE(DATASEND) ! ENDIF ENDDO ! ! ! ALLOCATE(DATARECV(SUM(Ndata2recv(:)))) ! sendrecv=1 iStart=1 iEnd=0 DO iCPU=0,MPIdata%nCPU-1 ! iEnd=iEnd+Ndata2recv(iCPU) ! IF(MPIdata%myrank.NE.iCPU)THEN iTag=MPIdata%myrank CALL MPI_IRECV(DATARECV(iStart:iEnd),Ndata2recv(iCPU),MPI_DOUBLE_PRECISION,iCPU,iTag,MPI_COMM_WORLD,recv_request(sendrecv),MPIdata%iErr) sendrecv=sendrecv+1 ! iStart=iStart+Ndata2recv(iCPU) ! ENDIF ! ! ENDDO CALL MPI_WAITALL(MPIdata%nCPU-1,send_request,send_status_list,MPIdata%iErr) CALL MPI_WAITALL(MPIdata%nCPU-1,recv_request,recv_status_list,MPIdata%iErr) IF(MPIdata%myrank==2)THEN DO ip=1,SUM(Ndata2recv(:)) WRITE(*,*) DATARECV(ip) ENDDO ENDIF DEALLOCATE(DATARECV) CALL MPI_Finalize(MPIdata%iErr) ENDPROGRAM