<div>I&nbsp;have written a MPI Program that goes as below.</div>
<div><br>program.c<br>~~~~~~~</div>
<div>&nbsp;</div>
<div>#include &quot;mpi.h&quot;<br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;string.h&gt;</div>
<p>#define ROWS&nbsp;&nbsp; (long)(2 * nprocs)<br>#define COLS&nbsp;&nbsp; (long)(4 * nprocs)<br>#define MPI_ERR_CHECK(error_code) if((error_code) != MPI_SUCCESS) { \<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MPI_Error_string(error_code, string, &amp;len); \
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fprintf(stderr, &quot;error_code: %s\n&quot;, string); \<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return error_code; \<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</p>
<p><br>int main(int argc, char **argv) {<br>&nbsp; int *buf = NULL, nprocs = 0, mynod = 0, error_code = 0, len = 0, i = 0, j = 0, provided;<br>&nbsp; char string[MPI_MAX_ERROR_STRING], filename[] = &quot;pvfs2:/tmp/pvfs2-fs/TEST&quot;;
<br>&nbsp; MPI_Datatype darray;<br>&nbsp; MPI_File fh;<br>&nbsp; MPI_Status status;</p>
<p>&nbsp; error_code = MPI_Init_thread(&amp;argc, &amp;argv, MPI_THREAD_MULTIPLE, &amp;provided); MPI_ERR_CHECK(error_code);<br>&nbsp; error_code = MPI_Comm_size(MPI_COMM_WORLD, &amp;nprocs); MPI_ERR_CHECK(error_code);<br>&nbsp; error_code = MPI_Comm_rank(MPI_COMM_WORLD, &amp;mynod); MPI_ERR_CHECK(error_code);
</p>
<p>&nbsp; int array_size[2]&nbsp;&nbsp;&nbsp; = {ROWS, COLS};<br>&nbsp; int array_distrib[2] = {MPI_DISTRIBUTE_BLOCK, MPI_DISTRIBUTE_BLOCK};<br>&nbsp; int array_dargs[2]&nbsp;&nbsp; = {MPI_DISTRIBUTE_DFLT_DARG, MPI_DISTRIBUTE_DFLT_DARG};<br>&nbsp; int array_psizes[2]&nbsp; = {nprocs, 1};
</p>
<p>&nbsp; error_code = MPI_Type_create_darray(nprocs, mynod, 2, array_size, array_distrib, array_dargs, array_psizes, MPI_ORDER_C, MPI_INT, &amp;darray); MPI_ERR_CHECK(error_code);<br>&nbsp; error_code = MPI_Type_commit(&amp;darray); MPI_ERR_CHECK(error_code);
<br>&nbsp; error_code = MPI_File_open(MPI_COMM_WORLD, filename, MPI_MODE_RDONLY, MPI_INFO_NULL, &amp;fh); MPI_ERR_CHECK(error_code);<br>&nbsp; error_code = MPI_File_set_view(fh, 0, MPI_INT, darray, &quot;native&quot;, MPI_INFO_NULL); MPI_ERR_CHECK(error_code);
<br>&nbsp; buf = (int *) calloc(COLS+1, sizeof MPI_INT);<br>&nbsp; if(!buf) { fprintf(stderr, &quot;malloc error\n&quot;); exit(0); }</p>
<p>&nbsp; for(i = 0; i &lt; ROWS/nprocs; i++) {<br>&nbsp;&nbsp;&nbsp; error_code = MPI_File_read_all(fh, buf, COLS, MPI_INT, &amp;status); MPI_ERR_CHECK(error_code);<br>&nbsp; }</p>
<div>&nbsp; free(buf);<br>&nbsp; MPI_Finalize();<br>&nbsp; return 0;<br>}</div>
<div>~~~~~~~~<br>&nbsp;<br>I have used extremely small buffer sizes in this example program just to check the validity of the program.&nbsp;My file is 1G in size and I am just reading a small portion of the file to test the program. I am getting strange errors while running the program. Sometimes under the control of a debugger the program will fail in the line where I &quot;free(buf);&quot;.
</div>
<div>2:&nbsp; (gdb) backtrace<br>0:&nbsp; #0&nbsp; main (argc=1, argv=0xbf8f8134) at program.c:44<br>1:&nbsp; #0&nbsp; main (argc=1, argv=0xbf80a044) at program.c:44<br>2:&nbsp; #0&nbsp; 0x00211ed8 in _int_free () from /lib/libc.so.6<br>3:&nbsp; #0&nbsp; main (argc=1, argv=0xbfaf7b34) at 
program.c:44<br>0-1,3:&nbsp; (gdb) 2:&nbsp; #1&nbsp; 0x0021272b in free () from /lib/libc.so.6<br>2:&nbsp; #2&nbsp; 0x0804b655 in main (argc=1, argv=0xbfc76cb4) at program.c:43</div>
<div>&nbsp;</div>
<div>Somehow I do not think that this problem is related to freeing of the buffer because there are&nbsp;times when&nbsp;the first collective call succeeds and then subsequent&nbsp;collective calls fails with a SEGV. When I debug the program in this case, it shows me that the global variable &quot;ADIOI_Flatlist&quot; is getting corrupted. Here is where my program faults and the values of this global link list when it faults: 
</div>
<div>&nbsp;</div>
<div>0-3:&nbsp; (gdb) p ADIOI_Flatlist<br>0:&nbsp; $1 = (ADIOI_Flatlist_node *) 0x99657e8<br>1:&nbsp; $1 = (ADIOI_Flatlist_node *) 0x8e1fbb0<br>2:&nbsp; $1 = (ADIOI_Flatlist_node *) 0x85bd608<br>3:&nbsp; $1 = (ADIOI_Flatlist_node *) 0x82ee7c0<br>
0-3:&nbsp; (gdb) p ADIOI_Flatlist-&gt;next<br>0:&nbsp; $2 = (struct ADIOI_Fl_node *) 0x9986310<br>1:&nbsp; $2 = (struct ADIOI_Fl_node *) 0x8e3d218<br>2:&nbsp; $2 = (struct ADIOI_Fl_node *) 0x56&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&lt;== This is the invalid value. Somehow the link list is getting corrupted. Instead of NULL, u have an invalid value like 0x56 stored in the list. 
<br>3:&nbsp; $2 = (struct ADIOI_Fl_node *) 0x830f280</div>
<div>&nbsp;</div>
<div>Initially I felt that the problem is because I am creating a separate I/O thread. However, when I remove my code changes from the MPICH2 library,&nbsp;I continue getting&nbsp;the same errors. If somebody out there could help me out, I would really appreciate it. I have compiled the mpich2 library as follows:
</div>
<div># ./configure --with-pvfs2=&lt;pvfs2path&gt; --with-file-system=pvfs2+ufs+nfs --enable-threads=multiple -prefix=&lt;pathToInstallMpich2&gt;&nbsp;--enable-g=dbg --enable-debuginfo</div>
<div>Also my program is compiled using &quot;-ggdb3&quot; option.</div>
<p>Thanks,<br>Christina.<br>&nbsp;</p>