On 09/24/2014 01:56 AM, Au Eelis wrote:
I want to convert the input/output of my program to MPI-IO routines. To
write the same data, as is written in the already implement textmode
routines, I need a custom datatype consisting of several integers and reals.

I was hoping someone else would step up and answer for you, but after two months let's see if I can give you some guidance.

My problem is, that I don't really understand the way, how mpi_file_read
uses this extent to perform file-io on arrays of this data.

When writing data you have two things working together: the memory description (given by the "buffer, count, datatype" tuple in mpi_file_write) and the file view (by default, etype and ftype of MPI_BYTE with a displacement of 0: the same way POSIX open/read/write/close treats data in a file)

For memory, the extent is used the same way it is used when sending data between processes: if you have a count greater than 1, the extent tells MPI how to walk through memory (tells it to skip over any padding, ghost cells, or anything else that doesn't belong in the file)

For the file side of things, the extent is how one tiles the datatype. Three integers have an extent of... three integers, no padding. So if you write 12 integers to the file, your file view is tiled 4 times, and 12 integers end up in the file.

Real followed by int is more complicated as you see. Maybe a compiler padded it, maybe it didn't.

> On the one
hand, the data, which is written to the file, is only the data, which is
actually used, i.e. no padding is written to the file and thus, only the
mpi_type_size is interesting for the writing. On the other hand, the
missing padding in the extent of ifort causes mpi_file_read to skip some
of the last datasets. In my opinion, this would make some sense, if the
padding of the datasets would cause corruption on the read data after
the first padding, but this is not the case. If you execute the appended
program with 4 processes, the last two of eight datasets stay
uninitialized (keep their values of -1 for each member) what suggests
that the amount of data is somehow related to the extent rather than the
type_size.

What is the problem here? Do I misunderstand, how these routines should
work?

I don't see the problem on my system with your test case: I am using gfortran.

PS: Does the stat(1) variable mean anything? It returns 0 all the time.

That is an MPI status object. You can't do much with it directly, but you can call MPI_Status_get_bytes to see how much data was transferred.

PS you have created a type without freeing and your variable names are inscrutable -- and I like C-style 6 character variables a lot!

==rob
--
Rob Latham
Mathematics and Computer Science Division
Argonne National Lab, IL USA

Reply via email to