[petsc-dev] using typedef for each different memory space the variable lives in
Barry Smith
bsmith at petsc.dev
Sat Dec 12 09:43:53 CST 2020
Currently we use PetscScalar and PetscScalar * to refer to variables that could be in any memory space. On the CPU, on the GPU, in Kokkos, etc.
Would it make sense to use typedef to indicate at each location the true type of the memory location when possible?
typedef PetscReal PetscKokkosReal means the variable is in the Kokkos memory space
typedef PetscReal PetscCUDAReal
typedef PetscReal PetscNVSHEMReal
etc.
Then one could write things like
struct {
...
PetscNVSHEMReal *values;
}
Similarly inside kernels one would use the type type associated with the kernel, cuda with cuda etc.
I think the resulting code will be much clearer and easier to dive into, then having to first figure out where each variable lives.
I find the current code confusing because one cannot immediately see a variable declaration and know where it lives, even though it does live somewhere in particular..
Barry
More information about the petsc-dev
mailing list