<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
I noticed that you are using ARKIMEX in the code. A temporary workaround you can try is to disable adaptive time stepping, e.g. by using the option -ts_adapt_type none. Then MatShift() will not be called when the Jacobians are computed.
<div><br>
</div>
<div>Hong (Mr.) <br>
<div><br>
<blockquote type="cite">
<div>On Oct 5, 2023, at 4:52 PM, Fackler, Philip via petsc-users <petsc-users@mcs.anl.gov> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div class="elementToProof" 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; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Consolas, Courier, monospace; font-size: 12pt;">
Aha! That makes sense. Thank you.<br>
</div>
<div class="elementToProof" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; 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; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;"><br>
</div>
<div id="Signature">
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<span style="font-size: 11pt;"><strong>Philip Fackler<br>
</strong></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<div><span style="font-size: 11pt;">Research Software Engineer, Application Engineering Group</span></div>
<div><span style="font-size: 11pt;">Advanced Computing Systems Research Section</span></div>
<div><span style="font-size: 11pt;">Computer Science and Mathematics Division<br>
</span></div>
<div><span style="font-size: 11pt;"><strong>Oak Ridge National Laboratory</strong></span><span style="font-size: 11pt;"></span><br>
</div>
</div>
</div>
</div>
</div>
<div id="appendonsend" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; 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; -webkit-text-stroke-width: 0px; text-decoration: none;">
</div>
<hr tabindex="-1" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; 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; -webkit-text-stroke-width: 0px; text-decoration: none; display: inline-block; width: 686px;">
<span style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; 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; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;"></span>
<div id="divRplyFwdMsg" dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; 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; -webkit-text-stroke-width: 0px; text-decoration: none;">
<font face="Calibri, sans-serif" style="font-size: 11pt;"><b>From:</b><span class="Apple-converted-space"> </span>Junchao Zhang <junchao.zhang@gmail.com><br>
<b>Sent:</b><span class="Apple-converted-space"> </span>Thursday, October 5, 2023 17:29<br>
<b>To:</b><span class="Apple-converted-space"> </span>Fackler, Philip <facklerpw@ornl.gov><br>
<b>Cc:</b><span class="Apple-converted-space"> </span>petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov>; xolotl-psi-development@lists.sourceforge.net <xolotl-psi-development@lists.sourceforge.net>; Blondel, Sophie <sblondel@utk.edu><br>
<b>Subject:</b><span class="Apple-converted-space"> </span>[EXTERNAL] Re: [petsc-users] Unexpected performance losses switching to COO interface</font>
<div> </div>
</div>
<div style="caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; 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; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div dir="ltr">Wait a moment, it seems it was because we do not have a GPU implementation of MatShift...
<div>Let me see how to add it.
<div>
<div>
<div>
<div dir="ltr" class="x_gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">--Junchao Zhang</div>
</div>
</div>
<br>
</div>
</div>
</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Thu, Oct 5, 2023 at 10:58 AM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com">junchao.zhang@gmail.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr">
<div>Hi, Philip,</div>
<div> I looked at the hpcdb-NE_3-cuda file. It seems you used MatSetValues() instead of the COO interface? MatSetValues() needs to copy the data from device to host and thus is expensive.</div>
<div> Do you have profiling results with COO enabled?</div>
<div><br>
</div>
<span id="cid:ii_lndd1oy70"><Screenshot 2023-10-05 at 10.55.29 AM.png></span><br>
<div> </div>
<br clear="all">
<div>
<div dir="ltr" class="x_gmail_signature">
<div dir="ltr">--Junchao Zhang</div>
</div>
</div>
<br>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Mon, Oct 2, 2023 at 9:52 AM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@gmail.com</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<div dir="ltr">Hi, Philip,
<div> I will look into the tarballs and get back to you.</div>
<div> Thanks.<br clear="all">
<div>
<div dir="ltr" class="x_gmail_signature">
<div dir="ltr">--Junchao Zhang</div>
</div>
</div>
<br>
</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr" class="x_gmail_attr">On Mon, Oct 2, 2023 at 9:41 AM Fackler, Philip via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">
<div>
<div dir="ltr">
<div><span style="font-family: Consolas, Courier, monospace; font-size: 12pt;">We finally have xolotl ported to use the new COO interface and the aijkokkos implementation for Mat (and kokkos for Vec). Comparing this port to our previous version (using MatSetValuesStencil
and the default Mat and Vec implementations), we expected to see an improvement in performance for both the "serial" and "cuda" builds (here I'm referring to the kokkos configuration).</span></div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;"><br>
</div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;">Attached are two plots that show timings for three different cases. All of these were run on Ascent (the Summit-like training system) with 6 MPI tasks (on a single node). The CUDA cases
were given one GPU per task (and used CUDA-aware MPI). The labels on the blue bars indicate speedup. In all cases we used "-fieldsplit_0_pc_type jacobi" to keep the comparison as consistent as possible.<br>
</div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;"><br>
</div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;">The performance of RHSJacobian (where the bulk of computation happens in xolotl) behaved basically as expected (better than expected in the serial build). NE_3 case in CUDA was the only
one that performed worse, but not surprisingly, since its workload for the GPUs is much smaller. We've still got more optimization to do on this.<br>
</div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;"><br>
</div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;">The real surprise was how much worse the overall solve times were. This seems to be due simply to switching to the kokkos-based implementation. I'm wondering if there are any changes we
can make in configuration or runtime arguments to help with PETSc's performance here. Any help looking into this would be appreciated.<br>
</div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;"><br>
</div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;">The tarballs linked<span class="Apple-converted-space"> </span><a href="https://urldefense.us/v2/url?u=https-3A__drive.google.com_file_d_19X-5FL3SVkGBM9YUzXnRR-5FkVWFG0JFwqZ3_view-3Fusp-3Ddrive-5Flink&d=DwMFaQ&c=v4IIwRuZAmwupIjowmMWUmLasxPEgYsgNI-O7C4ViYc&r=DAkLCjn8leYU-uJ-kfNEQMhPZWx9lzc4d5KgIR-RZWQ&m=GTpC2k9hIdMhUg_aJkeAqd-1CP5M8bwJMJjTriVE1k-j36ZnEHerQkZOzszxWoG2&s=GW0ImGWhWr4rR5AoSULCnaP1CN1QWxTSeMDhdOuhTEA&e=" title="https://drive.google.com/file/d/19X_L3SVkGBM9YUzXnRR_kVWFG0JFwqZ3/view?usp=drive_link" id="x_m_4560154858951847936m_2345933986412643521m_3364327590849106712LPNoLPOWALinkPreview" target="_blank">here</a><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><a href="https://urldefense.us/v2/url?u=https-3A__drive.google.com_file_d_15yDBN7-2DYlO1g6RJNPYNImzr611i1Ffhv_view-3Fusp-3Ddrive-5Flink&d=DwMFaQ&c=v4IIwRuZAmwupIjowmMWUmLasxPEgYsgNI-O7C4ViYc&r=DAkLCjn8leYU-uJ-kfNEQMhPZWx9lzc4d5KgIR-RZWQ&m=GTpC2k9hIdMhUg_aJkeAqd-1CP5M8bwJMJjTriVE1k-j36ZnEHerQkZOzszxWoG2&s=tO-BnNY2myA-pIsRnBjQNoaOSjn-B3-lWGiQp7XXJwk&e=" title="https://drive.google.com/file/d/15yDBN7-YlO1g6RJNPYNImzr611i1Ffhv/view?usp=drive_link" id="x_m_4560154858951847936m_2345933986412643521m_3364327590849106712LPNoLPOWALinkPreview_1" target="_blank">here</a><span class="Apple-converted-space"> </span>are
profiling databases which, once extracted, can be viewed with hpcviewer. I don't know how helpful that will be, but hopefully it can give you some direction.</div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;"><br>
</div>
<span style="font-family: Consolas, Courier, monospace; font-size: 12pt;">Thanks for your help,</span>
<div>
<div style="font-family: Consolas, Courier, monospace; font-size: 12pt;"><br>
</div>
<div id="x_m_4560154858951847936m_2345933986412643521m_3364327590849106712Signature">
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<span style="font-size: 11pt;"><strong>Philip Fackler<br>
</strong></span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;">
<div><span style="font-size: 11pt;">Research Software Engineer, Application Engineering Group</span></div>
<div><span style="font-size: 11pt;">Advanced Computing Systems Research Section</span></div>
<div><span style="font-size: 11pt;">Computer Science and Mathematics Division<br>
</span></div>
<div><span style="font-size: 11pt;"><strong>Oak Ridge National Laboratory</strong></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</body>
</html>