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