<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<font><font><font><font><font><font>Hi all,<br>
<br>
In the MPI2 Standard, chapter "File views"
(<a class="moz-txt-link-freetext"
href="http://www.mpi-forum.org/docs/mpi-20-html/node184.htm#Node184">http://www.mpi-forum.org/docs/mpi-20-html/node184.htm#Node184</a>)
:</font></font></font></font></font></font><br>
<blockquote>"If the file is opened for writing, neither the etype nor
the filetype is permitted to contain overlapping regions. This
restriction is equivalent to the `datatype used in a receive cannot
specify overlapping regions' restriction for communication."<br>
</blockquote>
<font><font><font><font><font><font>I understand that if the file is
opened for reading, overlapping regions are permitted.<br>
I tried with a very simple example and the results with mpich2-1.2.1p1
are surprising.<br>
<br>
The filetype is described by:<br>
dsp[0]= 0;<br>
lng[0] = 2;<br>
</font></font></font></font></font></font><font><font><font><font><font><font>
dsp[1]= 1;<br>
</font></font></font></font></font></font><font><font><font><font><font><font>
lng[1] = 2;<br>
err = MPI_Type_indexed (2, lng, dsp, MPI_CHAR, &filetype);<br>
With this definition, there is an overlap in the byte at offset 1.<br>
</font></font></font></font></font></font><font><font><font><font><font><font>The
file contains following values in bytes: 0,1,2,3,4,5,6,7,8,9,10, ....<br>
I expect to read "0, 1, 1, 2, 3, 4, 4, 5, 6, 7, 7, 8" (each value 3n+1
must be doubled).<br>
<br>
The results I get depend on how I read the file :<br>
Read 1 bytes per 1 bytes: 0 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1<br>
Read 2 bytes per 2 bytes: 0 1 1 1 1 2 3 4 4 4 4 5 6 7
7 7 7 8 9 10<br>
Read 3 bytes per 3 bytes: 0 1 1 1 2 3 4 4 5 6 7 7 7 8 9
10 10 11 12 13<br>
Read 4 bytes per 4 bytes: 0 1 1 2 3 4 4 5 6 7 7 8 9 10 10
11 12 13 13 14<br>
Read 5 bytes per 5 bytes: 0 1 1 2 3 4 4 5 6 7 7 7 8 9 10
10 10 11 12 13<br>
Read 6 bytes per 6 bytes: 0 1 1 2 3 4 4 4 5 6 7 7 7 8 9
10 10 11 12 13<br>
Read 7 bytes per 7 bytes: 0 1 1 2 3 4 4 4 5 6 7 7 8 9 10
10 11 12 13 13<br>
Read 8 bytes per 8 bytes: 0 1 1 2 3 4 4 5 6 7 7 8 9 10 10
11 12 13 13 14<br>
Read 9 bytes per 9 bytes: 0 1 1 2 3 4 4 5 6 7 7 8 9 10 10
11 12 13 13 13<br>
Only the results "4 bytes per 4 bytes" and "8 bytes per 8 bytes" are
correct. The others are false.<br>
<br>
Is it possible to read overlapping regions ?<br>
Or is there something I misunderstand ?<br>
<br>
Pascal<br>
<br>
============= Simple program ==========<br>
#include <stdio.h><br>
#include "mpi.h"<br>
<br>
#define file "/tmp/TESTFILE"<br>
#define IO_SIZE 30<br>
char buffer[IO_SIZE];<br>
int dsp[2], lng[2], myid, i, n, err, read_nb;<br>
MPI_Datatype filetype;<br>
MPI_Status status;<br>
MPI_File fh;<br>
<br>
int main(int argc,char **argv) {<br>
MPI_Init(&argc,&argv);<br>
MPI_Comm_rank(MPI_COMM_WORLD,&myid);<br>
<br>
if (!myid) {<br>
err = MPI_File_open(MPI_COMM_SELF, file, MPI_MODE_CREATE |
MPI_MODE_RDWR, MPI_INFO_NULL, &fh);<br>
for (i=0; i<IO_SIZE; i++) buffer [i] = i;<br>
err = MPI_File_write (fh, buffer, IO_SIZE, MPI_CHAR,
&status);<br>
<br>
dsp[0]= 0;<br>
lng[0]= 2;<br>
dsp[1]= 1; </font></font></font></font></font></font><font><font><font><font><font><font>
/* overlap at offset 1 */</font></font></font></font></font></font><br>
<font><font><font><font><font><font> lng[1]= 2;<br>
err = MPI_Type_indexed (2, lng, dsp, MPI_CHAR, &filetype);<br>
err = MPI_Type_commit (&filetype);<br>
<br>
err = MPI_File_set_view(fh, 0, MPI_CHAR, filetype, "native",
MPI_INFO_NULL);<br>
<br>
for (n=1; n<10; n++) {<br>
read_nb=IO_SIZE/n;<br>
MPI_File_seek(fh, 0, MPI_SEEK_SET);<br>
// Read the file n bytes per nbytes<br>
for (i=0; i<read_nb; i++) MPI_File_read(fh,
buffer+i*n, n, MPI_CHAR, &status);<br>
// Display result<br>
printf("Read %d bytes per %d bytes: ", n);<br>
for (i=0; i<20; i++) printf(" %2d", buffer[i]);<br>
printf("\n");<br>
}<br>
err = MPI_File_close(&fh);<br>
}<br>
MPI_Finalize();<br>
}</font></font></font></font></font></font>
</body>
</html>