<div dir="ltr"><div dir="ltr">On Thu, Jun 2, 2022 at 8:59 AM Patrick Sanan <<a href="mailto:patrick.sanan@gmail.com">patrick.sanan@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thanks, Barry and Changqing! That seems reasonable to me, so I'll make an MR with that change.</div></blockquote><div><br></div><div>Hi Patrick,</div><div><br></div><div>In the MR, could you add that option to all places we internally use Preallocator? I think we mean it for those.</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Am Mi., 1. Juni 2022 um 20:06 Uhr schrieb Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><br></div>  This appears to be a bug in the DMStag/Mat preallocator code. If you add after the DMCreateMatrix() line in your code <div><br></div><div>PetscCall(MatSetOption(A, MAT_NO_OFF_PROC_ENTRIES, PETSC_FALSE));</div><div><br></div><div>Your code will run correctly.</div><div><br></div><div>  Patrick and Matt,</div><div><br></div><div>  MatPreallocatorPreallocate_Preallocator() has </div><div><br></div><div>PetscCall(MatSetOption(A, MAT_NO_OFF_PROC_ENTRIES, p->nooffproc));</div><div><br></div><div>to make the assembly of the stag matrix from the preallocator matrix a little faster,</div><div><br></div><div>but then it never "undoes" this call. Hence the matrix is left in the state where it will error if someone sets values from a different rank (which they certainly can using DMStagMatSetValuesStencil(). </div><div><br></div><div> I think you need to clear the NO_OFF_PROC at the end of MatPreallocatorPreallocate_Preallocator() because just because the preallocation process never needed communication does not mean that when someone puts real values in the matrix they will never use communication; they can put in values any dang way they please.</div><div><br></div><div>I don't know why this bug has not come up before.</div><div><br></div><div>  Barry</div><div><br><div><br><blockquote type="cite"><div>On May 31, 2022, at 11:08 PM, Ye Changqing <<a href="mailto:Ye_Changqing@outlook.com" target="_blank">Ye_Changqing@outlook.com</a>> wrote:</div><br><div><div style="font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Dear all,</div><div style="font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br></div><div style="font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;font-family:Calibri,Helvetica,sans-serif;font-size:12pt">[BugReport.c] is a sample code, [BugReportParallel.output] is the output when execute BugReport with mpiexec, [BugReportSerial.output] is the output in serial execution.</div><div style="font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br></div><div style="font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Best,</div><div style="font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Changqing</div><div id="gmail-m_3304808727657521988gmail-m_4756362046906407553appendonsend" style="font-family:Helvetica;font-size:18px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"></div><div style="font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br></div><hr style="font-family:Helvetica;font-size:18px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline-block;width:1075.05px"><span style="font-family:Helvetica;font-size:18px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline"></span><div id="gmail-m_3304808727657521988gmail-m_4756362046906407553divRplyFwdMsg" dir="ltr" style="font-family:Helvetica;font-size:18px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><font style="font-size:11pt" face="Calibri, sans-serif"><b>发件人:</b><span> </span>Dave May <<a href="mailto:dave.mayhem23@gmail.com" target="_blank">dave.mayhem23@gmail.com</a>><br><b>发送时间:</b><span> </span>2022年5月31日 22:55<br><b>收件人:</b><span> </span>Ye Changqing <<a href="mailto:Ye_Changqing@outlook.com" target="_blank">Ye_Changqing@outlook.com</a>><br><b>抄送:</b><span> </span><a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><span> </span><<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>><br><b>主题:</b><span> </span>Re: [petsc-users] Mat created by DMStag cannot access ghost points</font><div> </div></div><div style="font-family:Helvetica;font-size:18px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div><br></div><div><br><div><div dir="ltr">On Tue 31. May 2022 at 16:28, Ye Changqing <<a href="mailto:Ye_Changqing@outlook.com" target="_blank">Ye_Changqing@outlook.com</a>> wrote:<br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Dear developers of PETSc,</div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br></div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">I encountered a problem when using the DMStag module. The program could be executed perfectly in serial, while errors are thrown out in parallel (using mpiexec). Some rows in Mat cannot be accessed in local processes when looping all elements in DMStag. The DM object I used only has one DOF in each element. Hence, I could switch to the DMDA module easily, and the program now is back to normal.</div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br></div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Some snippets are below.</div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br></div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Initialise a DMStag object:</div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">PetscCall(DMStagCreate2d(PETSC_COMM_WORLD, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, M, N, PETSC_DECIDE, PETSC_DECIDE, 0, 0, 1, DMSTAG_STENCIL_BOX, 1, NULL, NULL, &(s_ctx->dm_P)));<br></div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Created a Mat:</div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">PetscCall(DMCreateMatrix(s_ctx->dm_P, A));<br></div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Loop:</div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">PetscCall(DMStagGetCorners(s_ctx->dm_V, &startx, &starty, &startz, &nx, &ny, &nz, &extrax, &extray, &extraz));</div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><span style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">for (ey = starty; ey < starty + ny; ++ey)</span></div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><div>for (ex = startx; ex < startx + nx; ++ex)</div>{<br></div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">...</div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">PetscCall(DMStagMatSetValuesStencil(s_ctx->dm_P, *A, 2, &row[0], 2, &col[0], &val_A[0][0], ADD_VALUES));  // The traceback shows the problem is in here.<br></div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">}</div></div></blockquote><div dir="auto"><br></div><div dir="auto">In addition to the code or MWE, please forward us the complete stack trace / error thrown to stdout.</div><div dir="auto"><br></div><div dir="auto">Thanks,</div><div dir="auto">Dave</div><div dir="auto"><br></div><div dir="auto"><br></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"></div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br></div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Best,</div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt">Changqing</div><div style="font-family:Calibri,Helvetica,sans-serif;font-size:12pt"><br></div></div></blockquote></div></div></div><span id="gmail-m_3304808727657521988gmail-m_4756362046906407553cid:A74F9B90-FA44-4E0C-AD24-8C4CEEA1607C"><BugReport.c></span><span id="gmail-m_3304808727657521988gmail-m_4756362046906407553cid:A5F0C74A-B57C-4784-9AA8-E0D07E2190C0"><BugReportParallel.output></span><span id="gmail-m_3304808727657521988gmail-m_4756362046906407553cid:6E964459-DB49-4014-85A5-09B37E4F6B71"><BugReportSerial.output></span></div></blockquote></div><br></div></div></blockquote></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>