# # (C) 2004 by Argonne National Laboratory. # See COPYRIGHT in top-level directory. # # Definitions for various MPI I/O Read/write tests # If we want a separate step to check the file as written different # from the read step, insert it here. # # If the open fails, jump to 111 call mpi_file_open( comm, filename, MPI_MODE_RDWR + MPI_MODE_CREATE, MPI_INFO_NULL, fh, ierr ) if (ierr .ne. MPI_SUCCESS) then goto 111 endif call mpi_file_close( fh, ierr ) call mpi_barrier( comm, ierr ) call mpi_comm_rank( comm, r, ierr ) if (r .eq. 0) then call mpi_file_delete( filename, MPI_INFO_NULL, ierr ) endif call mpi_barrier( comm, ierr ) # Common code to initialize the buffer for contiguous writes do i=1, n buf(i) = r*n + (k-1)*n*s + i-1 enddo # This is for double buffered tests do i=1, n buf2(i) = r*n + (k)*n*s + i-1 enddo do i=1, n ans = r*n + (k-1)*n*s + i-1 if (buf(i) .ne. ans) then errs = errs + 1 if (errs .le. 10) then print *, r, k, ' buf(',i,') = ', buf(i), ' expected ', ans endif endif enddo do i=1, n buf(i) = - (r*n + (k-1)*n*s + i) enddo do i=1, n if (buf2(i) .ne. r*n + (k)*n*s + i-1) then errs = errs + 1 if (errs .le. 10) then print *, r,k,' buf2(',i,') = ', buf2(i) endif endif enddo do i=1, n buf2(i) = - (r*n + (k)*n*s + i) enddo # Common error check if (ierr .ne. MPI_SUCCESS) then errs = errs + 1 if (errs .le. 10) then call MTestPrintError( ierr ) endif endif # Common error check when MPI_ERR_IN_STATUS is a possibility # (status array is then statuses, of length nreq (one status per request) if (ierr .ne. MPI_SUCCESS) then errs = errs + 1 if (errs .le. 10) then call MTestPrintError( ierr ) if (ierr .eq. MPI_ERR_IN_STATUS) then do i=1, nreq if (statuses(MPI_ERROR,i) .ne. MPI_SUCCESS) then print *, 'For statuses[', i, '], error is:' call MTestPrintError( statuses(MPI_ERROR,i) ) endif enddo endif endif endif # Common offset computation, based on the block, rank, size offset = (r * n + (k - 1) * n * s) * intsize # Set the view of the file for this process; suitable for # collective I/O and independent file I/O without seek call mpi_type_vector( b, n, n*s, MPI_INTEGER, filetype, ierr ) call mpi_type_commit( filetype, ierr ) offset = r * n * intsize call mpi_file_set_view( fh, offset, MPI_INTEGER, filetype, "native", MPI_INFO_NULL, ierr ) call mpi_type_free( filetype, ierr ) # Some tests require that the individual processes proceed in order. # The following definitions initialize the src and dest, and arrange # to pass a token using MPI_Ssend # Prereqs: r and s contain rank and size, and src,dest are declared. # The ring is executed b times, with index variable k src = mod( r + s - 1, s ) dest = mod( r + 1, s ) if (s .eq. 1) then src = MPI_PROC_NULL dest = MPI_PROC_NULL endif if (r .eq. s-1) then call mpi_ssend( MPI_BOTTOM, 0, MPI_INTEGER, dest, 1, comm, ierr ) endif call mpi_recv( MPI_BOTTOM, 0, MPI_INTEGER, src, k, comm, MPI_STATUS_IGNORE, ierr ) if (r .eq. s-1) then call mpi_ssend( MPI_BOTTOM, 0, MPI_INTEGER, dest, k+1, comm, ierr ) else call mpi_ssend( MPI_BOTTOM, 0, MPI_INTEGER, dest, k, comm, ierr ) endif if (r .eq. 0) then call mpi_recv( MPI_BOTTOM, 0, MPI_INTEGER, src, b+1, comm, MPI_STATUS_IGNORE, ierr ) endif # # ---------------------------------------------------------------------------- # This test uses the individual file pointers. # To reach the correct locations, we seek to the position integer status(MPI_STATUS_SIZE) integer buf(MAX_BUFFER), ans include 'iooffset.h' do k=1, b call mpi_file_seek( fh, offset, MPI_SEEK_SET, ierr ) call mpi_file_write( fh, buf, n, MPI_INTEGER, status, ierr ) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_seek( fh, offset, MPI_SEEK_SET, ierr ) call mpi_file_read( fh, buf, n, MPI_INTEGER, status, ierr ) enddo # This test uses independent I/O with thread-safe, individual file pointers integer status(MPI_STATUS_SIZE) integer buf(MAX_BUFFER), ans include 'iooffset.h' do k=1, b call mpi_file_write_at( fh, offset, buf, n, MPI_INTEGER, status, ierr ) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_read_at( fh, offset, buf, n, MPI_INTEGER, status, ierr ) enddo # This test uses collective I/O with thread-safe, individual file pointers integer status(MPI_STATUS_SIZE) integer buf(MAX_BUFFER), ans include 'iooffset.h' do k=1, b call mpi_file_write_at_all( fh, offset, buf, n, MPI_INTEGER, status, ierr ) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_read_at_all( fh, offset, buf, n, MPI_INTEGER, status, ierr ) enddo # This test uses nonblocking collective I/O with thread-safe, individual file pointers integer status(MPI_STATUS_SIZE) integer request integer buf(MAX_BUFFER), ans include 'iooffset.h' do k=1, b call mpi_file_iwrite_at_all( fh, offset, buf, n, MPI_INTEGER, request, ierr ) call mpi_wait(request, status, ierr) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_iread_at_all( fh, offset, buf, n, MPI_INTEGER, request, ierr ) call mpi_wait(request, status, ierr) enddo # This test uses collective I/O with thread-safe, individual file pointers integer status(MPI_STATUS_SIZE) integer buf(MAX_BUFFER), ans include 'iooffset.h' do k=1, b call mpi_file_write_at_all_begin( fh, offset, buf, n, MPI_INTEGER, ierr ) call mpi_file_write_at_all_end( fh, buf, status, ierr ) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_read_at_all_begin( fh, offset, buf, n, MPI_INTEGER, ierr ) call mpi_file_read_at_all_end( fh, buf, status, ierr ) enddo # This test uses nonblocking I/O with independent file pointers integer statuses(MPI_STATUS_SIZE,2) integer buf(MAX_BUFFER), buf2(MAX_BUFFER), ans integer req(2), nreq include 'iooffset.h' do k=1, b ,2 nreq = 1 call mpi_file_iwrite_at( fh, offset, buf, n, MPI_INTEGER, req(1), ierr ) if (k+1 .le. b) then offset = offset + (s * n) * intsize nreq = nreq + 1 call mpi_file_iwrite_at( fh, offset, buf2, n, MPI_INTEGER, req(2), ierr ) endif call mpi_waitall( nreq, req, statuses, ierr ) enddo # No extra declarations are needed for the read step do k=1, b ,2 nreq = 1 call mpi_file_iread_at( fh, offset, buf, n, MPI_INTEGER, req(1), ierr ) if (k+1 .le. b) then offset = offset + (s * n) * intsize nreq = nreq + 1 call mpi_file_iread_at( fh, offset, buf2, n, MPI_INTEGER, req(2), ierr ) endif call mpi_waitall( nreq, req, statuses, ierr ) if (nreq .eq. 2) then endif enddo # This test uses nonblocking I/O with independent file pointers and explicit # seeks integer statuses(MPI_STATUS_SIZE,2) integer buf(MAX_BUFFER), buf2(MAX_BUFFER), ans integer req(2), nreq include 'iooffset.h' do k=1, b ,2 nreq = 1 call mpi_file_seek( fh, offset, MPI_SEEK_SET, ierr ) call mpi_file_iwrite( fh, buf, n, MPI_INTEGER, req(1), ierr ) if (k+1 .le. b) then offset = offset + (s * n) * intsize call mpi_file_seek( fh, offset, MPI_SEEK_SET, ierr ) nreq = nreq + 1 call mpi_file_iwrite( fh, buf2, n, MPI_INTEGER, req(2), ierr ) endif call mpi_waitall( nreq, req, statuses, ierr ) enddo # No extra declarations are needed for the read step do k=1, b ,2 nreq = 1 call mpi_file_seek( fh, offset, MPI_SEEK_SET, ierr ) call mpi_file_iread( fh, buf, n, MPI_INTEGER, req(1), ierr ) if (k+1 .le. b) then offset = offset + (s * n) * intsize call mpi_file_seek( fh, offset, MPI_SEEK_SET, ierr ) nreq = nreq + 1 call mpi_file_iread( fh, buf2, n, MPI_INTEGER, req(2), ierr ) endif call mpi_waitall( nreq, req, statuses, ierr ) if (nreq .eq. 2) then endif enddo # This test uses nonblocking I/O with shared file pointers integer status(MPI_STATUS_SIZE) integer buf(MAX_BUFFER), ans integer src, dest integer req do k=1, b call mpi_file_iwrite_shared( fh, buf, n, MPI_INTEGER, req, ierr ) call mpi_wait( req, status, ierr ) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_iread_shared( fh, buf, n, MPI_INTEGER, req, ierr ) call mpi_wait( req, status, ierr ) enddo # This test uses collective I/O integer status(MPI_STATUS_SIZE) integer buf(MAX_BUFFER), ans integer filetype include 'iooffset.h' do k=1, b call mpi_file_write_all( fh, buf, n, MPI_INTEGER, status, ierr ) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_read_all( fh, buf, n, MPI_INTEGER, status, ierr ) enddo # This test uses split collective I/O integer status(MPI_STATUS_SIZE) integer buf(MAX_BUFFER), ans integer filetype include 'iooffset.h' do k=1, b call mpi_file_write_all_begin( fh, buf, n, MPI_INTEGER, ierr ) call mpi_file_write_all_end( fh, buf, status, ierr ) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_read_all_begin( fh, buf, n, MPI_INTEGER, ierr ) call mpi_file_read_all_end( fh, buf, status, ierr ) enddo # This test uses the shared file pointers collectively. integer status(MPI_STATUS_SIZE) integer buf(MAX_BUFFER), ans include 'iooffset.h' do k=1, b call mpi_file_write_ordered( fh, buf, n, MPI_INTEGER, status, ierr ) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_read_ordered( fh, buf, n, MPI_INTEGER, status, ierr ) enddo # This test uses the shared file pointers with split collectives. integer status(MPI_STATUS_SIZE) integer buf(MAX_BUFFER), ans include 'iooffset.h' do k=1, b call mpi_file_write_ordered_begin( fh, buf, n, MPI_INTEGER, ierr ) call mpi_file_write_ordered_end( fh, buf, status, ierr ) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_read_ordered_begin( fh, buf, n, MPI_INTEGER, ierr ) call mpi_file_read_ordered_end( fh, buf, status, ierr ) enddo # This test uses the shared file pointers independently. # We pass a token to control the oredering integer status(MPI_STATUS_SIZE) integer buf(MAX_BUFFER), ans integer src, dest do k=1, b call mpi_file_write_shared( fh, buf, n, MPI_INTEGER, status, ierr ) enddo # No extra declarations are needed for the read step do k=1, b call mpi_file_read_shared( fh, buf, n, MPI_INTEGER, status, ierr ) enddo