Commit 56b997ee authored by Hal Finkel's avatar Hal Finkel
Browse files

Work around MPI bug where MPI_Get_count does not return zero for zero count

parent 9796d0ae
......@@ -122,8 +122,10 @@ void GenericFileIO_MPI::write(const void *buf, size_t count, off_t offset,
if (MPI_File_write_at(FH, offset, (void *) buf, count, MPI_BYTE, &status) != MPI_SUCCESS)
throw runtime_error("Unable to write " + D + " to file: " + FileName);
int scount;
(void) MPI_Get_count(&status, MPI_BYTE, &scount);
int scount = 0;
// On some systems, MPI_Get_count will not return zero even when count is zero.
if (count > 0)
(void) MPI_Get_count(&status, MPI_BYTE, &scount);
count -= scount;
buf = ((char *) buf) + scount;
......@@ -140,8 +142,10 @@ void GenericFileIO_MPICollective::read(void *buf, size_t count, off_t offset,
if (MPI_File_read_at_all(FH, offset, buf, count, MPI_BYTE, &status) != MPI_SUCCESS)
throw runtime_error("Unable to read " + D + " from file: " + FileName);
int scount;
(void) MPI_Get_count(&status, MPI_BYTE, &scount);
int scount = 0;
// On some systems, MPI_Get_count will not return zero even when count is zero.
if (count > 0)
(void) MPI_Get_count(&status, MPI_BYTE, &scount);
count -= scount;
buf = ((char *) buf) + scount;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment