#pragma once #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 PetscComplex 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, No Fortran Support Input Parameter: . v - the vector in type of `VECKOKKOS` Output Parameter: . kv - the Kokkos View with a user-specified template parameter MemorySpace Level: beginner 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. 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: HostMirrorMemorySpace 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. .seealso: `VecRestoreKokkosView()`, `VecRestoreArray()`, `VecGetKokkosViewWrite()`, `VecGetArrayRead()`, `VecGetArrays()`, `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, No Fortran Support Input Parameters: + v - the vector in type of `VECKOKKOS` - kv - the Kokkos View with a user-specified template parameter MemorySpace Level: beginner Note: 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()`. .seealso: `VecGetKokkosView()`, `VecRestoreKokkosViewWrite()`, `VecRestoreArray()`, `VecGetArrayRead()`, `VecGetArrays()`, `VecPlaceArray()`, `VecGetArray2d()`, `VecGetArrayPair()`, `VecRestoreArrayPair()`, `VecGetArrayWrite()`, `VecRestoreArrayWrite()` @*/ template PetscErrorCode VecRestoreKokkosView(Vec, Kokkos::View *) { return PETSC_SUCCESS; } 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, No Fortran Support Input Parameter: . v - the vector in type of `VECKOKKOS` Output Parameter: . kv - the Kokkos View with a user-specified template parameter MemorySpace Level: beginner 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: HostMirrorMemorySpace and Kokkos::DefaultExecutionSpace::memory_space. .seealso: `VecRestoreKokkosViewWrite()`, `VecRestoreKokkosView()`, `VecGetKokkosView()`, `VecRestoreArray()`, `VecGetArrayRead()`, `VecGetArrays()`, `VecPlaceArray()`, `VecGetArray2d()`, `VecGetArrayPair()`, `VecRestoreArrayPair()`, `VecGetArrayWrite()`, `VecRestoreArrayWrite()` @*/ template PetscErrorCode VecGetKokkosViewWrite(Vec, Kokkos::View *); /*@C VecRestoreKokkosViewWrite - Returns a Kokkos View gotten with `VecGetKokkosViewWrite()`. Synopsis: #include PetscErrorCode VecRestoreKokkosViewWrite (Vec v,Kokkos::View* kv); Logically Collective, No Fortran Support Input Parameters: + v - the vector in type of `VECKOKKOS` - kv - the Kokkos View with a user-specified template parameter MemorySpace Level: beginner 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()`. .seealso: `VecGetKokkosViewWrite()`, `VecGetKokkosView()`, `VecGetKokkosView()`, `VecRestoreArray()`, `VecGetArrayRead()`, `VecGetArrays()`, `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