<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">The GPU supports double precision and I didn’t explicitly tell PETSc to use float when compiling, so<o:p></o:p></p>
<p class="MsoNormal">I guess it uses double? What’s the easiest way to check?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Barry, running -ksp_view shows that the solver options are the same for CPU and GPU. The only
<o:p></o:p></p>
<p class="MsoNormal">difference is the coarse grid solver for gamg (“the package used to perform factorization:”) which<o:p></o:p></p>
<p class="MsoNormal">is petsc for CPU and cusparse for GPU. I tried forcing the GPU to use petsc via<o:p></o:p></p>
<p class="MsoNormal">-fieldsplit_0_mg_coarse_sub_pc_factor_mat_solver_type, but then ksp failed to converge<o:p></o:p></p>
<p class="MsoNormal">even on the first topology optimization iteration. <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-ksp_view also shows differences in the eigenvalues from the Chebyshev smoother. For example,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">GPU: <o:p></o:p></p>
<p class="MsoNormal"> Down solver (pre-smoother) on level 2 -------------------------------<o:p></o:p></p>
<p class="MsoNormal"> KSP Object: (fieldsplit_0_mg_levels_2_) 1 MPI process<o:p></o:p></p>
<p class="MsoNormal"> type: chebyshev<o:p></o:p></p>
<p class="MsoNormal"> eigenvalue targets used: min 0.109245, max 1.2017<o:p></o:p></p>
<p class="MsoNormal"> eigenvalues provided (min 0.889134, max 1.09245) with<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">CPU: <o:p></o:p></p>
<p class="MsoNormal"> eigenvalue targets used: min 0.112623, max 1.23886<o:p></o:p></p>
<p class="MsoNormal"> eigenvalues provided (min 0.879582, max 1.12623)<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">But I guess such differences are expected?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">/Carl-Johan<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Matthew Knepley <knepley@gmail.com> <br>
<b>Sent:</b> den 30 oktober 2022 22:00<br>
<b>To:</b> Barry Smith <bsmith@petsc.dev><br>
<b>Cc:</b> Carl-Johan Thore <carl-johan.thore@liu.se>; petsc-users@mcs.anl.gov<br>
<b>Subject:</b> Re: [petsc-users] KSP on GPU<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Sun, Oct 30, 2022 at 3:52 PM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<o:p></o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal"> In general you should expect similar but not identical conference behavior. <o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> I suggest running with all the monitoring you can. -ksp_monitor_true_residual -fieldsplit_0_monitor_true_residual -fieldsplit_1_monitor_true_residual and compare the various convergence between the CPU and GPU. Also run with -ksp_view
and check that the various solver options are the same (they should be).<o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Is the GPU using float or double?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> Matt<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal"> Barry<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Oct 30, 2022, at 11:02 AM, Carl-Johan Thore via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">Hi,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I'm solving a topology optimization problem with Stokes flow discretized by a stabilized Q1-Q0 finite element method<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">and using BiCGStab with the fieldsplit preconditioner to solve the linear systems. The implementation<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">is based on DMStag, runs on Ubuntu via WSL2, and works fine with PETSc-3.18.1 on multiple CPU cores and the following<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">options for the preconditioner:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-fieldsplit_0_ksp_type preonly \<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-fieldsplit_0_pc_type gamg \<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-fieldsplit_0_pc_gamg_reuse_interpolation 0 \<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-fieldsplit_1_ksp_type preonly \<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-fieldsplit_1_pc_type jacobi <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">However, when I enable GPU computations by adding two options -<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-dm_vec_type cuda \<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-dm_mat_type aijcusparse \<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-fieldsplit_0_ksp_type preonly \<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-fieldsplit_0_pc_type gamg \<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-fieldsplit_0_pc_gamg_reuse_interpolation 0 \<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-fieldsplit_1_ksp_type preonly \<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-fieldsplit_1_pc_type jacobi <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">- KSP still works fine the first couple of topology optimization iterations but then<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">stops with "Linear solve did not converge due to DIVERGED_DTOL ..".<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">My question is whether I should expect the GPU versions of the linear solvers and pre-conditioners<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">to function exactly as their CPU counterparts (I got this impression from the documentation),<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">in which case I've probably made some mistake in my own code, or whether there are other/additional<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">settings or modifications I should use to run on the GPU (an NVIDIA Quadro T2000)?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span lang="SV">Kind regards,</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span lang="SV"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><span lang="SV">Carl-Johan</span><o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">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<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="https://eur01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.cse.buffalo.edu%2F~knepley%2F&data=05%7C01%7Ccarl-johan.thore%40liu.se%7C8113f968516a44cce6ba08dabab9b28e%7C913f18ec7f264c5fa816784fe9a58edd%7C0%7C0%7C638027603971893036%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gQ45cdsgo404NeBzZ7e6c5zNXhYOy39ZPfZzqtGDaDk%3D&reserved=0" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>