<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 24, 2022 at 1:54 PM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<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 style="overflow-wrap: break-word;"><br><div><br><blockquote type="cite"><div>On Jun 24, 2022, at 1:38 PM, Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:</div><br><div><div dir="ltr">I am rearranging the code for clarity from the repo but I have:<div><br></div><div>  PetscBool is_dev_ptrs;<br>  PetscCall(MatMPIAIJGetLocalMat(Pmat, MAT_INITIAL_MATRIX, &amgx->localA));<br>  PetscCall(PetscObjectTypeCompareAny((PetscObject)amgx->localA, &is_dev_ptrs, MATAIJCUSPARSE, MATSEQAIJCUSPARSE, MATMPIAIJCUSPARSE, ""));<br>  PetscPrintf(PETSC_COMM_SELF,"<b>checking against mataijcusparse amgx->localA = %d</b>\n",is_dev_ptrs);<br>  PetscCall(PetscObjectTypeCompareAny((PetscObject)Pmat, &is_dev_ptrs, MATAIJCUSPARSE, MATSEQAIJCUSPARSE, MATMPIAIJCUSPARSE, ""));<br>  PetscPrintf(PETSC_COMM_SELF,"<b>checking against mataijcusparse Pmat = %d</b>\n",is_dev_ptrs);<br></div><div><br></div><div>And it seems to show that MatMPIAIJGetLocalMat takes a <font color="#ff0000">mpiaijcusparse</font> Mat and returns an <font color="#ff0000">seqaij</font> mat (<font color="#ff0000">see below</font>):</div></div></div></blockquote><div><br></div> Yes, this is how it currently behaves as Stefano has indicated. Thus it is not currently directly suitable for use with GPUs. As Stefano has indicated it has be revised to handle <span style="color:rgb(255,0,0)">mpiaijcusparse </span>matrices correctly in the same way that <span style="font-size:inherit">MatMPIAIJGetLocalMatMerge has been revised for GPUs.</span></div><div><br></div></div></blockquote><div><br></div><div>OK, sorry, I did not understand that this is not supported. We need a MatMPIAIJCusparseGetLocalMatMerge (I read this as supported with "hstack" format, unsorted?, by Stefano)</div><div><br></div><div>What is the best way to proceed? Should we just convert to amgx->localA to mpiaijcusparse if Pmat is a cusparse matrix?<br></div><div>If so, should this code go in amgx or MatMPIAIJGetLocalMat(MAT_INITIAL_MATRIX) ?</div><div>Or should I add a MatMPIAIJCusparseGetLocalMatMerge that simply wraps these two calls for now?</div><div><br></div><div>Thanks,</div><div>Mark</div><div><br></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 style="overflow-wrap: break-word;"><div></div><div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>AMGX version 2.2.0.132-opensource<br>Built on Jun 24 2022, 09:21:43<br>Compiled with CUDA Runtime 11.5, using CUDA driver 11.5<br><b>checking against mataijcusparse amgx->localA = 0<br>checking against mataijcusparse Pmat = 1</b><br>l<font color="#ff0000">ocalA_name seqaij<br>Pmat_name mpiaijcusparse</font><br></div><div><br></div><div>Matt's existing testing code (below) then <font color="#ff0000">shows</font> the types that conform with these tests and prints that I added.</div><div><br></div><div>  // XXX DEBUG REMOVE<br>  const char* localA_name;<br>  PetscObjectGetType((PetscObject)amgx->localA, &localA_name);<br>  PetscPrintf(PETSC_COMM_SELF,"localA_name %s\n", localA_name);<br>  const char* Pmat_name;<br>  PetscObjectGetType((PetscObject)Pmat, &Pmat_name);<br>  PetscPrintf(PETSC_COMM_SELF,"Pmat_name %s\n", Pmat_name);<br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 24, 2022 at 10:00 AM Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:<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><br><div><br><blockquote type="cite"><div>On Jun 24, 2022, at 8:58 AM, Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:</div><br><div><div dir="ltr">And before we move to the MR, I think Matt found a clear problem:<div><br>* PetscCall(MatMPIAIJGetLocalMat(Pmat, MAT_REUSE_MATRIX, &amgx->localA));<br>returns "localA seqaij"</div><div><br></div>* And, oddly, PetscCall(MatSeqAIJGetArrayRead(amgx->localA, &amgx->values)); returns:<div>"it seems to detect that the pointer is a device mapped pointer but that it is invalid"</div></div></div></blockquote><div><br></div>  It does not return a device mapped pointer, it returns a valid host pointer only. MatSeqAIJGetArrayRead() is intended to only return a host pointer, it cannot return a device pointer. MatSeqAIJCusparseGetArrayRead() returns device pointers and should be used for this purpose.</div><div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>Matt, lets just comment out the REUSE line and add another INITIAL line (destroying the old Mat of course), and lets press on.</div></div></div></blockquote><div><br></div>  Looking at the code there is no way that simply using INITIAL instead of REUSE will make a code that does not work on the GPU run on the GPU. The <span style="font-family:-webkit-standard;font-size:inherit">MatMPIAIJGetLocalMat() </span>returns only a MATSEQAIJ matrix regardless of the INITIAL versus REUSE and one can never get a device pointer from a non-GPU matrix.</div><div><br></div><div>   As noted by Stefano, the code either needs to use <span style="font-family:-webkit-standard;font-size:inherit">MatMPIAIJGetLocalMatMerge</span><span style="font-family:-webkit-standard;font-size:inherit"> () which does return a CUSPARSE matrix (but the columns are not supported) or </span><span style="font-family:-webkit-standard;font-size:inherit">MatMPIAIJGetLocalMat()</span></div><div><span style="font-family:-webkit-standard;font-size:inherit">needs to be updated to return a CUSPARSE matrix when the input MPI matrix is a CUSPARSE matrix.</span></div><div><span style="font-family:-webkit-standard;font-size:inherit"><br></span></div><div><span style="font-family:-webkit-standard;font-size:inherit"><br></span></div><div><br></div><div><br><blockquote type="cite"><div><div dir="ltr"><div>We can keep the debugging code for now.</div><div><br></div><div>We (PETSc) can work on this independently,</div><div><br></div><div>Thanks,</div><div>Mark</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 24, 2022 at 8:51 AM Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:<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 dir="ltr">I am not seeing this response, I see my "hstack" comment last.<div><a href="https://gitlab.com/petsc/petsc/-/merge_requests/4323" target="_blank">https://gitlab.com/petsc/petsc/-/merge_requests/4323</a><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 23, 2022 at 4:37 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> wrote:<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> I have responded in the MR, which has all the context and the code. Please move this conversation from petsc-dev to the MR. Note you can use the little cartoon cloud symbol (upper write of the sub window with my text)  to reply to my post and keep everything in a thread for clarity.<div><br></div><div>  We are confused because it seems you are trying a variety of things and we don't know how the different things you tried resulted in the multiple errors you reported.</div><div><br></div><div><br><div><br><blockquote type="cite"><div>On Jun 23, 2022, at 3:59 PM, Matthew Martineau <<a href="mailto:mmartineau@nvidia.com" target="_blank">mmartineau@nvidia.com</a>> wrote:</div><br><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 style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span>I checked in the changes and some debugging statements.<u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)"><u></u> <u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Consolas">PetscCall(MatMPIAIJGetLocalMat(Pmat, MAT_REUSE_MATRIX, &amgx->localA));</span><span style="font-size:10pt;font-family:Consolas"><u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Consolas">PetscCall(PetscObjectTypeCompareAny((PetscObject)amgx->localA, &is_dev_ptrs, MATAIJCUSPARSE, MATSEQAIJCUSPARSE, MATMPIAIJCUSPARSE, ""));<u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span><u></u> <u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span>Then the call returns false. If we instead call PetscObjectTypeCompareAny on Pmat then it returns true. If you print the type of the matrices:<u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span><u></u> <u></u></span></div><p class="MsoNormal" style="margin:0cm 0cm 3pt;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:9pt;font-family:"Courier New";color:rgb(29,28,29)">localA seqaij<u></u><u></u></span></p><p class="MsoNormal" style="margin:0cm 0cm 3pt;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:9pt;font-family:"Courier New";color:rgb(29,28,29)">Pmat mpiaijcusparse<u></u><u></u></span></p><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span><u></u> <u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span>If you subsequently call MatSeqAIJCUSPARSEGetArrayRead on localA then it errors (presumably because of the type mismatch).<u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span><u></u> <u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span>If we call MatSeqAIJGetArrayRead on localA and then pass the `values` to AmgX it seems to detect that the pointer is a device mapped pointer but that it is invalid.<u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span><u></u> <u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Consolas">PetscCall(MatMPIAIJGetLocalMat(Pmat, MAT_REUSE_MATRIX, &amgx->localA));<u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Consolas">PetscCall(MatSeqAIJGetArrayRead(amgx->localA, &amgx->values)); // Seems to return invalid pointer, but I’ll investigate more</span><span style="font-size:10pt;font-family:Consolas"><u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span><u></u> <u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span>This doesn’t reproduce if we call:<u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:Consolas"><u></u> <u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Consolas">PetscCall(MatMPIAIJGetLocalMat(Pmat, MAT_INITIAL_MATRIX, &amgx->localA));<u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:10pt;font-family:Consolas">PetscCall(MatSeqAIJGetArrayRead(amgx->localA, &amgx->values)); // Pointer appears to be valid and we converge<u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span><u></u> <u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span>Essentially all I want to achieve is that when we are parallel, we fetch the local part of A and the device pointer to the matrix values from that structure so that we can pass to AmgX. Preferring whichever API calls are the most efficient.<span> </span><u></u><u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span><u></u> <u></u></span></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span><u></u> <u></u></span></div><div><div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0cm 0cm"><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><b><span lang="EN-US">From:</span></b><span lang="EN-US"><span> </span>Stefano Zampini <<a href="mailto:stefano.zampini@gmail.com" style="color:blue;text-decoration:underline" target="_blank">stefano.zampini@gmail.com</a>><span> </span><br><b>Sent:</b><span> </span>23 June 2022 20:55<br><b>To:</b><span> </span>Mark Adams <<a href="mailto:mfadams@lbl.gov" style="color:blue;text-decoration:underline" target="_blank">mfadams@lbl.gov</a>><br><b>Cc:</b><span> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" style="color:blue;text-decoration:underline" target="_blank">bsmith@petsc.dev</a>>; For users of the development version of PETSc <<a href="mailto:petsc-dev@mcs.anl.gov" style="color:blue;text-decoration:underline" target="_blank">petsc-dev@mcs.anl.gov</a>>; Matthew Martineau <<a href="mailto:mmartineau@nvidia.com" style="color:blue;text-decoration:underline" target="_blank">mmartineau@nvidia.com</a>><br><b>Subject:</b><span> </span>Re: [petsc-dev] MatMPIAIJGetLocalMat problem with GPUs<u></u><u></u></span></div></div></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><table border="1" cellpadding="0" style="background-color:rgb(255,235,156)"><tbody><tr><td style="padding:0.75pt"><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><b><span style="font-size:7.5pt;font-family:Verdana,sans-serif">External email: Use caution opening links or attachments</span></b><span style="font-size:7.5pt;font-family:Verdana,sans-serif"></span><u></u><u></u></div></td></tr></tbody></table><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">The logic is wrong. It should check for MATSEQAIJCUSPARSE. <u></u><u></u></div></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">On Thu, Jun 23, 2022, 21:36 Mark Adams <<a href="mailto:mfadams@lbl.gov" style="color:blue;text-decoration:underline" target="_blank">mfadams@lbl.gov</a>> wrote:<u></u><u></u></div></div><blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm"><div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">On Thu, Jun 23, 2022 at 3:02 PM Barry Smith <<a href="mailto:bsmith@petsc.dev" style="color:blue;text-decoration:underline" target="_blank">bsmith@petsc.dev</a>> wrote:<u></u><u></u></div></div><blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm"><div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">  It looks like the current code copies the nonzero values to the CPU from the MPI matrix (with the calls PetscCall(MatSeqAIJGetArrayRead(mpimat->A,&aav));<br>  PetscCall(MatSeqAIJGetArrayRead(mpimat->B,&bav));, then copies them into the CPU memory of the Seq matrix. When the matrix entries are next accessed on the GPU it should automatically copy them down to the GPU.  So the code looks ok even for GPUs. We'll need to see the full error message with what the "invalid pointer" is.<u></u><u></u></div></div></blockquote><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">I showed Matt how to peek into offloadmask and he found that it is a host state, but this is not the issue. The access method should do the copy to the device.<u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">I am thinking the logic here might be wrong. (Matt fixed "VEC" --> "MAT" in the comparison below).<u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Matt, is the issue that you are calling  <b>MatSeqAIJCUSPARSEGetArrayRead</b><b><span style="font-family:"Courier New""> </span></b>and getting a host pointer?<u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">I think the state of amgx->localA after the call to MatSeqAIJCUSPARSEGetArrayRead should be "BOTH" because this copied the data to the device so they are both valid and you should have device data.<u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-family:"Courier New"">211   PetscBool is_dev_ptrs;<br>212   PetscCall(PetscObjectTypeCompareAny((PetscObject)amgx->localA, &is_dev_ptrs, VECCUDA, VECMPICUDA, VECSEQCUDA, ""));<br>213<br>214   if (is_dev_ptrs) {<br><b>216     PetscCall(MatSeqAIJCUSPARSEGetArrayRead(amgx->localA, &amgx->values));<br></b>217   } else {<br>219     PetscCall(MatSeqAIJGetArrayRead(amgx->localA, &amgx->values));<span> </span><br>220   }</span><u></u><u></u></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm"><div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">  Barry<u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"> Yes this routine is terribly inefficient for GPU matrices, it needs to be specialized to not use the GPU memory but that is a separate issue from there being bugs in the current code.<u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">  The code also seems to implicitly assume the parallel matrix has the same nonzero pattern with a reuse. This should be checked with each use by stashing the nonzero state of the matrix into the sequential matrix and making sure the parallel matrix has that same stashed value each time. Currently if one changes the nonzero matrix of the parallel matrix one is likely to get random confusing crashes due to memory corruption. But likely not the problem here.<u></u><u></u></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><br><br><u></u><u></u></div><blockquote style="margin-top:5pt;margin-bottom:5pt"><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">On Jun 23, 2022, at 2:23 PM, Mark Adams <<a href="mailto:mfadams@lbl.gov" style="color:blue;text-decoration:underline" target="_blank">mfadams@lbl.gov</a>> wrote:<u></u><u></u></div></div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div><div><div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">We have a bug in the AMGx test snes_tests-ex13_amgx in parallel.<u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Matt Martineau found that MatMPIAIJGetLocalMat worked in the first pass in the code below, where the local matrix is created (INITIAL), but in the next pass, when "REUSE" is used, he sees an invalid pointer.<u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Matt found that it does have offloadmask == CPU. <u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Maybe it is missing logic to put the output in same state as the input?<u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Any ideas on this or should I just dig into it?<u></u><u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif"><u></u> <u></u></div></div><div><div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">Thanks,<u></u><u></u></div></div><div><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New";box-sizing:inherit;font-variant-ligatures:none;white-space:pre-wrap;border-radius:4px"><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">bool partial_setup_allowed = (pc->setupcalled && pc->flag != DIFFERENT_NONZERO_PATTERN);<u></u><u></u></span></pre><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New""><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">199   if (amgx->nranks > 1) {<u></u><u></u></span></pre><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New""><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">200     if (partial_setup_allowed) {<u></u><u></u></span></pre><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New""><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">202       PetscCall(MatMPIAIJGetLocalMat(Pmat, MAT_REUSE_MATRIX, &amgx->localA)); // This path seems doesn't work by the time we reach AmgX API<u></u><u></u></span></pre><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New""><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">203     } else {<u></u><u></u></span></pre><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New""><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">205       PetscCall(MatMPIAIJGetLocalMat(Pmat, MAT_INITIAL_MATRIX, &amgx->localA)); // This path works<u></u><u></u></span></pre><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New""><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">206     }<u></u><u></u></span></pre><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New""><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">207   } else {<u></u><u></u></span></pre><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New""><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">208     amgx->localA = Pmat;<u></u><u></u></span></pre><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New""><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">209   }<u></u><u></u></span></pre><pre style="margin:0cm 0cm 3pt;font-size:10pt;font-family:"Courier New""><span style="font-size:9pt;font-family:Monaco;color:rgb(29,28,29)">210</span></pre></div></div></div></blockquote></div></div></div></div></blockquote></div></div></blockquote></div></div></div></div></blockquote></div><br></div></div></blockquote></div>
</blockquote></div>
</div></blockquote></div><br></div></blockquote></div>
</div></blockquote></div><br></div></blockquote></div></div>