<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Barry,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
I tried again today on Perlmutter and running on multiple GPU nodes worked. Likely, I had messed up something the other day. Also, I was able to have multiple MPI tasks on a GPU using Nvidia MPS. The petsc output shows the number of MPI tasks:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
KSP Object: 32 MPI processes<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
Can petsc show the number of GPUs used?</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
Thanks,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
Cho<br>
</div>
<div id="appendonsend"></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size: 11pt; color: rgb(0, 0, 0);"><b>From:</b> Barry Smith <bsmith@petsc.dev><br>
<b>Sent:</b> Wednesday, August 9, 2023 4:09 PM<br>
<b>To:</b> Ng, Cho-Kuen <cho@slac.stanford.edu><br>
<b>Cc:</b> petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Subject:</b> Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div style="line-break:after-white-space">
<div><br>
</div>
We would need more information about "hanging". Do PETSc examples and tiny problems "hang" on multiple nodes? If you run with -info what are the last messages printed? Can you run with a debugger to see where it is "hanging"?
<div><br>
</div>
<div><br>
<div><br>
<blockquote type="cite">
<div>On Aug 9, 2023, at 5:59 PM, Ng, Cho-Kuen <cho@slac.stanford.edu> wrote:</div>
<br class="x_Apple-interchange-newline">
<div>
<div class="x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Barry and Matt,</div>
<div class="x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Thanks for your help. Now I can use petsc GPU backend on Perlmutter: 1 node, 4 MPI tasks and 4 GPUs. However, I ran into problems with multiple nodes: 2 nodes, 8 MPI tasks and 8 GPUs. The run hung on KSPSolve. How can I fix this?</div>
<div class="x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Best,</div>
<div class="x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Cho<br>
</div>
<div id="x_appendonsend" 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 tabindex="-1" 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:934.90625px">
<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!important"></span>
<div id="x_divRplyFwdMsg" 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 face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" id="OWA65880423-3319-3abc-7b68-035ed2684e8a" class="OWAAutoLink" data-loopstyle="linkonly">bsmith@petsc.dev</a>><br>
<b>Sent:</b><span class="x_Apple-converted-space"> </span>Monday, July 17, 2023 6:58 AM<br>
<b>To:</b><span class="x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAc6ca8f0b-d015-46ea-795b-c308298fb287" class="OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Cc:</b><span class="x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWA23197170-9687-f507-8dda-3f194dc4f96e" class="OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWA72205c82-1689-6fe8-4c63-48e2f8ddeecc" class="OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</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; line-break:after-white-space">
<div><br>
</div>
The examples that use DM, in particular DMDA all trivially support using the GPU with -dm_mat_type aijcusparse -dm_vec_type cuda
<div><br>
</div>
<div><br>
<div><br>
<blockquote type="cite">
<div>On Jul 17, 2023, at 1:45 AM, Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAffa344e5-f1a3-0808-8e96-f786314d449a" class="OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>> wrote:</div>
<br class="x_x_Apple-interchange-newline">
<div>
<div class="x_x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Barry,</div>
<div class="x_x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Thank you so much for the clarification.<span class="x_x_Apple-converted-space"> </span><br>
</div>
<div class="x_x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_x_elementToProof x_x_ContentPasted0" 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">
I see that ex104.c and ex300.c use MatXAIJSetPreallocation(). Are there other tutorials available?</div>
<div class="x_x_elementToProof x_x_ContentPasted0" 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 class="x_x_elementToProof x_x_ContentPasted0" 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">
Cho<br>
</div>
<div id="x_x_appendonsend" 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>
<hr tabindex="-1" 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:934.90625px">
<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!important"></span>
<div id="x_x_divRplyFwdMsg" 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 face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" id="OWAaf03f0fb-ad77-b952-d839-ca92b0898076" class="x_OWAAutoLink" data-loopstyle="linkonly">bsmith@petsc.dev</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Saturday, July 15, 2023 8:36 AM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAbd38134e-462b-1383-b530-8912013a1374" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWAbfa4dec3-3b5d-8aa1-4074-a0a462a74eae" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWA02670bf4-7e80-eae1-c22c-bb05ccecdc80" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</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; line-break:after-white-space">
<div><br>
</div>
<div> Cho,</div>
<div><br>
</div>
<div> We currently have a crappy API for turning on GPU support, and our documentation is misleading in places. </div>
<div><br>
</div>
<div> People constantly say "to use GPU's with PETSc you only need to use -mat_type aijcusparse (for example)" This is incorrect.</div>
<div><br>
</div>
<div> This does not work with code that uses the convenience Mat constructors such as MatCreateAIJ(), MatCreateAIJWithArrays etc. It only works if you use the constructor approach of MatCreate(), MatSetSizes(), MatSetFromOptions(), MatXXXSetPreallocation().
... Similarly you need to use VecCreate(), VecSetSizes(), VecSetFromOptions() and -vec_type cuda</div>
<div><br>
</div>
<div> If you use DM to create the matrices and vectors then you can use <span style="font-variant-ligatures:no-common-ligatures">-</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 36, 25);"><b>dm_mat_type aijcusparse</b></span><span style="font-variant-ligatures:no-common-ligatures"><span class="x_x_Apple-converted-space"> </span>-dm_vec_type
cuda</span></div>
<div><br>
</div>
<div> Sorry for the confusion.</div>
<div><br>
</div>
<div> Barry</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div><br>
<blockquote type="cite">
<div>On Jul 15, 2023, at 8:03 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" id="OWA84478fb6-4168-0592-400e-0c9edaa76e0e" class="x_OWAAutoLink" data-loopstyle="linkonly">knepley@gmail.com</a>> wrote:</div>
<br class="x_x_x_Apple-interchange-newline">
<div>
<div dir="ltr">
<div dir="ltr">On Sat, Jul 15, 2023 at 1:44 AM Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAa6bf2122-9894-7488-5195-2d443291cddc" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>> wrote:<br>
</div>
<div class="x_x_x_gmail_quote">
<blockquote class="x_x_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 class="x_x_x_msg2927322207553750716">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Matt,</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">After inserting 2 lines in the code:</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"> ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); <span class="x_x_Apple-converted-space"> </span><br>
<div> ierr = MatSetFromOptions(A);CHKERRQ(ierr);</div>
<div> ierr = MatCreateAIJ(PETSC_COMM_WORLD,mlocal,mlocal,m,n,</div>
<div> d_nz,PETSC_NULL,o_nz,PETSC_NULL,&A);;CHKERRQ(ierr);</div>
<div><br>
</div>
<div>"There are no unused options." However, there is no improvement on the GPU performance.</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>1. MatCreateAIJ() sets the type, and in fact it overwrites the Mat you created in steps 1 and 2. This is detailed in the manual.</div>
<div><br>
</div>
<div>2. You should replace MatCreateAIJ(), with MatSetSizes() before MatSetFromOptions().</div>
<div><br>
</div>
<div> THanks,</div>
<div><br>
</div>
<div> Matt</div>
<div> </div>
<blockquote class="x_x_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 class="x_x_x_msg2927322207553750716">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<div>Thanks,</div>
<div>Cho<br>
</div>
</div>
<div id="x_x_x_m_2927322207553750716appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt"><br>
</div>
<hr style="display:inline-block; width:907.546875px">
<div id="x_x_x_m_2927322207553750716divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com" id="OWA1fead60e-e1ca-e0dc-0e0e-0dc8b30bd6e6" class="x_OWAAutoLink" data-loopstyle="linkonly">knepley@gmail.com</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Friday, July 14, 2023 5:57 PM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWA43d3e458-0d93-ace9-d118-5d03880322b6" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" id="OWAfba1a4b5-e802-6882-cc87-5a628587b06c" class="x_OWAAutoLink" data-loopstyle="linkonly">bsmith@petsc.dev</a>>; Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWAfb8ecf62-7b45-633e-c2da-74a985fc8898" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>>;<span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWAe4f42722-74c6-3dc1-ce86-966c20e7dfb1" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWAfd698a50-134f-685b-645b-63f1ba09cc6c" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Fri, Jul 14, 2023 at 7:57 PM Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAd9616d69-8df3-d25e-4fe2-b8806d772b50" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>> wrote:<br>
</div>
<div>
<blockquote 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 style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">I managed to pass the following options to PETSc using a GPU node on Perlmutter.</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"> -mat_type aijcusparse -vec_type cuda -log_view -options_left</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">Below is a summary of the test using 4 MPI tasks and 1 GPU per task.</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">o #PETSc Option Table entries:
<div><span> </span>-log_view</div>
<div><span> </span>-mat_type aijcusparse</div>
<div> -options_left</div>
<div> -vec_type cuda</div>
<div> #End of PETSc Option Table entries</div>
<div> WARNING! There are options you set that were not used!</div>
<div> WARNING! could be spelling mistake, etc!</div>
<div> There is one unused database option. It is:</div>
<div> Option left: name:-mat_type value: aijcusparse</div>
<div><br>
</div>
<div>The -mat_type option has not been used. In the application code, we use</div>
<div><br>
</div>
<div> ierr = MatCreateAIJ(PETSC_COMM_WORLD,mlocal,mlocal,m,n,
<div> d_nz,PETSC_NULL,o_nz,PETSC_NULL,&A);;CHKERRQ(ierr);</div>
</div>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt"><br>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>If you create the Mat this way, then you need MatSetFromOptions() in order to set the type from the command line.</div>
<div><br>
</div>
<div> Thanks,</div>
<div><br>
</div>
<div> Matt</div>
<div> </div>
<blockquote 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 style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">o The percent flops on the GPU for KSPSolve is 17%.</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">In comparison with a CPU run using 16 MPI tasks, the GPU run is an order of magnitude slower. How can I improve the GPU performance?</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">Thanks,</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Cho<br>
</div>
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556appendonsend"></div>
<hr style="display:inline-block; width:889.984375px">
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAd615ef54-6691-57af-b867-7db24f044885" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Friday, June 30, 2023 7:57 AM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" id="OWA17ac07b3-8636-7736-e71b-a1f7052c4d78" class="x_OWAAutoLink" data-loopstyle="linkonly">bsmith@petsc.dev</a>>; Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWA95d7f21f-717f-8605-5867-25cb15fe4b99" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com" id="OWA115d97d5-57c8-74bd-0e28-70608855e115" class="x_OWAAutoLink" data-loopstyle="linkonly">knepley@gmail.com</a>>;<span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWA6b5c0218-60ea-0b8f-e606-5c6c17b93564" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWAc5e71d0b-5b64-ff11-7967-17b181628bb5" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Barry, Mark and Matt,</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">Thank you all for the suggestions. I will modify the code so we can pass runtime options.</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">Cho<br>
</div>
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_appendonsend"></div>
<hr style="display:inline-block; width:889.984375px">
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" id="OWA339c8864-e990-9364-dbd2-cafdcc2281ca" class="x_OWAAutoLink" data-loopstyle="linkonly">bsmith@petsc.dev</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Friday, June 30, 2023 7:01 AM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWA0acc0d5f-c702-a9e0-50d4-9045bac985f6" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com" id="OWA052dfb6f-df7d-8db9-d241-5a2d82544e2b" class="x_OWAAutoLink" data-loopstyle="linkonly">knepley@gmail.com</a>>; Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAa46c1df5-0d6d-64a5-edd9-866d0ae09b16" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>>;<span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWAa68d8315-7e36-6c48-64b0-139cdaef59b5" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWA0cec6a3f-f94c-d75e-5922-0827c569fdd8" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div>
<div><br>
</div>
Note that options like -mat_type aijcusparse -vec_type cuda only work if the program is set up to allow runtime swapping of matrix and vector types. If you have a call to MatCreateMPIAIJ() or other specific types then then these options do nothing but because
Mark had you use -options_left the program will tell you at the end that it did not use the option so you will know.
<div><br>
<blockquote type="cite">
<div>On Jun 30, 2023, at 9:30 AM, Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWA60ec1c3d-cc6c-7742-bd0c-355e48c2e5c3" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>> wrote:</div>
<br>
<div>
<div dir="ltr">PetscCall(PetscInitialize(&argc, &argv, NULL, help)); gives us the args and you run:<br>
<div><br>
</div>
<div>a.out -mat_type aijcusparse -vec_type cuda -log_view -options_left</div>
<div><br>
</div>
<div>Mark</div>
</div>
<br>
<div>
<div dir="ltr">On Fri, Jun 30, 2023 at 6:16 AM Matthew Knepley <<a href="mailto:knepley@gmail.com" id="OWA5ebe868b-66c3-1d75-1586-b209d9fdedb4" class="x_OWAAutoLink" data-loopstyle="linkonly">knepley@gmail.com</a>> wrote:<br>
</div>
<blockquote 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 dir="ltr">On Fri, Jun 30, 2023 at 1:13 AM Ng, Cho-Kuen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" id="OWA08dc57d7-a492-f90b-6644-2597b6770f3a" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<div>
<blockquote 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 style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Mark,</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">The application code reads in parameters from an input file, where we can put the PETSc runtime options. Then we pass the options to PetscInitialize(...). Does that sounds right?</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>PETSc will read command line argument automatically in PetscInitialize() unless you shut it off.</div>
<div><br>
</div>
<div> Thanks,</div>
<div><br>
</div>
<div> Matt</div>
<div> </div>
<blockquote 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 style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Cho<br>
</div>
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_x_m_-2363626647532502450m_5514417947815199577appendonsend">
</div>
<hr style="display:inline-block; width:845.0625px">
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_x_m_-2363626647532502450m_5514417947815199577divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAc8d201e0-34f9-97c2-8738-9ec1b50187f4" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Thursday, June 29, 2023 8:32 PM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWA0a49d407-744d-0881-4c97-8d4df50fbff2" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWA6f08c63d-2c79-e0eb-5ad0-109e492f4b07" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWA0c6cde14-339b-4e48-c334-0c1b87e578af" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Mark,</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">Thanks for the information. How do I put the runtime options for the executable, say, a.out, which does not have the provision to append arguments? Do I need to change the C++ main to read
in the options?</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">Cho<br>
</div>
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_x_m_-2363626647532502450m_5514417947815199577x_appendonsend">
</div>
<hr style="display:inline-block; width:845.0625px">
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_x_m_-2363626647532502450m_5514417947815199577x_divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWA76a0c45e-af50-c736-7da1-84fe15a9e4fa" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Thursday, June 29, 2023 5:55 PM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAff0f822b-1aab-0837-6300-54e1d1df9cb8" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWA9673ed61-dc1d-ece2-1fb5-2cd9a0a8cd38" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWA88667eb0-bbdb-b5e4-e556-15edf689747e" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div>
<div dir="ltr">Run with options: -mat_type aijcusparse -vec_type cuda -log_view -options_left
<div><br>
</div>
<div>The last column of the performance data (from -log_view) will be the percent flops on the GPU. Check that that is > 0.</div>
<div><br>
</div>
<div>The end of the output will list the options that were used and options that were _not_ used (if any). Check that there are no options left.</div>
<div><br>
</div>
<div>Mark</div>
</div>
<br>
<div>
<div dir="ltr">On Thu, Jun 29, 2023 at 7:50 PM Ng, Cho-Kuen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" id="OWA6e357c45-a7c8-592a-6ba6-8f3c759b7073" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<blockquote 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 style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">I installed PETSc on Perlmutter using "spack install<span class="x_x_Apple-converted-space"> </span><span style="background: rgb(255, 255, 255);">petsc+cuda+zoltan</span><span style="background-color: rgb(255, 255, 255);">"<span class="x_x_Apple-converted-space"> </span></span>and
used it by "<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; background: rgb(255, 255, 255);">spack load petsc/fwge6pf</span>". Then I compiled the application code (purely CPU code) linking to the petsc package, hoping that I can get
performance improvement using the petsc GPU backend. However, the timing was the same using the same number of MPI tasks with and without GPU accelerators. Have I missed something in the process, for example, setting up PETSc options at runtime to use the
GPU backend?</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">Thanks,</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Cho<br>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
<span>--<span class="x_x_Apple-converted-space"> </span></span><br>
<div dir="ltr">
<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/" data-auth="NotApplicable" id="OWA5aa7594b-4379-5cf2-afb8-e701c34c7f13" class="x_OWAAutoLink" data-loopstyle="linkonly">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
<span>--<span class="x_x_Apple-converted-space"> </span></span><br>
<div dir="ltr">
<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/" data-auth="NotApplicable" id="OWA122834f1-3b66-8d00-6135-2233006f0c78" class="x_OWAAutoLink" data-loopstyle="linkonly">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
<span class="x_x_x_gmail_signature_prefix">--<span class="x_x_Apple-converted-space"> </span></span><br>
<div dir="ltr" class="x_x_x_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/" data-auth="NotApplicable" id="OWA7302555a-c36c-e199-5778-c6b587432330" class="x_OWAAutoLink" data-loopstyle="linkonly">https://www.cse.buffalo.edu/~knepley/</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
<div id="x_appendonsend" 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 tabindex="-1" 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:934.90625px">
<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!important"></span>
<div id="x_divRplyFwdMsg" 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 face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" id="OWA8f0ed789-92ef-1e31-aa1c-ca7d928feb14" class="OWAAutoLink" data-loopstyle="linkonly">bsmith@petsc.dev</a>><br>
<b>Sent:</b><span class="x_Apple-converted-space"> </span>Monday, July 17, 2023 6:58 AM<br>
<b>To:</b><span class="x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWA9da9d20d-385d-8e0b-2c70-949e075d4be2" class="OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Cc:</b><span class="x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWA919e7200-6b78-dbe4-d82e-b826ab32564a" class="OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWA0bf1955d-a7ee-1635-c69a-8ff1bdb3e0b1" class="OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</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; line-break:after-white-space">
<div><br>
</div>
The examples that use DM, in particular DMDA all trivially support using the GPU with -dm_mat_type aijcusparse -dm_vec_type cuda
<div><br>
</div>
<div><br>
<div><br>
<blockquote type="cite">
<div>On Jul 17, 2023, at 1:45 AM, Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWA1329cb35-5b7d-3438-60b0-c0eacf970255" class="OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>> wrote:</div>
<br class="x_x_Apple-interchange-newline">
<div>
<div class="x_x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Barry,</div>
<div class="x_x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
Thank you so much for the clarification.<span class="x_x_Apple-converted-space"> </span><br>
</div>
<div class="x_x_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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<br>
</div>
<div class="x_x_elementToProof x_x_ContentPasted0" 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">
I see that ex104.c and ex300.c use MatXAIJSetPreallocation(). Are there other tutorials available?</div>
<div class="x_x_elementToProof x_x_ContentPasted0" 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 class="x_x_elementToProof x_x_ContentPasted0" 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">
Cho<br>
</div>
<div id="x_x_appendonsend" 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>
<hr tabindex="-1" 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:934.90625px">
<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!important"></span>
<div id="x_x_divRplyFwdMsg" 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 face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" id="OWAfbb290bd-51be-4c06-d767-17e9b71aa7ec" class="x_OWAAutoLink" data-loopstyle="linkonly">bsmith@petsc.dev</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Saturday, July 15, 2023 8:36 AM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWA6bd9d64e-ec12-0649-77a4-2abfdbbcab39" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWA2ea198ea-81a8-b826-8bc0-01f149571ed8" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWAbe4f0e1a-8c6d-5450-fe41-a1acc5a63752" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</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; line-break:after-white-space">
<div><br>
</div>
<div> Cho,</div>
<div><br>
</div>
<div> We currently have a crappy API for turning on GPU support, and our documentation is misleading in places. </div>
<div><br>
</div>
<div> People constantly say "to use GPU's with PETSc you only need to use -mat_type aijcusparse (for example)" This is incorrect.</div>
<div><br>
</div>
<div> This does not work with code that uses the convenience Mat constructors such as MatCreateAIJ(), MatCreateAIJWithArrays etc. It only works if you use the constructor approach of MatCreate(), MatSetSizes(), MatSetFromOptions(), MatXXXSetPreallocation().
... Similarly you need to use VecCreate(), VecSetSizes(), VecSetFromOptions() and -vec_type cuda</div>
<div><br>
</div>
<div> If you use DM to create the matrices and vectors then you can use <span style="font-variant-ligatures:no-common-ligatures">-</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(180, 36, 25);"><b>dm_mat_type aijcusparse</b></span><span style="font-variant-ligatures:no-common-ligatures"><span class="x_x_Apple-converted-space"> </span>-dm_vec_type
cuda</span></div>
<div><br>
</div>
<div> Sorry for the confusion.</div>
<div><br>
</div>
<div> Barry</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
<div><br>
<blockquote type="cite">
<div>On Jul 15, 2023, at 8:03 AM, Matthew Knepley <<a href="mailto:knepley@gmail.com" id="OWAd0ac30fb-094a-9792-c5be-820ce917841e" class="x_OWAAutoLink" data-loopstyle="linkonly">knepley@gmail.com</a>> wrote:</div>
<br class="x_x_x_Apple-interchange-newline">
<div>
<div dir="ltr">
<div dir="ltr">On Sat, Jul 15, 2023 at 1:44 AM Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAc5c43cc4-1f77-c03b-3142-b4ca6cf63ce5" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>> wrote:<br>
</div>
<div class="x_x_x_gmail_quote">
<blockquote class="x_x_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 class="x_x_x_msg2927322207553750716">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Matt,</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">After inserting 2 lines in the code:</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"> ierr = MatCreate(PETSC_COMM_WORLD,&A);CHKERRQ(ierr); <span class="x_x_Apple-converted-space"> </span><br>
<div> ierr = MatSetFromOptions(A);CHKERRQ(ierr);</div>
<div> ierr = MatCreateAIJ(PETSC_COMM_WORLD,mlocal,mlocal,m,n,</div>
<div> d_nz,PETSC_NULL,o_nz,PETSC_NULL,&A);;CHKERRQ(ierr);</div>
<div><br>
</div>
<div>"There are no unused options." However, there is no improvement on the GPU performance.</div>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>1. MatCreateAIJ() sets the type, and in fact it overwrites the Mat you created in steps 1 and 2. This is detailed in the manual.</div>
<div><br>
</div>
<div>2. You should replace MatCreateAIJ(), with MatSetSizes() before MatSetFromOptions().</div>
<div><br>
</div>
<div> THanks,</div>
<div><br>
</div>
<div> Matt</div>
<div> </div>
<blockquote class="x_x_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 class="x_x_x_msg2927322207553750716">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
<div>Thanks,</div>
<div>Cho<br>
</div>
</div>
<div id="x_x_x_m_2927322207553750716appendonsend"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt"><br>
</div>
<hr style="display:inline-block; width:907.546875px">
<div id="x_x_x_m_2927322207553750716divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com" id="OWA7b347126-cb02-a29b-f99c-a66939044050" class="x_OWAAutoLink" data-loopstyle="linkonly">knepley@gmail.com</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Friday, July 14, 2023 5:57 PM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWA92347dc3-e333-d73d-f853-2242431675fa" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" id="OWA905f9a03-1c98-75c9-a307-e8585ad67fad" class="x_OWAAutoLink" data-loopstyle="linkonly">bsmith@petsc.dev</a>>; Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWA54f089ea-fab3-1ad6-27b9-ba2b5ca5b766" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>>;<span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWA7f95a127-a197-5e55-fd9b-624c004678ce" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWA4033f262-af91-8b93-651e-d2416ef3346b" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Fri, Jul 14, 2023 at 7:57 PM Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWA0a382f5c-cfe7-e881-2295-0ae3a776c4fa" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>> wrote:<br>
</div>
<div>
<blockquote 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 style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">I managed to pass the following options to PETSc using a GPU node on Perlmutter.</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"> -mat_type aijcusparse -vec_type cuda -log_view -options_left</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">Below is a summary of the test using 4 MPI tasks and 1 GPU per task.</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">o #PETSc Option Table entries:
<div><span> </span>-log_view</div>
<div><span> </span>-mat_type aijcusparse</div>
<div> -options_left</div>
<div> -vec_type cuda</div>
<div> #End of PETSc Option Table entries</div>
<div> WARNING! There are options you set that were not used!</div>
<div> WARNING! could be spelling mistake, etc!</div>
<div> There is one unused database option. It is:</div>
<div> Option left: name:-mat_type value: aijcusparse</div>
<div><br>
</div>
<div>The -mat_type option has not been used. In the application code, we use</div>
<div><br>
</div>
<div> ierr = MatCreateAIJ(PETSC_COMM_WORLD,mlocal,mlocal,m,n,
<div> d_nz,PETSC_NULL,o_nz,PETSC_NULL,&A);;CHKERRQ(ierr);</div>
</div>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt"><br>
</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>If you create the Mat this way, then you need MatSetFromOptions() in order to set the type from the command line.</div>
<div><br>
</div>
<div> Thanks,</div>
<div><br>
</div>
<div> Matt</div>
<div> </div>
<blockquote 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 style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt"></div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">o The percent flops on the GPU for KSPSolve is 17%.</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">In comparison with a CPU run using 16 MPI tasks, the GPU run is an order of magnitude slower. How can I improve the GPU performance?</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">Thanks,</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Cho<br>
</div>
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556appendonsend"></div>
<hr style="display:inline-block; width:889.984375px">
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWA88979936-307c-cd8e-03cb-e2a9a8f18230" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Friday, June 30, 2023 7:57 AM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" id="OWA2381847a-3e1f-fdb2-59ff-391d1167d602" class="x_OWAAutoLink" data-loopstyle="linkonly">bsmith@petsc.dev</a>>; Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWAb1d18e59-380c-d42f-2672-e524cc3a561d" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com" id="OWA42881da5-319e-936e-3ed9-e236321c9bfa" class="x_OWAAutoLink" data-loopstyle="linkonly">knepley@gmail.com</a>>;<span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWA088c6acf-10c6-1bfc-94bc-554856fca1b8" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWA557889dd-778d-6015-da29-fbc3e4a178d4" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Barry, Mark and Matt,</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">Thank you all for the suggestions. I will modify the code so we can pass runtime options.</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">Cho<br>
</div>
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_appendonsend"></div>
<hr style="display:inline-block; width:889.984375px">
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" id="OWAe5075272-bc4e-0479-4efb-50b07944b0a5" class="x_OWAAutoLink" data-loopstyle="linkonly">bsmith@petsc.dev</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Friday, June 30, 2023 7:01 AM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWA77a146f4-03b5-4fde-9d41-82878e40a2c7" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com" id="OWA9602ab08-23fd-838f-4a8a-d2af64974aec" class="x_OWAAutoLink" data-loopstyle="linkonly">knepley@gmail.com</a>>; Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWA0b437e8d-f65d-062f-bb8b-59a4d8e3807d" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>>;<span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWAa39194a2-b13e-e7cc-20cb-9c729ed7afd1" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWA62bd62c3-7fb6-08b8-1495-2e49c04ca0b2" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div>
<div><br>
</div>
Note that options like -mat_type aijcusparse -vec_type cuda only work if the program is set up to allow runtime swapping of matrix and vector types. If you have a call to MatCreateMPIAIJ() or other specific types then then these options do nothing but because
Mark had you use -options_left the program will tell you at the end that it did not use the option so you will know.
<div><br>
<blockquote type="cite">
<div>On Jun 30, 2023, at 9:30 AM, Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWAbeaab997-7cbe-c13e-81c4-daa8f9c8af06" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>> wrote:</div>
<br>
<div>
<div dir="ltr">PetscCall(PetscInitialize(&argc, &argv, NULL, help)); gives us the args and you run:<br>
<div><br>
</div>
<div>a.out -mat_type aijcusparse -vec_type cuda -log_view -options_left</div>
<div><br>
</div>
<div>Mark</div>
</div>
<br>
<div>
<div dir="ltr">On Fri, Jun 30, 2023 at 6:16 AM Matthew Knepley <<a href="mailto:knepley@gmail.com" id="OWAc4b37134-2245-c94b-516e-bbbf45269800" class="x_OWAAutoLink" data-loopstyle="linkonly">knepley@gmail.com</a>> wrote:<br>
</div>
<blockquote 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 dir="ltr">On Fri, Jun 30, 2023 at 1:13 AM Ng, Cho-Kuen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" id="OWA2911832f-99a0-5ef2-b459-825723ab31c7" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<div>
<blockquote 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 style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Mark,</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">The application code reads in parameters from an input file, where we can put the PETSc runtime options. Then we pass the options to PetscInitialize(...). Does that sounds right?</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>PETSc will read command line argument automatically in PetscInitialize() unless you shut it off.</div>
<div><br>
</div>
<div> Thanks,</div>
<div><br>
</div>
<div> Matt</div>
<div> </div>
<blockquote 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 style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Cho<br>
</div>
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_x_m_-2363626647532502450m_5514417947815199577appendonsend">
</div>
<hr style="display:inline-block; width:845.0625px">
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_x_m_-2363626647532502450m_5514417947815199577divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWA09dc23b9-07d7-1115-147a-d26c93392e39" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Thursday, June 29, 2023 8:32 PM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWAfc4998f5-c219-bcca-5b7a-f805c61c7889" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWAa6aaf0c9-8d69-69a8-8ef5-da21272b7652" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWA3e2b4dcc-c6e7-e7b2-17e9-93b772e14fac" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Mark,</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">Thanks for the information. How do I put the runtime options for the executable, say, a.out, which does not have the provision to append arguments? Do I need to change the C++ main to read
in the options?</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">Cho<br>
</div>
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_x_m_-2363626647532502450m_5514417947815199577x_appendonsend">
</div>
<hr style="display:inline-block; width:845.0625px">
<div id="x_x_x_m_2927322207553750716x_m_-8026140834471843556x_x_m_-2363626647532502450m_5514417947815199577x_divRplyFwdMsg" dir="ltr">
<font face="Calibri, sans-serif" style="font-size:11pt"><b>From:</b><span class="x_x_Apple-converted-space"> </span>Mark Adams <<a href="mailto:mfadams@lbl.gov" id="OWA45a68f16-48ad-22b4-97d2-3f29b8b35b84" class="x_OWAAutoLink" data-loopstyle="linkonly">mfadams@lbl.gov</a>><br>
<b>Sent:</b><span class="x_x_Apple-converted-space"> </span>Thursday, June 29, 2023 5:55 PM<br>
<b>To:</b><span class="x_x_Apple-converted-space"> </span>Ng, Cho-Kuen <<a href="mailto:cho@slac.stanford.edu" id="OWAe4804992-e3d7-b009-4e2b-37a42da63dea" class="x_OWAAutoLink" data-loopstyle="linkonly">cho@slac.stanford.edu</a>><br>
<b>Cc:</b><span class="x_x_Apple-converted-space"> </span><a href="mailto:petsc-users@mcs.anl.gov" id="OWA2f254220-28d1-eff5-8fcd-dbcc1942d940" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a><span class="x_x_Apple-converted-space"> </span><<a href="mailto:petsc-users@mcs.anl.gov" id="OWAfc098099-4eef-22bc-9d97-264ea7487324" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="x_x_Apple-converted-space"> </span>Re: [petsc-users] Using PETSc GPU backend</font>
<div> </div>
</div>
<div>
<div dir="ltr">Run with options: -mat_type aijcusparse -vec_type cuda -log_view -options_left
<div><br>
</div>
<div>The last column of the performance data (from -log_view) will be the percent flops on the GPU. Check that that is > 0.</div>
<div><br>
</div>
<div>The end of the output will list the options that were used and options that were _not_ used (if any). Check that there are no options left.</div>
<div><br>
</div>
<div>Mark</div>
</div>
<br>
<div>
<div dir="ltr">On Thu, Jun 29, 2023 at 7:50 PM Ng, Cho-Kuen via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" id="OWA7b917b08-907a-7c2f-d019-071faf236e4a" class="x_OWAAutoLink" data-loopstyle="linkonly">petsc-users@mcs.anl.gov</a>> wrote:<br>
</div>
<blockquote 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 style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">I installed PETSc on Perlmutter using "spack install<span class="x_x_Apple-converted-space"> </span><span style="background: rgb(255, 255, 255);">petsc+cuda+zoltan</span><span style="background-color: rgb(255, 255, 255);">"<span class="x_x_Apple-converted-space"> </span></span>and
used it by "<span style="font-family: Arial, Helvetica, sans-serif; font-size: 12pt; background: rgb(255, 255, 255);">spack load petsc/fwge6pf</span>". Then I compiled the application code (purely CPU code) linking to the petsc package, hoping that I can get
performance improvement using the petsc GPU backend. However, the timing was the same using the same number of MPI tasks with and without GPU accelerators. Have I missed something in the process, for example, setting up PETSc options at runtime to use the
GPU backend?</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">Thanks,</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt">Cho<br>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
<span>--<span class="x_x_Apple-converted-space"> </span></span><br>
<div dir="ltr">
<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/" data-auth="NotApplicable" id="OWA3c72b2d1-63bb-78be-2393-1bfb7703f5b4" class="x_OWAAutoLink" data-loopstyle="linkonly">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
<span>--<span class="x_x_Apple-converted-space"> </span></span><br>
<div dir="ltr">
<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/" data-auth="NotApplicable" id="OWA8952c241-3cac-14c2-2008-e9fad4be4ff3" class="x_OWAAutoLink" data-loopstyle="linkonly">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
<span class="x_x_x_gmail_signature_prefix">--<span class="x_x_Apple-converted-space"> </span></span><br>
<div dir="ltr" class="x_x_x_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/" data-auth="NotApplicable" id="OWAc7414f9c-f648-f2a3-3b40-6c3ec935812e" class="x_OWAAutoLink" data-loopstyle="linkonly">https://www.cse.buffalo.edu/~knepley/</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</body>
</html>