-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathTestCUDAProducerGPU.cc
58 lines (45 loc) · 2.73 KB
/
TestCUDAProducerGPU.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "CUDADataFormats/Common/interface/Product.h"
#include "HeterogeneousCore/CUDACore/interface/ScopedContext.h"
#include "HeterogeneousCore/CUDATest/interface/Thing.h"
#include "TestCUDAProducerGPUKernel.h"
class TestCUDAProducerGPU : public edm::global::EDProducer<> {
public:
explicit TestCUDAProducerGPU(const edm::ParameterSet& iConfig);
~TestCUDAProducerGPU() override = default;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
void produce(edm::StreamID streamID, edm::Event& iEvent, edm::EventSetup const& iSetup) const override;
private:
std::string const label_;
edm::EDGetTokenT<cms::cuda::Product<cms::cudatest::Thing>> const srcToken_;
edm::EDPutTokenT<cms::cuda::Product<cms::cudatest::Thing>> const dstToken_;
TestCUDAProducerGPUKernel const gpuAlgo_;
};
TestCUDAProducerGPU::TestCUDAProducerGPU(edm::ParameterSet const& iConfig)
: label_(iConfig.getParameter<std::string>("@module_label")),
srcToken_(consumes<cms::cuda::Product<cms::cudatest::Thing>>(iConfig.getParameter<edm::InputTag>("src"))),
dstToken_(produces<cms::cuda::Product<cms::cudatest::Thing>>()) {}
void TestCUDAProducerGPU::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("src", edm::InputTag())->setComment("Source of cms::cuda::Product<cms::cudatest::Thing>.");
descriptions.addWithDefaultLabel(desc);
descriptions.setComment(
"This EDProducer is part of the TestCUDAProducer* family. It models a GPU algorithm this is not the first "
"algorithm in the chain of the GPU EDProducers. Produces cms::cuda::Product<cms::cudatest::Thing>.");
}
void TestCUDAProducerGPU::produce(edm::StreamID streamID, edm::Event& iEvent, edm::EventSetup const& iSetup) const {
edm::LogVerbatim("TestCUDAProducerGPU") << label_ << " TestCUDAProducerGPU::produce begin event "
<< iEvent.id().event() << " stream " << iEvent.streamID();
auto const& in = iEvent.get(srcToken_);
cms::cuda::ScopedContextProduce ctx{in};
cms::cudatest::Thing const& input = ctx.get(in);
ctx.emplace(iEvent, dstToken_, cms::cudatest::Thing{gpuAlgo_.runAlgo(label_, input.get(), ctx.stream())});
edm::LogVerbatim("TestCUDAProducerGPU")
<< label_ << " TestCUDAProducerGPU::produce end event " << iEvent.id().event() << " stream " << iEvent.streamID();
}
DEFINE_FWK_MODULE(TestCUDAProducerGPU);