<p>Hi, PETSc Developers</p><p>I have sent the matrices and codes to you. However, the sizes of the matrices are a little big and reach your limit. If you need it. I will further send them to you. thanks a lot.</p><p>Regards,</p>
<p>Yujie&nbsp;<br></p><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Yujie</b> <span dir="ltr">&lt;<a href="mailto:recrusader@gmail.com">recrusader@gmail.com</a>&gt;</span><br>
Date: Sat, Jan 31, 2009 at 4:25 PM<br>Subject: further about MatGetSubMatrix_MPIDense(), and MatTranspose() and  MatGetSubMatrix()<br>To: PETSc users list &lt;<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>&gt;<br>
<br><br><p>Hi, PETSc Developers:<br></p><p>Recently, I try to find the bug in MatGetSubMatrix_MPIDense(). The problem should be in &quot;av = v + ((Mat_SeqDense *)newmatd-&gt;A-&gt;data)-&gt;lda*icol[i];&quot; of the following codes.</p>

<p>Since &quot;av&quot; and &quot;v&quot; are used for parent matrix, I think it should not be &quot;newmatd&quot; but &quot;mat&quot; in the codes. I have revised it. The results are correct. &nbsp;</p><p>224:   for (i=0; i&lt;ncols; i++) {<br>

225:     av = v + ((Mat_SeqDense *)newmatd-&gt;A-&gt;data)-&gt;lda*icol[i];<br>226:     for (j=0; j&lt;nrows; j++) {<br>227:       *bv++ = av[irow[j] - rstart];<br>228:     }<br>229:   }</p><p>Further problem is to use MatTranspose() and MatGetSubMatrix() when MPIAIJ*MPIDense. The attached files are the testing codes (I revised ex113.c). I have used Valgrind to test it. The errors are as follows. I obtain them from Valgrind output. The command is &quot;valgrind -v --trace-children=yes --show-reachable=yes --track-fds=yes --leak-check=full mpirun -np 2 ex113&quot;.</p>

<p>This &quot;Invalid read of size 4&quot; will lead to the uncertain output. I can&#39;t figure out where the problem is. Could you give me some help? The used system is &quot;Red Hat Enterprise Linux ES release 3&quot;. thanks.</p>

<p>&quot;Finishing MatMatMult<br>Finishing MatMatMult<br>Finishing MatTranspose<br>Finishing MatTranspose<br>==23027==&nbsp;<br>==23027== Invalid read of size 4<br>==23027==    at 0x4253F2C: MatGetSubMatrix_MPIDense(_p_Mat*, _p_IS*, _p_IS*, int, MatReuse, _p_Mat**) (mpidense.c:227)<br>

==23027==    by 0x41D4F56: MatGetSubMatrix(_p_Mat*, _p_IS*, _p_IS*, int, MatReuse, _p_Mat**) (matrix.c:6162)<br>==23027==    by 0x8049643: main (ex113.c:75)<br>==23027==  Address 0x553de30 is 8 bytes after a block of size 46,952 alloc&#39;d<br>

==23027==    at 0x401AC01: malloc (vg_replace_malloc.c:207)<br>==23027==    by 0x46992C1: PetscMallocAlign(unsigned int, int, char const*, char const*, char const*, void**) (mal.c:40)<br>==23027==    by 0x46A45C3: PetscTrMallocDefault(unsigned int, int, char const*, char const*, char const*, void**) (mtr.c:194)<br>

==23027==    by 0x413E56F: MatSeqDenseSetPreallocation_SeqDense (dense.c:1945)<br>==23027==    by 0x413E26D: MatSeqDenseSetPreallocation(_p_Mat*, double*) (dense.c:1926)<br>==23027==    by 0x425C193: MatMPIDenseSetPreallocation_MPIDense (mpidense.c:1549)<br>

==23027==    by 0x425CE71: MatMPIDenseSetPreallocation(_p_Mat*, double*) (mpidense.c:1699)<br>==23027==    by 0x425B4E5: MatTranspose_MPIDense(_p_Mat*, MatReuse, _p_Mat**) (mpidense.c:963)<br>==23027==    by 0x41C3435: MatTranspose(_p_Mat*, MatReuse, _p_Mat**) (matrix.c:3843)<br>

==23027==    by 0x8049482: main (ex113.c:62)<br>==23027==&nbsp;<br>==23027== Invalid read of size 4<br>==23027==    at 0x4253F2E: MatGetSubMatrix_MPIDense(_p_Mat*, _p_IS*, _p_IS*, int, MatReuse, _p_Mat**) (mpidense.c:227)<br>
==23027==    by 0x41D4F56: MatGetSubMatrix(_p_Mat*, _p_IS*, _p_IS*, int, MatReuse, _p_Mat**) (matrix.c:6162)<br>
==23027==    by 0x8049643: main (ex113.c:75)<br>==23027==  Address 0x553de34 is 12 bytes after a block of size 46,952 alloc&#39;d<br>==23027==    at 0x401AC01: malloc (vg_replace_malloc.c:207)<br>==23027==    by 0x46992C1: PetscMallocAlign(unsigned int, int, char const*, char const*, char const*, void**) (mal.c:40)<br>

==23027==    by 0x46A45C3: PetscTrMallocDefault(unsigned int, int, char const*, char const*, char const*, void**) (mtr.c:194)<br>==23027==    by 0x413E56F: MatSeqDenseSetPreallocation_SeqDense (dense.c:1945)<br>==23027==    by 0x413E26D: MatSeqDenseSetPreallocation(_p_Mat*, double*) (dense.c:1926)<br>

==23027==    by 0x425C193: MatMPIDenseSetPreallocation_MPIDense (mpidense.c:1549)<br>==23027==    by 0x425CE71: MatMPIDenseSetPreallocation(_p_Mat*, double*) (mpidense.c:1699)<br>==23027==    by 0x425B4E5: MatTranspose_MPIDense(_p_Mat*, MatReuse, _p_Mat**) (mpidense.c:963)<br>

==23027==    by 0x41C3435: MatTranspose(_p_Mat*, MatReuse, _p_Mat**) (matrix.c:3843)<br>==23027==    by 0x8049482: main (ex113.c:62)<br>Finishing MatGetSubMatrix<br>Finishing MatGetSubMatrix<br>&quot;<br></p><p>Regards,</p>

<p>Yujie</p>
</div><br>