Actual source code: sfcupm.hpp

      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>

      7: namespace Petsc
      8: {

     10: namespace sf
     11: {

     13: namespace cupm
     14: {

     16: namespace impl
     17: {

     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);

     23: private:
     24:   template <typename Type, PetscInt BS, PetscInt EQ>
     25:   static PetscErrorCode Pack(PetscSFLink, PetscInt, PetscInt, PetscSFPackOpt, const PetscInt *, const void *, void *) noexcept;

     27:   template <typename Type, class Op, PetscInt BS, PetscInt EQ>
     28:   static PetscErrorCode UnpackAndOp(PetscSFLink, PetscInt, PetscInt, PetscSFPackOpt, const PetscInt *, void *, const void *) noexcept;

     30:   template <typename Type, class Op, PetscInt BS, PetscInt EQ>
     31:   static PetscErrorCode FetchAndOp(PetscSFLink, PetscInt, PetscInt, PetscSFPackOpt, const PetscInt *, void *, void *) noexcept;

     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;

     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;

     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;

     42:   template <typename Type, PetscInt BS, PetscInt EQ>
     43:   static void PackInit_RealType(PetscSFLink) noexcept;

     45:   template <typename Type, PetscInt BS, PetscInt EQ, PetscInt size /*sizeof(Type)*/>
     46:   struct PackInit_IntegerType_Atomic;

     48:   template <typename Type, PetscInt BS, PetscInt EQ>
     49:   static void PackInit_IntegerType(PetscSFLink link) noexcept;

     51: #if PetscDefined(HAVE_COMPLEX)
     52:   template <typename Type, PetscInt BS, PetscInt EQ>
     53:   static void PackInit_ComplexType(PetscSFLink link) noexcept;
     54: #endif

     56:   template <typename Type>
     57:   static void PackInit_PairType(PetscSFLink link) noexcept;

     59:   template <typename Type, PetscInt BS, PetscInt EQ>
     60:   static void PackInit_DumbType(PetscSFLink link) noexcept;

     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;

     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: };

     73: } // namespace impl

     75: } // namespace cupm

     77: } // namespace sf

     79: } // namespace Petsc