Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-11-24 00:02:22

0001 #ifndef HeterogeneousCore_AlpakaCore_interface_alpaka_EDPutToken_h
0002 #define HeterogeneousCore_AlpakaCore_interface_alpaka_EDPutToken_h
0003 
0004 #include "DataFormats/Common/interface/DeviceProduct.h"
0005 #include "FWCore/Utilities/interface/EDPutToken.h"
0006 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/DeviceProductType.h"
0007 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0008 
0009 namespace ALPAKA_ACCELERATOR_NAMESPACE::device {
0010   class Event;
0011 
0012   /**
0013    * The device::EDPutToken is similar to edm::EDPutTokenT, but is
0014    * intended for Event data products in the device memory space
0015    * defined by the backend (i.e. ALPAKA_ACCELERATOR_NAMESPACE). It
0016    * can be used only to put data into a device::Event
0017    */
0018   template <typename TProduct>
0019   class EDPutToken {
0020     using ProductType = typename detail::DeviceProductType<TProduct>::type;
0021 
0022   public:
0023     constexpr EDPutToken() noexcept = default;
0024 
0025     template <typename TAdapter>
0026     explicit EDPutToken(TAdapter&& adapter) : token_(adapter.template deviceProduces<TProduct, ProductType>()) {}
0027 
0028     template <typename TAdapter>
0029     EDPutToken& operator=(TAdapter&& adapter) {
0030       edm::EDPutTokenT<ProductType> tmp(adapter.template deviceProduces<TProduct, ProductType>());
0031       token_ = tmp;
0032       return *this;
0033     }
0034 
0035   private:
0036     friend class Event;
0037 
0038     auto const& underlyingToken() const { return token_; }
0039 
0040     edm::EDPutTokenT<ProductType> token_;
0041   };
0042 
0043 }  // namespace ALPAKA_ACCELERATOR_NAMESPACE::device
0044 
0045 #endif