CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
TestCUDAProducerGPUEW Class Reference
Inheritance diagram for TestCUDAProducerGPUEW:
edm::stream::EDProducer< edm::ExternalWork >

Public Member Functions

void acquire (edm::Event const &iEvent, edm::EventSetup const &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
 
void produce (edm::Event &iEvent, edm::EventSetup const &iSetup) override
 
 TestCUDAProducerGPUEW (edm::ParameterSet const &iConfig)
 
 ~TestCUDAProducerGPUEW () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::ExternalWork >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

cms::cuda::ContextState ctxState_
 
cms::cuda::device::unique_ptr< float[]> devicePtr_
 
const edm::EDPutTokenT< cms::cuda::Product< cms::cudatest::Thing > > dstToken_
 
TestCUDAProducerGPUKernel gpuAlgo_
 
cms::cuda::host::noncached::unique_ptr< float > hostData_
 
const std::string label_
 
const edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > srcToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer< edm::ExternalWork >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 19 of file TestCUDAProducerGPUEW.cc.

Constructor & Destructor Documentation

◆ TestCUDAProducerGPUEW()

TestCUDAProducerGPUEW::TestCUDAProducerGPUEW ( edm::ParameterSet const &  iConfig)
explicit

Definition at line 41 of file TestCUDAProducerGPUEW.cc.

42  : label_{iConfig.getParameter<std::string>("@module_label")},
43  srcToken_{consumes<cms::cuda::Product<cms::cudatest::Thing>>(iConfig.getParameter<edm::InputTag>("src"))},
44  dstToken_{produces<cms::cuda::Product<cms::cudatest::Thing>>()} {
46  if (cs->enabled()) {
47  hostData_ = cms::cuda::make_host_noncached_unique<float>();
48  }
49 }

References edm::ParameterSet::getParameter(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ ~TestCUDAProducerGPUEW()

TestCUDAProducerGPUEW::~TestCUDAProducerGPUEW ( )
overridedefault

Member Function Documentation

◆ acquire()

void TestCUDAProducerGPUEW::acquire ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup,
edm::WaitingTaskWithArenaHolder  waitingTaskHolder 
)
override

Definition at line 62 of file TestCUDAProducerGPUEW.cc.

64  {
65  edm::LogVerbatim("TestCUDAProducerGPUEW") << label_ << " TestCUDAProducerGPUEW::acquire begin event "
66  << iEvent.id().event() << " stream " << iEvent.streamID();
67 
68  auto const& in = iEvent.get(srcToken_);
69  cms::cuda::ScopedContextAcquire ctx{in, std::move(waitingTaskHolder), ctxState_};
70  cms::cudatest::Thing const& input = ctx.get(in);
71 
72  devicePtr_ = gpuAlgo_.runAlgo(label_, input.get(), ctx.stream());
73  // Mimick the need to transfer some of the GPU data back to CPU to
74  // be used for something within this module, or to be put in the
75  // event.
76  cudaCheck(
77  cudaMemcpyAsync(hostData_.get(), devicePtr_.get() + 10, sizeof(float), cudaMemcpyDeviceToHost, ctx.stream()));
78  edm::LogVerbatim("TestCUDAProducerGPUEW") << label_ << " TestCUDAProducerGPUEW::acquire end event "
79  << iEvent.id().event() << " stream " << iEvent.streamID();
80 }

References ctxState_, cudaCheck, devicePtr_, dqmMemoryStats::float, gpuAlgo_, hostData_, iEvent, recoMuon::in, input, label_, eostools::move(), TestCUDAProducerGPUKernel::runAlgo(), and srcToken_.

◆ fillDescriptions()

void TestCUDAProducerGPUEW::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 51 of file TestCUDAProducerGPUEW.cc.

51  {
53  desc.add<edm::InputTag>("src", edm::InputTag());
54  descriptions.addWithDefaultLabel(desc);
55  descriptions.setComment(
56  "This EDProducer is part of the TestCUDAProducer* family. It models a GPU algorithm this is not the first "
57  "algorithm in the chain of the GPU EDProducers, and that transfers some data from GPU to CPU and thus needs to "
58  "synchronize GPU and CPU. The synchronization is implemented with the ExternalWork extension. Produces "
59  "cms::cuda::Product<cms::cuda::Thing>.");
60 }

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, HLT_FULL_cff::InputTag, and edm::ConfigurationDescriptions::setComment().

◆ produce()

void TestCUDAProducerGPUEW::produce ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
override

Definition at line 82 of file TestCUDAProducerGPUEW.cc.

82  {
83  edm::LogVerbatim("TestCUDAProducerGPUEW")
84  << label_ << " TestCUDAProducerGPUEW::produce begin event " << iEvent.id().event() << " stream "
85  << iEvent.streamID() << " 10th element " << *hostData_;
86 
88 
89  ctx.emplace(iEvent, dstToken_, std::move(devicePtr_));
90 
91  edm::LogVerbatim("TestCUDAProducerGPUEW") << label_ << " TestCUDAProducerGPUEW::produce end event "
92  << iEvent.id().event() << " stream " << iEvent.streamID();
93 }

References ctxState_, devicePtr_, dstToken_, hostData_, iEvent, label_, and eostools::move().

Member Data Documentation

◆ ctxState_

cms::cuda::ContextState TestCUDAProducerGPUEW::ctxState_
private

Definition at line 36 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire(), and produce().

◆ devicePtr_

cms::cuda::device::unique_ptr<float[]> TestCUDAProducerGPUEW::devicePtr_
private

Definition at line 37 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire(), and produce().

◆ dstToken_

const edm::EDPutTokenT<cms::cuda::Product<cms::cudatest::Thing> > TestCUDAProducerGPUEW::dstToken_
private

Definition at line 34 of file TestCUDAProducerGPUEW.cc.

Referenced by produce().

◆ gpuAlgo_

TestCUDAProducerGPUKernel TestCUDAProducerGPUEW::gpuAlgo_
private

Definition at line 35 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire().

◆ hostData_

cms::cuda::host::noncached::unique_ptr<float> TestCUDAProducerGPUEW::hostData_
private

Definition at line 38 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire(), and produce().

◆ label_

const std::string TestCUDAProducerGPUEW::label_
private

◆ srcToken_

const edm::EDGetTokenT<cms::cuda::Product<cms::cudatest::Thing> > TestCUDAProducerGPUEW::srcToken_
private

Definition at line 33 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire().

TestCUDAProducerGPUEW::devicePtr_
cms::cuda::device::unique_ptr< float[]> devicePtr_
Definition: TestCUDAProducerGPUEW.cc:37
TestCUDAProducerGPUEW::hostData_
cms::cuda::host::noncached::unique_ptr< float > hostData_
Definition: TestCUDAProducerGPUEW.cc:38
TestCUDAProducerGPUEW::ctxState_
cms::cuda::ContextState ctxState_
Definition: TestCUDAProducerGPUEW.cc:36
input
static const std::string input
Definition: EdmProvDump.cc:48
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
TestCUDAProducerGPUKernel::runAlgo
cms::cuda::device::unique_ptr< float[]> runAlgo(const std::string &label, cudaStream_t stream) const
Definition: TestCUDAProducerGPUKernel.h:27
cms::cuda::ScopedContextProduce
Definition: ScopedContext.h:149
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:47
TestCUDAProducerGPUEW::gpuAlgo_
TestCUDAProducerGPUKernel gpuAlgo_
Definition: TestCUDAProducerGPUEW.cc:35
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TestCUDAProducerGPUEW::dstToken_
const edm::EDPutTokenT< cms::cuda::Product< cms::cudatest::Thing > > dstToken_
Definition: TestCUDAProducerGPUEW.cc:34
TestCUDAProducerGPUEW::label_
const std::string label_
Definition: TestCUDAProducerGPUEW.cc:32
TestCUDAProducerGPUEW::srcToken_
const edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > srcToken_
Definition: TestCUDAProducerGPUEW.cc:33
edm::ConfigurationDescriptions::setComment
void setComment(std::string const &value)
Definition: ConfigurationDescriptions.cc:48
recoMuon::in
Definition: RecoMuonEnumerators.h:6
cms::cudatest::Thing
Definition: Thing.h:8
edm::Service
Definition: Service.h:30
iEvent
int iEvent
Definition: GenABIO.cc:224
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cms::cuda::ScopedContextAcquire
Definition: ScopedContext.h:101
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
cudaCheck
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
edm::InputTag
Definition: InputTag.h:15
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:87