<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 9, 2020 at 7:11 PM GIBB Gordon <<a href="mailto:g.gibb@epcc.ed.ac.uk">g.gibb@epcc.ed.ac.uk</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="overflow-wrap: break-word;">
Hi,
<div><br>
</div>
<div>First of all, my apologies if this is not the appropriate list to send these questions to.</div>
<div><br>
</div>
<div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
I’m one of the developers of TPLS (<a href="https://sourceforge.net/projects/tpls/" target="_blank"><span style="color:rgb(255,204,19)">https://sourceforge.net/projects/tpls/</span></a>), a Fortran code that uses PETSc, parallelised using DM vectors.
It uses a mix of our own solvers, and PETSc’s Krylov solvers. At present it has been run on up to 25,000 MPI processes, although larger problem sizes should be able to scale beyond that.</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue";min-height:14px">
<br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
With the awareness that more and more HPC machines now have one or more GPUs per node, and that upcoming machines that approach/achieve Exascale will be heterogeneous in nature, we are investigating whether it is worth using GPUs with TPLS, and if so, how to
best do this.</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue";min-height:14px">
<br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
I see that in principle all we’d need to do to is set some flags as described at <a href="https://www.mcs.anl.gov/petsc/features/gpus.html" target="_blank">
<span style="color:rgb(255,204,19)">https://www.mcs.anl.gov/petsc/features/gpus.html</span></a> to offload work onto the GPU, however I have some questions about doing this in practice:</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue";min-height:14px">
<br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
The GPU machine I have access to has nodes with two 20 core CPUs and 4 NVIDIA GPUs (so 10 cores per GPU). We could use CUDA or OpenCL, and may well explore both of them. With TPLS being an MPI application, we would wish to use many processes (and nodes), not
just a single process. How would we best split this problem up? </div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue";min-height:14px">
<br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
Would we have 1 MPI process per GPU (so 4 per node), and then implement our own solvers either to also work on the GPU, or use OpenMP to make use of the 10 cores per GPU? If so, how would we specify to PETSc which GPU each process would use? </div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue";min-height:14px">
<br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
Would we instead just have 40 (or perhaps slightly fewer) MPI processes all sharing the GPUs? Surely this would be inefficient, and would PETSc distribute the work across all 4 GPUs, or would every process end out using a single GPU?</div></div></div></blockquote><div>See <a href="https://docs.olcf.ornl.gov/systems/summit_user_guide.html#volta-multi-process-service">https://docs.olcf.ornl.gov/systems/summit_user_guide.html#volta-multi-process-service</a>. In some cases, we did see better performance with multiple mpi ranks/GPU than 1 rank/GPU. The optimal configuration depends on the code. Think two extremes: One code with work done all on GPU and the other all on CPU. Probably you only need 1 mpi rank/node for the former, but full ranks for the latter. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue";min-height:14px">
<br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
Would the Krylov solvers be blocking whilst the GPUs are in use running the solvers, or would the host code be able to continue and carry out other calculations whilst waiting for the GPU code to finish? We may need to modify our algorithm to allow for this,
but it would make sense to introduce some concurrency so that the CPUs aren’t idling whilst waiting for the GPUs to complete their work.</div></div></div></blockquote><div>We use asynchronous kernel launch and split-phase communication (VecScatterBegin/End). As long as there is no dependency, you can overlap computations on CPU and GPU, or computations with communications. </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue";min-height:14px">
<br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
Finally, I’m trying to get the OpenCL PETSc to work on my laptop (Macbook Pro with discrete AMD Radeon R9 M370X GPU). This is mostly because our GPU cluster is out of action until at least late June and I want to get a head start on experimenting with GPUs
and TPLS. When I try to run TPLS with the ViennaCL PETSc it reports that my GPU is unable to support double precision. I confirmed that my discrete GPU does support this, however my integrated GPU (Intel Iris) does not. I suspect that ViennaCL is using my
integrated GPU instead of my discrete one (it is listed as GPU 0 by OpenCL, with the AMD card is GPU 1). Is there any way of getting PETSc to report which OpenCL device is in use, or to select which device to use? I saw there was some discussion about this
on the mailing list archives but I couldn’t find any conclusion.</div></div></div></blockquote><div>No experience. Karl Rupp (cc'ed) might know.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue";min-height:14px">
<br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
Thanks in advance for your help,</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
<br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
Regards,</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue";min-height:14px">
<br>
</div>
<div style="margin:0px;font-stretch:normal;line-height:normal;font-family:"Helvetica Neue"">
Gordon</div>
</div>
<div><br>
</div>
<div>
<div>
<div style="overflow-wrap: break-word;">
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
-----------------------------------------------<br>
Dr Gordon P S Gibb<br>
EPCC, The University of Edinburgh</div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
Tel: +44 131 651 3459</div>
</div>
</div>
<br>
</div>
The University of Edinburgh is a charitable body, registered in Scotland, with registration number SC005336.
</div>
</blockquote></div></div>