CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 ( edm::ParameterSet const &  iConfig)
explicit

Definition at line 41 of file TestCUDAProducerGPUEW.cc.

References fwrapper::cs, dstToken_, CUDAService::enabled(), edm::ParameterSet::getParameter(), hostData_, srcToken_, 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 (cs->enabled()) {
47  hostData_ = cms::cuda::make_host_noncached_unique<float>();
48  }
49 }
unique_ptr< ClusterSequence > cs
bool enabled() const
Definition: CUDAService.h:22
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 ( )
overridedefault

Member Function Documentation

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_, edm::EventID::event(), cms::cudatest::Thing::get(), edm::Event::get(), gpuAlgo_, hostData_, edm::EventBase::id(), recoMuon::in, input, label_, eostools::move(), TestCUDAProducerGPUKernel::runAlgo(), srcToken_, and edm::Event::streamID().

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
const float * get() const
Definition: Thing.h:13
cms::cuda::device::unique_ptr< float[]> devicePtr_
static std::string const input
Definition: EdmProvDump.cc:47
cms::cuda::device::unique_ptr< float[]> runAlgo(const std::string &label, cudaStream_t stream) const
int iEvent
Definition: GenABIO.cc:224
def move
Definition: eostools.py:511
cms::cuda::host::noncached::unique_ptr< float > hostData_
TestCUDAProducerGPUKernel gpuAlgo_
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > const srcToken_
cms::cuda::ContextState ctxState_
void TestCUDAProducerGPUEW::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 51 of file TestCUDAProducerGPUEW.cc.

References edm::ParameterSetDescription::add(), edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, HLT_FULL_cff::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)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void setComment(std::string const &value)
void TestCUDAProducerGPUEW::produce ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
override

Definition at line 82 of file TestCUDAProducerGPUEW.cc.

References ctxState_, devicePtr_, dstToken_, edm::EventID::event(), hostData_, edm::EventBase::id(), label_, eostools::move(), and edm::Event::streamID().

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
EventNumber_t event() const
Definition: EventID.h:40
cms::cuda::device::unique_ptr< float[]> devicePtr_
def move
Definition: eostools.py:511
edm::EDPutTokenT< cms::cuda::Product< cms::cudatest::Thing > > const dstToken_
cms::cuda::host::noncached::unique_ptr< float > hostData_
edm::EventID id() const
Definition: EventBase.h:59
StreamID streamID() const
Definition: Event.h:98
cms::cuda::ContextState ctxState_

Member Data Documentation

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

Definition at line 36 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire(), and produce().

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

Definition at line 37 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire(), and produce().

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

Definition at line 34 of file TestCUDAProducerGPUEW.cc.

Referenced by produce(), and TestCUDAProducerGPUEW().

TestCUDAProducerGPUKernel TestCUDAProducerGPUEW::gpuAlgo_
private

Definition at line 35 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire().

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

Definition at line 38 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire(), produce(), and TestCUDAProducerGPUEW().

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

Definition at line 33 of file TestCUDAProducerGPUEW.cc.

Referenced by acquire(), and TestCUDAProducerGPUEW().