94 提供公平性(Fortran)

BACKWARD FORWARD


作为一个替代

parameter( large = 128 ) 
   integer requests(large); 
   integer statuses(MPI_STATUS_SIZE,large); 
   integer indices(large); 
   integer buf(large); 
   logical done 
   do 10 i = 1,size-1 
10 call MPI_Irecv( buf(i), 1, MPI_INTEGER, i, 
  *            MPI_ANY_TAG, MPI_COMM_WORLD, requests(i), ierr ) 
20 if (.not. done) then 
    call MPI_Waitsome( size-1, requests, ndone,  
                       indices, statuses, ierr ) 
    do 30 i=1, ndone 
        j = indices(i) 
        print *, 'Msg from ', statuses(MPI_SOURCE,i), ' with tag', 
     *               statuses(MPI_TAG,i) 
        call MPI_Irecv( buf(j), 1, MPI_INTEGER, j, 
                   MPI_ANY_TAG, MPI_COMM_WORLD, requests(j), ierr ) 
        done = ... 
30  continue 
    goto 20 
    endif 


Copyright: NPACT BACKWARD FORWARD