CMS 3D CMS Logo

TestCUDAProducerCPU.cc
Go to the documentation of this file.
7 
8 #include <chrono>
9 #include <random>
10 #include <thread>
11 
13 public:
14  explicit TestCUDAProducerCPU(edm::ParameterSet const& iConfig);
15  ~TestCUDAProducerCPU() override = default;
16 
17  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
18 
19  void produce(edm::StreamID id, edm::Event& iEvent, edm::EventSetup const& iSetup) const override;
20 
21 private:
25 };
26 
28  : label_{iConfig.getParameter<std::string>("@module_label")}, dstToken_{produces<int>()} {
29  auto srcTag = iConfig.getParameter<edm::InputTag>("src");
30  if (!srcTag.label().empty()) {
31  srcToken_ = consumes<int>(srcTag);
32  }
33 }
34 
37  desc.add<edm::InputTag>("src", edm::InputTag())->setComment("Optional source of another TestCUDAProducerCPU.");
38  descriptions.addWithDefaultLabel(desc);
39  descriptions.setComment("This EDProducer is part of the TestCUDAProducer* family. It models a CPU algorithm.");
40 }
41 
43  edm::LogVerbatim("TestCUDAProducerCPU")
44  << label_ << " TestCUDAProducerCPU::produce begin event " << iEvent.id().event() << " stream " << id;
45 
46  int input = 0;
47  if (!srcToken_.isUninitialized()) {
48  input = iEvent.get(srcToken_);
49  }
50 
51  std::random_device r;
52  std::mt19937 gen(r());
53  auto dist = std::uniform_real_distribution<>(0.2, 1.5);
54  auto dur = dist(gen);
55  edm::LogVerbatim("TestCUDAProducerCPU")
56  << " Task (CPU) for event " << iEvent.id().event() << " in stream " << id << " will take " << dur << " seconds";
57  std::this_thread::sleep_for(std::chrono::seconds(1) * dur);
58 
59  unsigned int const output = input + id * 100 + iEvent.id().event();
60 
61  iEvent.emplace(dstToken_, output);
62 
63  edm::LogVerbatim("TestCUDAProducerCPU") << label_ << " TestCUDAProducerCPU::produce end event " << iEvent.id().event()
64  << " stream " << id << " result " << output;
65 }
66 
edm::StreamID
Definition: StreamID.h:30
input
static const std::string input
Definition: EdmProvDump.cc:48
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT< int >
edm::EDPutTokenT< int >
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
seconds
double seconds()
gen
Definition: PythiaDecays.h:13
ParameterSetDescription.h
TestCUDAProducerCPU::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TestCUDAProducerCPU.cc:35
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TestCUDAProducerCPU
Definition: TestCUDAProducerCPU.cc:12
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
TestCUDAProducerCPU::dstToken_
const edm::EDPutTokenT< int > dstToken_
Definition: TestCUDAProducerCPU.cc:24
iEvent
int iEvent
Definition: GenABIO.cc:224
TestCUDAProducerCPU::~TestCUDAProducerCPU
~TestCUDAProducerCPU() override=default
TestCUDAProducerCPU::label_
const std::string label_
Definition: TestCUDAProducerCPU.cc:22
TestCUDAProducerCPU::produce
void produce(edm::StreamID id, edm::Event &iEvent, edm::EventSetup const &iSetup) const override
Definition: TestCUDAProducerCPU.cc:42
edm::EventSetup
Definition: EventSetup.h:57
alignCSCRings.r
r
Definition: alignCSCRings.py:93
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
Frameworkfwd.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
relval_steps.gen
def gen(fragment, howMuch)
Production test section ####.
Definition: relval_steps.py:509
TestCUDAProducerCPU::srcToken_
edm::EDGetTokenT< int > srcToken_
Definition: TestCUDAProducerCPU.cc:23
ParameterSet.h
EDProducer.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
TestCUDAProducerCPU::TestCUDAProducerCPU
TestCUDAProducerCPU(edm::ParameterSet const &iConfig)
Definition: TestCUDAProducerCPU.cc:27
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87