#if !defined(PETSCVEC_KOKKOS_HPP) #define PETSCVEC_KOKKOS_HPP #include /* SUBMANSEC = Vec */ #if defined(PETSC_HAVE_KOKKOS) #if defined(petsccomplexlib) #error "Error: You must include petscvec_kokkos.hpp before other petsc headers in this C++ file to use petsc complex with Kokkos" #endif #define PETSC_DESIRE_KOKKOS_COMPLEX 1 /* To control the definition of petsccomplexlib in petscsystypes.h */ #endif #include #if defined(PETSC_HAVE_KOKKOS) #include /*@C VecGetKokkosView - Returns a constant Kokkos View that contains up-to-date data of a vector in the specified memory space. Synopsis: #include PetscErrorCode VecGetKokkosView (Vec v,Kokkos::View* kv); PetscErrorCode VecGetKokkosView (Vec v,Kokkos::View* kv); Logically Collective on Vec Input Parameter: . v - the vector in type of VECKOKKOS Output Parameter: . kv - the Kokkos View with a user-specified template parameter MemorySpace Notes: If the vector is not of type VECKOKKOS, an error will be raised. The functions are similar to VecGetArrayRead() and VecGetArray() respectively. One can read-only or read/write the returned Kokkos View. Note that passing in a const View enables read-only access. One must return the View by a matching VecRestoreKokkosView() after finishing using the View. Currently, only two memory spaces are supported: Kokkos::HostSpace and Kokkos::DefaultExecutionSpace::memory_space. If needed, a memory copy will be internally called to copy the latest vector data to the specified memory space. Level: beginner .seealso: `VecRestoreKokkosView()`, `VecRestoreArray()`, `VecGetKokkosViewWrite()`, `VecGetArrayRead()`, `VecGetArrays()`, `VecGetArrayF90()`, `VecGetArrayReadF90()`, `VecPlaceArray()`, `VecGetArray2d()`, `VecGetArrayPair()`, `VecRestoreArrayPair()`, `VecGetArrayWrite()`, `VecRestoreArrayWrite()` @*/ template PetscErrorCode VecGetKokkosView (Vec,Kokkos::View*); template PetscErrorCode VecGetKokkosView (Vec,Kokkos::View*); /*@C VecRestoreKokkosView - Returns a Kokkos View gotten by VecGetKokkosView(). Synopsis: #include PetscErrorCode VecRestoreKokkosView (Vec v,Kokkos::View* kv); PetscErrorCode VecRestoreKokkosView (Vec v,Kokkos::View* kv); Logically Collective on Vec Input Parameters: + v - the vector in type of VECKOKKOS - kv - the Kokkos View with a user-specified template parameter MemorySpace Notes: If the vector is not of type VECKOKKOS, an error will be raised. The functions are similar to VecRestoreArrayRead() and VecRestoreArray() respectively. They are the counterpart of VecGetKokkosView(). Level: beginner .seealso: `VecGetKokkosView()`, `VecRestoreKokkosViewWrite()`, `VecRestoreArray()`, `VecGetArrayRead()`, `VecGetArrays()`, `VecGetArrayF90()`, `VecGetArrayReadF90()`, `VecPlaceArray()`, `VecGetArray2d()`, `VecGetArrayPair()`, `VecRestoreArrayPair()`, `VecGetArrayWrite()`, `VecRestoreArrayWrite()` @*/ template PetscErrorCode VecRestoreKokkosView(Vec,Kokkos::View*){return 0;} template PetscErrorCode VecRestoreKokkosView(Vec,Kokkos::View*); /*@C VecGetKokkosViewWrite - Returns a Kokkos View that contains the array of a vector in the specified memory space. Synopsis: #include PetscErrorCode VecGetKokkosViewWrite (Vec v,Kokkos::View* kv); Logically Collective on Vec Input Parameter: . v - the vector in type of VECKOKKOS Output Parameter: . kv - the Kokkos View with a user-specified template parameter MemorySpace Notes: If the vector is not of type VECKOKKOS, an error will be raised. The functions is similar to VecGetArrayWrite(). The returned view might contain garbage data or stale data and one is not expected to read data from the View. Instead, one is expected to overwrite all data in the View. One must return the View by a matching VecRestoreKokkosViewWrite() after finishing using the View. Currently, only two memory spaces are supported: Kokkos::HostSpace and Kokkos::DefaultExecutionSpace::memory_space. Level: beginner .seealso: `VecRestoreKokkosViewWrite()`, `VecRestoreKokkosView()`, `VecGetKokkosView()`, `VecRestoreArray()`, `VecGetArrayRead()`, `VecGetArrays()`, `VecGetArrayF90()`, `VecGetArrayReadF90()`, `VecPlaceArray()`, `VecGetArray2d()`, `VecGetArrayPair()`, `VecRestoreArrayPair()`, `VecGetArrayWrite()`, `VecRestoreArrayWrite()` @*/ template PetscErrorCode VecGetKokkosViewWrite (Vec,Kokkos::View*); /*@C VecRestoreKokkosViewWrite - Returns a Kokkos View gotten by VecGetKokkosViewWrite(). Synopsis: #include PetscErrorCode VecRestoreKokkosViewWrite (Vec v,Kokkos::View* kv); Logically Collective on Vec Input Parameters: + v - the vector in type of VECKOKKOS - kv - the Kokkos View with a user-specified template parameter MemorySpace Notes: If the vector is not of type VECKOKKOS, an error will be raised. The function is similar to VecRestoreArrayWrite(). It is the counterpart of VecGetKokkosViewWrite(). Level: beginner .seealso: `VecGetKokkosViewWrite()`, `VecGetKokkosView()`, `VecGetKokkosView()`, `VecRestoreArray()`, `VecGetArrayRead()`, `VecGetArrays()`, `VecGetArrayF90()`, `VecGetArrayReadF90()`, `VecPlaceArray()`, `VecGetArray2d()`, `VecGetArrayPair()`, `VecRestoreArrayPair()`, `VecGetArrayWrite()`, `VecRestoreArrayWrite()` @*/ template PetscErrorCode VecRestoreKokkosViewWrite(Vec,Kokkos::View*); #if defined(PETSC_HAVE_COMPLEX) && defined(PETSC_USE_COMPLEX) static_assert(std::alignment_of>::value == std::alignment_of>::value, "Alignment of Kokkos::complex and std::complex mismatch. Reconfigure your Kokkos with -DKOKKOS_ENABLE_COMPLEX_ALIGN=OFF, or let PETSc install Kokkos for you with --download-kokkos --download-kokkos-kernels"); #endif #endif #endif