Quantcast
Channel: Clusters and HPC Technology
Viewing all articles
Browse latest Browse all 927

MPI_FILE_WRITE_SHARED odd behavior?

$
0
0

I'm using MPI_FILE_WRITE_SHARED to write some error output to a single file.  NFS is used so that all nodes write/read to the same files.  When I run the program on any single node with multiple processes, error output occurs correctly.  However, when I run the code across multiple nodes, nothing get written to the file.  Here's a simple test program

   Program MPIwriteTest   
      use mpi
      implicit none
      integer mpiFHerr, mpiErr, myRank
      character (len=80) string
      character(len=2), parameter:: CRLF = char(13)//char(10) 
      
      ! Initialze MPI and get rank
      call MPI_INIT( mpierr )
      call MPI_COMM_RANK(MPI_COMM_WORLD, myRank, mpierr)
      
      ! open and close file MPIerror.dat to delete any existing file
      call MPI_FILE_OPEN(MPI_COMM_WORLD, 'MPIerror.dat', MPI_MODE_WRONLY+MPI_MODE_CREATE+MPI_MODE_SEQUENTIAL+MPI_MODE_DELETE_ON_CLOSE, &
               MPI_INFO_NULL, mpiFHerr, mpiErr)
      call MPI_FILE_CLOSE(mpiFHerr, mpiErr) ! This will delete the file.          
      ! open but don't delete on close         
      call MPI_FILE_OPEN(MPI_COMM_WORLD, 'MPIerror.dat', MPI_MODE_WRONLY+MPI_MODE_CREATE+MPI_MODE_SEQUENTIAL, &
               MPI_INFO_NULL, mpiFHerr, mpiErr)
   
      ! test code just just does simple write
      write(string,'(a,i0)') 'Error from process: ', myRank
      call MPI_FILE_WRITE_SHARED(mpiFHerr, trim(string)//CRLF, len_trim(string)+2, MPI_CHARACTER, MPI_STATUS_IGNORE, mpiErr)
      
      ! close and end
      call MPI_FILE_CLOSE(mpiFHerr, mpiErr)
      call MPI_FINALIZE(mpierr)    
      
   end program MPIwriteTest

I've also noticed if the file already exists (and I don't do the open and delete_on_close), then the file contains text, but sometime the file is corrupt.  Is there something wrong in this code?  Is MPI not playing well with NFS?

BTW, I'm using parallel studio xe 2019 update 4 cluster ed.  

thanks, -joe


Viewing all articles
Browse latest Browse all 927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>