<div dir="ltr"><div>Even ISCUDA is simple to add, the PetscSFSetUp algorithm and many functions involved are done on host (and are not simple to be parallelized on GPU)</div><div></div><div>The indices passed to VecScatter are analyzed and re-grouped. Even they are copied to device eventually, they are likely not in their original form. So, copying the indices from device to host and build a VecScatter there seems the easiest approach.</div><div><br></div><div>The Kokkos-related functions are experimental. We need to decide whether they are good or not.<br></div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><br></div><div dir="ltr">--Junchao Zhang</div></div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 19, 2021 at 4:32 AM Patrick Sanan <<a href="mailto:patrick.sanan@gmail.com">patrick.sanan@gmail.com</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;">Thanks! That helps a lot. <div><br></div><div><div>I assume "no," but is ISCUDA simple to add?</div><div><br></div><div>More on what I'm trying to do, in case I'm missing an obvious approach:</div><div><br></div><div>I'm working on a demo code that uses an external library, based on Kokkos, as a solver - I create a Vec of type KOKKOS and populate it with the solution data from the library, by getting access to the raw Kokkos view with VecKokkosGetDeviceView() * .</div><div><br></div><div>I then want to reorder that solution data into PETSc-native ordering (for a velocity-pressure DMStag), so I create a pair of ISs and a VecScatter to do that.</div><div><br></div><div>The issue is that to create this scatter, I need to use information (essentially, an element-to-index map) from the external library's mesh-management object, which lives on the device. This doesn't work (when host != device), because of course the ISs live on the host and to create them I need to provide host arrays of indices.</div><div><br></div><div>Am I stuck, for now, with sending the index information information from the device to the host, using it to create the IS, and then having essentially the same information go back to the device when I use the scatter?</div><div><br></div><div>* As an aside, it looks like some of these Kokkos-related functions and types are missing man pages - if you have time to add them, even as stubs, that'd be great (if not let me know and I'll just try to formally do it, so that at least the existence of the functions in the API is reflected on the website).</div><div><br></div><div><div><blockquote type="cite"><div>Am 18.02.2021 um 23:17 schrieb Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@gmail.com</a>>:</div><br><div><div dir="ltr"><div dir="ltr"><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 18, 2021 at 4:04 PM Fande Kong <<a href="mailto:fdkong.jd@gmail.com" target="_blank">fdkong.jd@gmail.com</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 dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 18, 2021 at 1:55 PM Junchao Zhang <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@gmail.com</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 dir="ltr"><div>VecScatter (i.e., SF, the two are the same thing) setup (building various index lists, rank lists) is done on the CPU. is1, is2 must be host data. </div></div></blockquote><div><br></div><div>Just out of curiosity, is1 and is2 can not be created on a GPU device in the first place? That being said, it is technically impossible? Or we just did not implement them yet?<br></div></div></div></blockquote><div>Simply because we do not have an ISCUDA class.</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 dir="ltr"><div class="gmail_quote"><div></div><div><br></div><div>Fande,<br></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 dir="ltr"><div>When the SF is used to communicate device data, indices are copied to the device..</div><div><br></div><div>--Junchao Zhang<br></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 18, 2021 at 11:50 AM Patrick Sanan <<a href="mailto:patrick.sanan@gmail.com" target="_blank">patrick.sanan@gmail.com</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>I'm trying to understand how VecScatters work with GPU-native Kokkos Vecs. <div><br></div><div>Specifically, I'm interested in what will happen in code like in src/vec/vec/tests/ex22.c, </div><div><br></div><div><code><span><span style="white-space:pre-wrap"> </span>ierr</span> <span>=</span> <span>VecScatterCreate</span><span>(</span><span>x</span><span>,</span><span>is1</span><span>,</span><span>y</span><span>,</span><span>is2</span><span>,</span><span>&</span><span>ctx</span><span>);</span><span>CHKERRQ</span><span>(</span><span>ierr</span><span>);</span></code></div><div><br></div><div>(from <a href="https://gitlab.com/petsc/petsc/-/blob/master/src/vec/vec/tests/ex22.c#L44" target="_blank">https://gitlab.com/petsc/petsc/-/blob/master/src/vec/vec/tests/ex22.c#L44</a>)</div><div><br></div><div>Here, x and y can be set to type KOKKOS using -vec_type kokkos at the command line. But is1 and is2 are (I think), always</div><div>CPU/host data. Assuming that the scatter itself can happen on the GPU, the indices must make it to the device somehow - are they copied there when the scatter is created? Is there a way to create the scatter using indices already on the GPU (Maybe using SF more directly)?</div><div><br></div></div></blockquote></div>
</blockquote></div></div>
</blockquote></div></div>
</div></blockquote></div><br></div></div></div></blockquote></div>