Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-16 23:23:55

0001 #include "DataFormats/Portable/interface/PortableObject.h"
0002 #include "DataFormats/PortableTestObjects/interface/TestHostObject.h"
0003 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0005 #include "FWCore/Utilities/interface/EDPutToken.h"
0006 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/global/EDProducer.h"
0007 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0008 #include "HeterogeneousCore/AlpakaInterface/interface/host.h"
0009 
0010 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0011   /**
0012    * This class demonstrates a global EDProducer that
0013    * - produces a host-side EDProduct that is copied to device automatically
0014    */
0015   class TestAlpakaGlobalProducerImplicitCopyToDevice : public global::EDProducer<> {
0016   public:
0017     TestAlpakaGlobalProducerImplicitCopyToDevice(edm::ParameterSet const& config)
0018         : EDProducer<>(config), putToken_{produces()}, putTokenInstance_{produces("instance")} {}
0019 
0020     void produce(edm::StreamID, device::Event& iEvent, device::EventSetup const& iSetup) const override {
0021       portabletest::TestStruct test{6., 14., 15., 52};
0022       iEvent.emplace(putToken_, cms::alpakatools::host(), test);
0023       iEvent.emplace(putTokenInstance_, cms::alpakatools::host(), test);
0024     }
0025 
0026     static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0027       edm::ParameterSetDescription desc;
0028       descriptions.addWithDefaultLabel(desc);
0029     }
0030 
0031   private:
0032     const edm::EDPutTokenT<portabletest::TestHostObject> putToken_;
0033     const edm::EDPutTokenT<portabletest::TestHostObject> putTokenInstance_;
0034   };
0035 
0036 }  // namespace ALPAKA_ACCELERATOR_NAMESPACE
0037 
0038 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
0039 DEFINE_FWK_ALPAKA_MODULE(TestAlpakaGlobalProducerImplicitCopyToDevice);