Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:03:45

0001 #ifndef CUDADataFormats_CaloCommon_interface_Common_h
0002 #define CUDADataFormats_CaloCommon_interface_Common_h
0003 
0004 #include <vector>
0005 
0006 #include "HeterogeneousCore/CUDAUtilities/interface/HostAllocator.h"
0007 #include "HeterogeneousCore/CUDAUtilities/interface/device_unique_ptr.h"
0008 
0009 namespace calo {
0010   namespace common {
0011 
0012     // FIXME: not able to get enums to work with genreflex
0013     namespace tags {
0014 
0015       struct Vec {};
0016       struct Ptr {};
0017       struct DevPtr {};
0018 
0019     }  // namespace tags
0020 
0021     template <typename tag>
0022     struct AddSize {};
0023 
0024     template <>
0025     struct AddSize<tags::Ptr> {
0026       uint32_t size;
0027     };
0028 
0029     template <>
0030     struct AddSize<tags::DevPtr> {
0031       uint32_t size;
0032     };
0033 
0034     struct ViewStoragePolicy {
0035       using TagType = tags::Ptr;
0036 
0037       template <typename T>
0038       struct StorageSelector {
0039         using type = T*;
0040       };
0041     };
0042 
0043     struct DevStoragePolicy {
0044       using TagType = tags::DevPtr;
0045 
0046       template <typename T>
0047       struct StorageSelector {
0048         using type = cms::cuda::device::unique_ptr<T[]>;
0049       };
0050     };
0051 
0052     template <template <typename> typename Allocator = std::allocator>
0053     struct VecStoragePolicy {
0054       using TagType = tags::Vec;
0055 
0056       template <typename T>
0057       struct StorageSelector {
0058         using type = std::vector<T, Allocator<T>>;
0059       };
0060     };
0061 
0062     template <typename T>
0063     using CUDAHostAllocatorAlias = cms::cuda::HostAllocator<T>;
0064 
0065   }  // namespace common
0066 }  // namespace calo
0067 
0068 #endif  // CUDADataFormats_CaloCommon_interface_Common_h