[petsc-users] Petsc veccuda device to host copy
Barry Smith
bsmith at petsc.dev
Sun Dec 7 22:35:26 CST 2025
I am sorry to hear you are having difficulties. Please send a full reproducer so we can track down the problem using the latest PETSc release. Software changes very rapidly for GPUs so we cannot support or debug PETSc 3.21.1, which is a couple of years old. But if the problem persists in 3.24, we will definitely track it down if you provide a reproducer.
Barry
> On Dec 7, 2025, at 11:03 PM, Wenbo Zhao <zhaowenbo.npic at gmail.com> wrote:
>
> Hi,
>
> we are using petsc's veccuda and found that the data in the host array obtained via VecGetArrayRead is partially updated sometime.
>
>
>
>
> Vec vgpu, vcpu;
>
> iterations:
>
> // ksp solve a * vgpu=b
>
> const PetscScalar * agpu;
>
> PetscScalar * acpu;
>
> VecGetArrayRead(vgpu, &agpu);
>
> VecGetArray(vcpu, &acpu);
>
>
> PetscArraycpy (acpu, agpu,size);
>
> // check updating
>
> std::cout << agpu[0] << agpu [size-1]<<std::endl;
>
> // we found that agpu[0] is last iterations value, agpu[size-1] updated from device value, randomly
>
> // use acpu values to update matrix a ....
>
>
>
>
>
>
>
> Petsc 3.21.1 is used. And manual said,
>
> For vectors that may also have array data in GPU memory, for example, VECCUDA, this call ensures the CPU array has the most recent array values by copying the data from the GPU memory if needed.
>
>
>
>
>
> Best wishes,
>
> Wenbo
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20251207/14f3c4ca/attachment.html>
More information about the petsc-users
mailing list