[mpich-discuss] ROMIO: 2 phase IO method and error handling
Pascal Deveze
Pascal.Deveze at bull.net
Mon Aug 23 09:35:36 CDT 2010
I discovered that I can read after the end of file !
After a look in the romio source code, I see that the "2 phase IO"
method for read:
1) Does not return the right count value in the status
2) Erases data in the read buffer after the last valid byte read from
the file.
Has anybody an idea on how to correct this ?
In the file src/mpi/romio/adio/common/ad_read_coll.c line 269, there is
a comment:
/* This is a temporary way of filling in status. The right way is to
keep track of how much data was actually read and placed in buf
during collective I/O. */
This clearly points the problem. The solution seems not trivial.
Has somebody an idea on a possible solution ?
Here is a little program to reproduce it: It writes 5 bytes on a file
(0,1,2,3,4) and two MPI processes try to read 10 bytes.
The read are succeeded and the 5 read bytes are correct, but:
1) The count value is set to 10 (instead of 5 because only 5 valid
bytes are read).
2) The 5 last bytes of the read buffers are overwritten (in this case
the values 99 are erased by 0)
================ EXAMPLE =================================
#include "mpi.h"
#define IO_SIZE 10
int main(int argc, char **argv) {
MPI_File fh;
MPI_Status status;
int i, myid, count;
unsigned char buffer[IO_SIZE];
MPI_Init(&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);
MPI_File_open(MPI_COMM_WORLD, "little_test_file", MPI_MODE_CREATE |
MPI_MODE_RDWR, MPI_INFO_NULL, &fh);
MPI_File_set_errhandler(fh,MPI_ERRORS_ARE_FATAL);
for (i=0; i < IO_SIZE; i++) buffer [i] = i;
if (myid) MPI_File_write(fh,buffer,IO_SIZE-5,MPI_CHAR,&status);
for (i=0; i < IO_SIZE; i++) buffer [i] = 99;
MPI_File_seek(fh, 0, MPI_SEEK_SET);
MPI_File_read_all(fh,buffer, IO_SIZE, MPI_BYTE, &status);
MPI_Get_count(&status, MPI_CHAR, &count);
printf ("%d: data after read : %d %d %d %d %d %d %d %d %d %d\n", myid,
buffer[0], buffer[1], buffer[2],
buffer[3], buffer[4], buffer[5],
buffer[6], buffer[7], buffer[8], buffer[9]);
if (count!=5) printf("%d: ====> ERROR: read count=%d\n", myid, count);
MPI_File_close(&fh);
MPI_Finalize();
}
================ RESULTS =================================
mpiexec -n 2 a.out
0: data after read : 0 1 2 3 4 0 0 0 0 0
0: ====> ERROR: read count=10
1: data after read : 0 1 2 3 4 0 0 0 0 0
1: ====> ERROR: read count=10
od -t d1 little_test_file
0000000 0 1 2 3 4
More information about the mpich-discuss
mailing list