CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TestCUDAAnalyzerGPU.cc
Go to the documentation of this file.
8 
14 
16 
18 public:
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 (cs->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;
76  assert(minValue_ <= value && value <= maxValue_);
77 
78  edm::LogVerbatim("TestCUDAAnalyzerGPU") << label_ << " TestCUDAAnalyzerGPU::endJob end";
79 }
80 
Log< level::Info, true > LogVerbatim
EventNumber_t event() const
Definition: EventID.h:40
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const float * get() const
Definition: Thing.h:13
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
unique_ptr< ClusterSequence > cs
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
assert(be >=bs)
static std::string const input
Definition: EdmProvDump.cc:47
int iEvent
Definition: GenABIO.cc:224
TestCUDAAnalyzerGPU(edm::ParameterSet const &iConfig)
bool enabled() const
Definition: CUDAService.h:22
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
SharedStreamPtr get()
Definition: StreamCache.cc:20
#define CMS_THREAD_SAFE
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setComment(std::string const &value)
edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > const srcToken_
edm::EventID id() const
Definition: EventBase.h:59
StreamCache & getStreamCache()
Definition: StreamCache.cc:39
StreamID streamID() const
Definition: Event.h:98
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