1 #pragma once 2 #include <../src/vec/is/sf/impls/basic/sfpack.h> 3 #include <petsc/private/cupminterface.hpp> 4 #include <petsc/private/cupmatomics.hpp> 5 #include <petsc/private/deviceimpl.h> 6 7 namespace Petsc 8 { 9 10 namespace sf 11 { 12 13 namespace cupm 14 { 15 16 namespace impl 17 { 18 19 template <device::cupm::DeviceType T> 20 struct PETSC_SINGLE_LIBRARY_VISIBILITY_INTERNAL SfInterface : device::cupm::impl::Interface<T> { 21 PETSC_CUPM_INHERIT_INTERFACE_TYPEDEFS_USING(T); 22 23 private: 24 template <typename Type, PetscInt BS, PetscInt EQ> 25 static PetscErrorCode Pack(PetscSFLink, PetscInt, PetscInt, PetscSFPackOpt, const PetscInt *, const void *, void *) noexcept; 26 27 template <typename Type, class Op, PetscInt BS, PetscInt EQ> 28 static PetscErrorCode UnpackAndOp(PetscSFLink, PetscInt, PetscInt, PetscSFPackOpt, const PetscInt *, void *, const void *) noexcept; 29 30 template <typename Type, class Op, PetscInt BS, PetscInt EQ> 31 static PetscErrorCode FetchAndOp(PetscSFLink, PetscInt, PetscInt, PetscSFPackOpt, const PetscInt *, void *, void *) noexcept; 32 33 template <typename Type, class Op, PetscInt BS, PetscInt EQ> 34 static PetscErrorCode ScatterAndOp(PetscSFLink, PetscInt, PetscInt, PetscSFPackOpt, const PetscInt *, const void *, PetscInt, PetscSFPackOpt, const PetscInt *, void *) noexcept; 35 36 template <typename Type, PetscInt BS, PetscInt EQ> 37 static PetscErrorCode ScatterAndInsert(PetscSFLink, PetscInt, PetscInt, PetscSFPackOpt, const PetscInt *, const void *, PetscInt, PetscSFPackOpt, const PetscInt *, void *) noexcept; 38 39 template <typename Type, class Op, PetscInt BS, PetscInt EQ> 40 static PetscErrorCode FetchAndOpLocal(PetscSFLink, PetscInt, PetscInt, PetscSFPackOpt, const PetscInt *, void *, PetscInt, PetscSFPackOpt, const PetscInt *, const void *, void *) noexcept; 41 42 template <typename Type, PetscInt BS, PetscInt EQ> 43 static void PackInit_RealType(PetscSFLink) noexcept; 44 45 template <typename Type, PetscInt BS, PetscInt EQ, PetscInt size /*sizeof(Type)*/> 46 struct PackInit_IntegerType_Atomic; 47 48 template <typename Type, PetscInt BS, PetscInt EQ> 49 static void PackInit_IntegerType(PetscSFLink link) noexcept; 50 51 #if PetscDefined(HAVE_COMPLEX) 52 template <typename Type, PetscInt BS, PetscInt EQ> 53 static void PackInit_ComplexType(PetscSFLink link) noexcept; 54 #endif 55 56 template <typename Type> 57 static void PackInit_PairType(PetscSFLink link) noexcept; 58 59 template <typename Type, PetscInt BS, PetscInt EQ> 60 static void PackInit_DumbType(PetscSFLink link) noexcept; 61 62 static PetscErrorCode LinkSyncDevice(PetscSFLink) noexcept; 63 static PetscErrorCode LinkSyncStream(PetscSFLink) noexcept; 64 static PetscErrorCode LinkMemcpy(PetscSFLink, PetscMemType, void *, PetscMemType, const void *, size_t) noexcept; 65 static PetscErrorCode LinkDestroy_MPI(PetscSF, PetscSFLink) noexcept; 66 67 public: 68 static PetscErrorCode Malloc(PetscMemType, size_t, void **) noexcept; 69 static PetscErrorCode Free(PetscMemType, void *) noexcept; 70 static PetscErrorCode LinkSetUp(PetscSF, PetscSFLink, MPI_Datatype) noexcept; 71 }; 72 73 } // namespace impl 74 75 } // namespace cupm 76 77 } // namespace sf 78 79 } // namespace Petsc 80