<div dir="ltr">Note we have MatCreateSeqAIJKokkosWithKokkosViews(MPI_Comm, PetscInt, PetscInt, Kokkos::View<PetscInt *> &, Kokkos::View<PetscInt *> &, Kokkos::View<PetscScalar *> &, Mat *);<br><br>Yes, I think we could provide MatCreateSeqAIJCUSPARSEWithArrays(MPI_Comm comm, PetscInt m, PetscInt n, PetscInt i[], PetscInt j[], PetscScalar a[], Mat *mat) with i, j, a on device. Note we already have MatCreateMPIAIJWithSeqAIJ(MPI_Comm comm, Mat A, Mat B, const PetscInt garray[], Mat *mat). With that, users are able to create MPIAIJ matrices on device with their own data, if they can manage the complexity. <div><div><br></div><div>--Junchao Zhang</div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Jan 13, 2026 at 4:15 PM Jed Brown <<a href="mailto:jed@jedbrown.org">jed@jedbrown.org</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">Note that petsc4py does have DLPack interfaces for Vec. So if you like DLPack, you could extend those interfaces.<br>
<br>
Also, MatSetValuesCOO can assemble matrices in which all the data is provided on the device. If you're generating sparse matrices on device, that routine is likely to be useful.<br>
<br>
Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank">bsmith@petsc.dev</a>> writes:<br>
<br>
> Alberto,<br>
><br>
> We don't have such a routine yet, but we should and it would not be terribly difficult to implement (using pieces of PETSc that already exist and cut and pasting them into a new function MatCreateSeqAICUSPARSEWithArrays()).<br>
><br>
> Barry<br>
><br>
><br>
>> On Jan 13, 2026, at 1:44 PM, Alberto Cattaneo via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br>
>> <br>
>> Greetings<br>
>> I hope this email reaches you all well. I was wondering whether it was possible to create PETSc mat objects directly from data that exists on the GPU in AIJ format without copying? For example, either via DLPack or just an assurance that the pointer provided to a creation method is in the needed AIJ format? Ideally, I'd like to be able to build a PETSc AIJCUSPARSE object out of data created by another program. I know there are a few builder methods and paradigms, but I'm a bit confused as to which would be ideal in this circumstance since in some sense the matrix is already created in memory, just not as a PETSc object.<br>
>> Thank you for your assistance, please let me know if I should provide more information.<br>
>> Respectfully:<br>
>> Alberto Cattaneo<br>
</blockquote></div>