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_
 
edm::EDPutTokenT< cms::cuda::Product< cms::cudatest::Thing > > const dstToken_
 
TestCUDAProducerGPUKernel gpuAlgo_
 
cms::cuda::host::noncached::unique_ptr< float > hostData_
 
std::string const label_
 
edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > const 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.

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

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 (cuda and cuda->enabled()) {
47  hostData_ = cms::cuda::make_host_noncached_unique<float>();
48  }
49 }
edm::EDPutTokenT< cms::cuda::Product< cms::cudatest::Thing > > const dstToken_
cms::cuda::host::noncached::unique_ptr< float > hostData_
edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > const srcToken_

◆ ~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.

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

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 }
Log< level::Info, true > LogVerbatim
cms::cuda::device::unique_ptr< float[]> devicePtr_
static std::string const input
Definition: EdmProvDump.cc:50
int iEvent
Definition: GenABIO.cc:224
cms::cuda::host::noncached::unique_ptr< float > hostData_
TestCUDAProducerGPUKernel gpuAlgo_
cms::cuda::device::unique_ptr< float[]> runAlgo(const std::string &label, cudaStream_t stream) const
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > const srcToken_
cms::cuda::ContextState ctxState_
def move(src, dest)
Definition: eostools.py:511

◆ fillDescriptions()

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

Definition at line 51 of file TestCUDAProducerGPUEW.cc.

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

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 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void setComment(std::string const &value)

◆ produce()

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

Definition at line 82 of file TestCUDAProducerGPUEW.cc.

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

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 }
Log< level::Info, true > LogVerbatim
cms::cuda::device::unique_ptr< float[]> devicePtr_
int iEvent
Definition: GenABIO.cc:224
edm::EDPutTokenT< cms::cuda::Product< cms::cudatest::Thing > > const dstToken_
cms::cuda::host::noncached::unique_ptr< float > hostData_
cms::cuda::ContextState ctxState_
def move(src, dest)
Definition: eostools.py:511

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_

edm::EDPutTokenT<cms::cuda::Product<cms::cudatest::Thing> > const 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_

std::string const TestCUDAProducerGPUEW::label_
private

◆ srcToken_

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

Definition at line 33 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire().