Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:39

0001 #ifndef HeterogeneousCore_AlpakaCore_interface_alpaka_EDGetToken_h
0002 #define HeterogeneousCore_AlpakaCore_interface_alpaka_EDGetToken_h
0003 
0004 #include "DataFormats/Common/interface/DeviceProduct.h"
0005 #include "FWCore/Utilities/interface/EDGetToken.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    * The device::EDGetToken is similar to edm::EDGetTokenT, but is
0013    * intended for Event data products in the device memory space
0014    * defined by the backend (i.e. ALPAKA_ACCELERATOR_NAMESPACE). It
0015    * can be used only to get data from a device::Event.
0016    *
0017    * A specific token class is motivated with
0018    * - enforce stronger the type-deducing consumes(). Consumes() with
0019    *   explicit type will fail anyway in general, but succeeds on one
0020    *   of the backends. With a specific token type the explicit-type
0021    *   consumes() would fail always.
0022    *- to avoid using device::EDGetToken with edm::Event
0023    */
0024   template <typename TProduct>
0025   class EDGetToken {
0026     using ProductType = typename detail::DeviceProductType<TProduct>::type;
0027 
0028   public:
0029     constexpr EDGetToken() = default;
0030 
0031     template <typename TAdapter>
0032     constexpr EDGetToken(TAdapter&& iAdapter) : token_(std::forward<TAdapter>(iAdapter)) {}
0033 
0034   private:
0035     friend class Event;
0036 
0037     auto const& underlyingToken() const { return token_; }
0038 
0039     edm::EDGetTokenT<ProductType> token_;
0040   };
0041 }  // namespace ALPAKA_ACCELERATOR_NAMESPACE::device
0042 
0043 #endif