1 #if !defined(PETSCVEC_KOKKOS_HPP) 2 #define PETSCVEC_KOKKOS_HPP 3 4 #include <petscconf.h> 5 6 #if defined(PETSC_HAVE_KOKKOS) 7 #if defined(petsccomplexlib) 8 #error "Error: You must include petscvec_kokkos.hpp before other petsc headers in this C++ file to use petsc complex with Kokkos" 9 #endif 10 11 #define PETSC_DESIRE_KOKKOS_COMPLEX 1 /* To control the definition of petsccomplexlib in petscsystypes.h */ 12 #endif 13 14 #include <petscvec.h> 15 16 #if defined(PETSC_HAVE_KOKKOS) 17 #include <Kokkos_Core.hpp> 18 19 /* REMOVE ME (?) */ 20 #if defined(PETSC_HAVE_CUDA) 21 #define WaitForKokkos() (Kokkos::fence(),0) 22 #elif defined(PETSC_HAVE_HIP) 23 #define WaitForKokkos() (Kokkos::fence(),0) 24 #else 25 #define WaitForKokkos() 0 26 #endif 27 28 /* Routines to get/restore Kokkos Views from PETSc vectors */ 29 30 /* Like VecGetArrayRead() */ 31 template<class MemorySpace> PetscErrorCode VecGetKokkosView (Vec,Kokkos::View<const PetscScalar*,MemorySpace>*); 32 template<class MemorySpace> PetscErrorCode VecRestoreKokkosView(Vec,Kokkos::View<const PetscScalar*,MemorySpace>*){return 0;} 33 34 /* Like VecGetArray() */ 35 template<class MemorySpace> PetscErrorCode VecGetKokkosView (Vec,Kokkos::View<PetscScalar*,MemorySpace>*); 36 template<class MemorySpace> PetscErrorCode VecRestoreKokkosView(Vec,Kokkos::View<PetscScalar*,MemorySpace>*); 37 38 /* Like VecGetArrayWrite() */ 39 template<class MemorySpace> PetscErrorCode VecGetKokkosViewWrite (Vec,Kokkos::View<PetscScalar*,MemorySpace>*); 40 template<class MemorySpace> PetscErrorCode VecRestoreKokkosViewWrite(Vec,Kokkos::View<PetscScalar*,MemorySpace>*); 41 42 #endif 43 44 #endif 45