<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">
Hi Junchao,</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 have managed to configure Petsc for GPU, also managed to run ksp/ex15 using -mat_type aijcusparse -vec_type cuda.  It seems runs much faster compared to the scenario if I don't use " -mat_type aijcusparse -vec_type cuda". so I believe it runs okay for GPUs.</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 have an existing CFD code that runs natively on GPUs. so all the data is offloaded to GPU at the beginning and some data are copied back to the cpu at the very end. It got a hand-coded Newton-Jacobi that runs in GPUs for the implicit solver. 
<b>My question is:  my code also has a GMRES+ILU(0) implemented with Petsc but it only runs on cpus (which I implemented a few years ago). How can I replace the existing Newton-Jacobi (which runs in GPUs) with GMRES+ILU(0) which should run in GPUs. Could you
 please give some advice?</b></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">
Thanks,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Feng</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr style="display: inline-block; width: 98%;">
<div id="divRplyFwdMsg">
<div style="direction: ltr; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<b>From:</b> Junchao Zhang <junchao.zhang@gmail.com><br>
<b>Sent:</b> 09 February 2026 23:18<br>
<b>To:</b> feng wang <snailsoar@hotmail.com><br>
<b>Cc:</b> petsc-users@mcs.anl.gov <petsc-users@mcs.anl.gov><br>
<b>Subject:</b> Re: [petsc-users] Port existing GMRES+ILU(0) implementation to GPU</div>
<div style="direction: ltr;"> </div>
</div>
<div style="direction: ltr;">Hi Feng,<br>
  At the first step, you don't need to change your CPU implementation.  Then do profiling to see where it is worth putting your effort.  Maybe you need to assemble your matrices and vectors on GPUs too, but decide that at a later stage. <br>
 </div>
<div style="direction: ltr;">  Thanks!</div>
<div style="direction: ltr;">--Junchao Zhang</div>
<div style="direction: ltr;"><br>
</div>
<div><br>
</div>
<div style="direction: ltr;">On Mon, Feb 9, 2026 at 4:31 PM feng wang <<a class="OWAAutoLink" id="OWAe390fc60-96cb-ebcc-fd45-7742ee2e3dec" href="mailto:snailsoar@hotmail.com">snailsoar@hotmail.com</a>> wrote:</div>
<blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left: 1px solid rgb(204, 204, 204);">
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Junchao,</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Many thanks for your reply.</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This is great!  Do I need to change anything for my current CPU implementation? or I just link to a version of Petsc that is configured with  cuda and make sure the necessary data are copied to the "device", then Petsc will do the rest magic for me?</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Feng</div>
<hr style="direction: ltr; display: inline-block; width: 98%;">
<div id="x_m_-6845830625879680973divRplyFwdMsg">
<div style="direction: ltr; font-family: Calibri, sans-serif; font-size: 11pt; color: rgb(0, 0, 0);">
<b>From:</b> Junchao Zhang <<a class="OWAAutoLink" id="OWA9554fddb-78d7-69c8-6fcb-57624941dac9" href="mailto:junchao.zhang@gmail.com">junchao.zhang@gmail.com</a>><br>
<b>Sent:</b> 09 February 2026 1:55<br>
<b>To:</b> feng wang <<a class="OWAAutoLink" id="OWA52c3fa9a-47d9-e9ba-7394-8801d9590804" href="mailto:snailsoar@hotmail.com">snailsoar@hotmail.com</a>><br>
<b>Cc:</b> <a class="OWAAutoLink" id="OWA39cd01ac-1268-655d-75ca-72a8eef84d08" href="mailto:petsc-users@mcs.anl.gov">
petsc-users@mcs.anl.gov</a> <<a class="OWAAutoLink" id="OWAb6289a58-9e52-2d6f-6c91-1eb3704340a9" href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> Re: [petsc-users] Port existing GMRES+ILU(0) implementation to GPU</div>
<div style="direction: ltr;"> </div>
</div>
<div style="direction: ltr;">Hello Feng,<br>
  It is possible to run GMRES with ILU(0) on GPUs.  You may need to configure PETSc with CUDA (--with-cuda --with-cudac=nvcc) or Kokkos (with extra --download-kokkos  --download-kokkos-kernels).  Then run with -mat_type {aijcusparse or aijkokkos}  -vec_type
 {cuda or kokkos}.<br>
  But triangular solve is not GPU friendly and the performance might be poor.  But you should try it, I think.    <br>
 <br>
Thanks!<br>
--Junchao Zhang</div>
<div style="direction: ltr;"><br>
</div>
<div style="direction: ltr;">On Sun, Feb 8, 2026 at 5:46 PM feng wang <<a class="OWAAutoLink" id="OWA99c52158-b7b5-0ebf-024c-1f173456565c" href="mailto:snailsoar@hotmail.com">snailsoar@hotmail.com</a>> wrote:</div>
<blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left: 1px solid rgb(204, 204, 204);">
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Dear All,</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I have an existing implementation of GMRES with ILU(0), it works well for cpu now. I went through the Petsc documentation, it seems Petsc has some support for GPUs. is it possible for me to run GMRES with ILU(0) in GPUs?</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Many thanks for your help in advance,</div>
<div style="direction: ltr; font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Feng</div>
</blockquote>
</blockquote>
</body>
</html>