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 (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;
77 
78  edm::LogVerbatim("TestCUDAAnalyzerGPU") << label_ << " TestCUDAAnalyzerGPU::endJob end";
79 }
80 
edm::StreamID
Definition: StreamID.h:30
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
input
static const std::string input
Definition: EdmProvDump.cc:48
StreamCache.h
TestCUDAAnalyzerGPU::label_
const std::string label_
Definition: TestCUDAAnalyzerGPU.cc:28
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
TestCUDAAnalyzerGPUKernel.h
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
cms::cuda::ScopedContextAnalyze
Definition: ScopedContext.h:222
cms::cuda::assert
assert(be >=bs)
TestCUDAAnalyzerGPU
Definition: TestCUDAAnalyzerGPU.cc:17
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Service.h
TestCUDAAnalyzerGPU::endJob
void endJob() override
Definition: TestCUDAAnalyzerGPU.cc:70
prod1Switch_cff.cuda
cuda
Definition: prod1Switch_cff.py:11
CMS_THREAD_SAFE
#define CMS_THREAD_SAFE
Definition: thread_safety_macros.h:4
ParameterSetDescription.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
TestCUDAAnalyzerGPU::maxValue_
const double maxValue_
Definition: TestCUDAAnalyzerGPU.cc:31
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::cuda::getStreamCache
StreamCache & getStreamCache()
Definition: StreamCache.cc:39
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
TestCUDAAnalyzerGPU::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: TestCUDAAnalyzerGPU.cc:48
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
recoMuon::in
Definition: RecoMuonEnumerators.h:6
TestCUDAAnalyzerGPU::gpuAlgo_
std::unique_ptr< TestCUDAAnalyzerGPUKernel > gpuAlgo_
Definition: TestCUDAAnalyzerGPU.cc:33
cms::cudatest::Thing
Definition: Thing.h:8
cms::cuda::StreamCache::get
SharedStreamPtr get()
Definition: StreamCache.cc:20
TestCUDAAnalyzerGPU::TestCUDAAnalyzerGPU
TestCUDAAnalyzerGPU(edm::ParameterSet const &iConfig)
Definition: TestCUDAAnalyzerGPU.cc:36
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
value
Definition: value.py:1
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::EventSetup
Definition: EventSetup.h:57
TestCUDAAnalyzerGPU::analyze
void analyze(edm::StreamID, edm::Event const &iEvent, edm::EventSetup const &iSetup) const override
Definition: TestCUDAAnalyzerGPU.cc:57
CUDAService.h
Product.h
TestCUDAAnalyzerGPU::~TestCUDAAnalyzerGPU
~TestCUDAAnalyzerGPU() override=default
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
relativeConstraints.value
value
Definition: relativeConstraints.py:53
ScopedContext.h
TestCUDAAnalyzerGPU::srcToken_
const edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > srcToken_
Definition: TestCUDAAnalyzerGPU.cc:29
TestCUDAAnalyzerGPU::minValue_
const double minValue_
Definition: TestCUDAAnalyzerGPU.cc:30
Thing.h
ParameterSet.h
edm::Event
Definition: Event.h:73
EDAnalyzer.h
edm::InputTag
Definition: InputTag.h:15
edm::global::EDAnalyzer
Definition: EDAnalyzer.h:32
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21