[petsc-dev] Backend independent VecGetArray for GPUs

Karl Rupp rupp at iue.tuwien.ac.at
Fri Oct 17 11:25:03 CDT 2014


Hi Ashwin,

 > After discussion with Lisandro Dalcin, I think that it might be a good
> idea for PETSc to provide a routine `VecGetGPUArray` (in place of or in
> addition to the current `VecCUSPGetArray`) which returns a raw pointer
> to device memory, and lets the user decide what to do with it.
>
> Do you think this can fit in to PETSc? If so, I already have an
> implementation, but can use help with the interface.

If this should be provided, then the right names were
  VecCUDAGetArray()
  VecOpenCLGetArray()
The former returns an object of type PetscScalar* and the latter an 
object of type cl_mem. Because one is stuck with two incompatible 
pointer types here, I'd suggest not to provide a single interface at the 
expense of giving up type safety. Also, even if one gives up type 
safety, one would immediately have to switch-case into a 
backend-specific implementation again, so there's little value in a 
common interface.

Best regards,
Karli




More information about the petsc-dev mailing list