[mpich-discuss] MPI-IO issue
Grismer, Matthew J Civ USAF AFMC AFRL/RBAT
Matthew.Grismer at wpafb.af.mil
Wed Feb 8 15:46:00 CST 2012
I am attempting to use MPI-IO to read block, structured data from a
file. Three three-dimensional coordinate arrays are stored in the file,
one after another with Fortran ordering and in binary (not Fortran
unformatted):
header info
(((x(i,j,k),i=1,ie),j=1,je),k=1,ke)
(((y(i,j,k),i=1,ie),j=1,je),k=1,ke)
(((z(i,j,k),i=1,ie),j=1,je),k=1,ke)
Each processor reads a block subset of the arrays, and I've defined a
derived type using MPI_TYPE_INDEXED for the blocks that go to each
processor. MPI_TYPE_INDEXED takes as arguments the number of blocks,
block size, and block displacement; I created (and committed) the
datatype with the number of blocks/displacements 3 times (i.e.
subsetie*subsetje*subsetke*3) what I need for one variable above on a
given processor. Then I used the following to read the file across the
processors:
count = subsetie*subsetje*subsetke
call MPI_FILE_SET_VIEW ( fh, skipheader, mpi_real8, newdatatype,
"native", mpi_info_null, ierror )
call MPI_FILE_READ_ALL ( fh, x, count, mpi_real8, ierror )
call MPI_FILE_READ_ALL ( fh, y, count, mpi_real8, ierror )
call MPI_FILE_READ_ALL ( fh, z, count, mpi_real8, ierror )
The result from this is x is read correctly, y and z are not. However,
if I define one variable xyz(subsetie,subsetje,subsetke,3) and read all
the data in one call:
count = subsetie*subsetje*subsetke*3
call MPI_FILE_SET_VIEW ( fh, skipheader, mpi_real8, newdatatype,
"native", mpi_info_null, ierror )
call MPI_FILE_READ_ALL ( fh, xyz, count, mpi_real8, ierror )
everything is read correctly, which also verifies my derived type is
correct. Alternatively I can reset the view (with correct
displacements) after each READ_ALL and read into the individual
variables.
Is this the expected behavior? If so I do not understand how to make
successive collective reads from a file without resetting the view
before every read, which will take a toll on performance when I continue
to read many additional variables from the file.
Matt
More information about the mpich-discuss
mailing list