Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0003 #include "FWCore/Utilities/interface/InputTag.h"
0004 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/stream/SynchronizingEDProducer.h"
0005 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0006 
0007 #include "TestHelperClass.h"
0008 
0009 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0010   /**
0011    * This class demonstrates a stream EDProducer that
0012    * - uses a helper class (need to use edm::ConsumesCollector), that
0013    *   - consumes a device EDProduct
0014    *   - consumes a host ESProduct
0015    *   - consumes a device ESProduct
0016    * - consumes a device ESProduct
0017    * - produces a host EDProduct
0018    * - synchronizes in a non-blocking way with the ExternalWork module
0019    *   ability (via the SynchronizingEDProcucer base class)
0020    */
0021   class TestAlpakaStreamSynchronizingProducer : public stream::SynchronizingEDProducer<> {
0022   public:
0023     TestAlpakaStreamSynchronizingProducer(edm::ParameterSet const& iConfig)
0024         : esTokenDevice_(esConsumes()), putToken_{produces()}, helper_{iConfig, consumesCollector()} {}
0025 
0026     void acquire(device::Event const& iEvent, device::EventSetup const& iSetup) override {
0027       [[maybe_unused]] auto const& esData = iSetup.getData(esTokenDevice_);
0028 
0029       helper_.makeAsync(iEvent, iSetup);
0030     }
0031 
0032     void produce(device::Event& iEvent, device::EventSetup const& iSetup) override {
0033       iEvent.emplace(putToken_, helper_.moveFrom());
0034     }
0035 
0036     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0037       edm::ParameterSetDescription desc;
0038       desc.add<edm::InputTag>("source");
0039       descriptions.addWithDefaultLabel(desc);
0040     }
0041 
0042   private:
0043     const device::ESGetToken<AlpakaESTestDataDDevice, AlpakaESTestRecordD> esTokenDevice_;
0044     const edm::EDPutTokenT<portabletest::TestHostCollection> putToken_;
0045 
0046     TestHelperClass helper_;
0047   };
0048 
0049 }  // namespace ALPAKA_ACCELERATOR_NAMESPACE
0050 
0051 #include "HeterogeneousCore/AlpakaCore/interface/MakerMacros.h"
0052 DEFINE_FWK_ALPAKA_MODULE(TestAlpakaStreamSynchronizingProducer);