CMS 3D CMS Logo

TestCUDAAnalyzerGPU.cc
Go to the documentation of this file.
8 
14 
16 
18 public:
19  explicit TestCUDAAnalyzerGPU(edm::ParameterSet const& iConfig);
20  ~TestCUDAAnalyzerGPU() override = default;
21 
22  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
23 
24  void analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const& iSetup) const override;
25  void endJob() override;
26 
27 private:
30  double const minValue_;
31  double const maxValue_;
32  // the public interface is thread safe
33  CMS_THREAD_SAFE mutable std::unique_ptr<TestCUDAAnalyzerGPUKernel> gpuAlgo_;
34 };
35 
37  : label_(iConfig.getParameter<std::string>("@module_label")),
38  srcToken_(consumes<cms::cuda::Product<cms::cudatest::Thing>>(iConfig.getParameter<edm::InputTag>("src"))),
39  minValue_(iConfig.getParameter<double>("minValue")),
40  maxValue_(iConfig.getParameter<double>("maxValue")) {
42  if (cuda and cuda->enabled()) {
43  auto streamPtr = cms::cuda::getStreamCache().get();
44  gpuAlgo_ = std::make_unique<TestCUDAAnalyzerGPUKernel>(streamPtr.get());
45  }
46 }
47 
50  desc.add<edm::InputTag>("src", edm::InputTag())->setComment("Source of cms::cuda::Product<cms::cudatest::Thing>.");
51  desc.add<double>("minValue", -1e308);
52  desc.add<double>("maxValue", 1e308);
53  descriptions.addWithDefaultLabel(desc);
54  descriptions.setComment("This EDAnalyzer is part of the TestCUDAProducer* family. It models a GPU analyzer.");
55 }
56 
58  edm::LogVerbatim("TestCUDAAnalyzerGPU") << label_ << " TestCUDAAnalyzerGPU::analyze begin event "
59  << iEvent.id().event() << " stream " << iEvent.streamID();
60 
61  auto const& in = iEvent.get(srcToken_);
63  cms::cudatest::Thing const& input = ctx.get(in);
64  gpuAlgo_->analyzeAsync(input.get(), ctx.stream());
65 
66  edm::LogVerbatim("TestCUDAAnalyzerGPU")
67  << label_ << " TestCUDAAnalyzerGPU::analyze end event " << iEvent.id().event() << " stream " << iEvent.streamID();
68 }
69 
71  edm::LogVerbatim("TestCUDAAnalyzerGPU") << label_ << " TestCUDAAnalyzerGPU::endJob begin";
72 
73  auto streamPtr = cms::cuda::getStreamCache().get();
74  auto value = gpuAlgo_->value(streamPtr.get());
75  edm::LogVerbatim("TestCUDAAnalyzerGPU") << label_ << " accumulated value " << value;
77 
78  edm::LogVerbatim("TestCUDAAnalyzerGPU") << label_ << " TestCUDAAnalyzerGPU::endJob end";
79 }
80 
Log< level::Info, true > LogVerbatim
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:50
int iEvent
Definition: GenABIO.cc:224
TestCUDAAnalyzerGPU(edm::ParameterSet const &iConfig)
SharedStreamPtr get()
Definition: StreamCache.cc:20
#define CMS_THREAD_SAFE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Definition: value.py:1
Namespace of DDCMS conversion namespace.
void setComment(std::string const &value)
edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > const srcToken_
HLT enums.
StreamCache & getStreamCache()
Definition: StreamCache.cc:39
std::unique_ptr< TestCUDAAnalyzerGPUKernel > gpuAlgo_
void analyze(edm::StreamID, edm::Event const &iEvent, edm::EventSetup const &iSetup) const override
std::string const label_
~TestCUDAAnalyzerGPU() override=default