AddSize

AddSize

AddSize

DevPtr

DevStoragePolicy

Ptr

StorageSelector

StorageSelector

StorageSelector

Vec

VecStoragePolicy

ViewStoragePolicy

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#ifndef CUDADataFormats_CaloCommon_interface_Common_h
#define CUDADataFormats_CaloCommon_interface_Common_h

#include <vector>

#include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
#include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"

namespace calo {
  namespace common {

    // FIXME: not able to get enums to work with genreflex
    namespace tags {

      struct Vec {};
      struct Ptr {};
      struct DevPtr {};

    }  // namespace tags

    template <typename tag>
    struct AddSize {};

    template <>
    struct AddSize<tags::Ptr> {
      uint32_t size;
    };

    template <>
    struct AddSize<tags::DevPtr> {
      uint32_t size;
    };

    struct ViewStoragePolicy {
      using TagType = tags::Ptr;

      template <typename T>
      struct StorageSelector {
        using type = T*;
      };
    };

    struct DevStoragePolicy {
      using TagType = tags::DevPtr;

      template <typename T>
      struct StorageSelector {
        using type = cms::cuda::device::unique_ptr<T[]>;
      };
    };

    template <template <typename> typename Allocator = std::allocator>
    struct VecStoragePolicy {
      using TagType = tags::Vec;

      template <typename T>
      struct StorageSelector {
        using type = std::vector<T, Allocator<T>>;
      };
    };

    template <typename T>
    using CUDAHostAllocatorAlias = cms::cuda::HostAllocator<T>;

  }  // namespace common
}  // namespace calo

#endif  // CUDADataFormats_CaloCommon_interface_Common_h