CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
TestCUDAProducerGPUtoCPU Class Reference
Inheritance diagram for TestCUDAProducerGPUtoCPU:
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, const edm::EventSetup &iSetup) override
 
 TestCUDAProducerGPUtoCPU (edm::ParameterSet const &iConfig)
 
 ~TestCUDAProducerGPUtoCPU () override=default
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::ExternalWork >
 EDProducer ()=default
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Attributes

cms::cuda::host::unique_ptr< float[]> buffer_
 
const edm::EDPutTokenT< int > dstToken_
 
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 >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 16 of file TestCUDAProducerGPUtoCPU.cc.

Constructor & Destructor Documentation

◆ TestCUDAProducerGPUtoCPU()

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

Definition at line 36 of file TestCUDAProducerGPUtoCPU.cc.

37  : label_{iConfig.getParameter<std::string>("@module_label")},
38  srcToken_{consumes<cms::cuda::Product<cms::cudatest::Thing>>(iConfig.getParameter<edm::InputTag>("src"))},
39  dstToken_{produces<int>()} {}

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

◆ ~TestCUDAProducerGPUtoCPU()

TestCUDAProducerGPUtoCPU::~TestCUDAProducerGPUtoCPU ( )
overridedefault

Member Function Documentation

◆ acquire()

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

Definition at line 50 of file TestCUDAProducerGPUtoCPU.cc.

52  {
53  edm::LogVerbatim("TestCUDAProducerGPUtoCPU") << label_ << " TestCUDAProducerGPUtoCPU::acquire begin event "
54  << iEvent.id().event() << " stream " << iEvent.streamID();
55 
56  auto const& in = iEvent.get(srcToken_);
57  cms::cuda::ScopedContextAcquire ctx{in, std::move(waitingTaskHolder)};
58  cms::cudatest::Thing const& device = ctx.get(in);
59 
60  buffer_ = cms::cuda::make_host_unique<float[]>(TestCUDAProducerGPUKernel::NUM_VALUES, ctx.stream());
61  // Enqueue async copy, continue in produce once finished
62  cudaCheck(cudaMemcpyAsync(buffer_.get(),
63  device.get(),
65  cudaMemcpyDeviceToHost,
66  ctx.stream()));
67 
68  edm::LogVerbatim("TestCUDAProducerGPUtoCPU") << label_ << " TestCUDAProducerGPUtoCPU::acquire end event "
69  << iEvent.id().event() << " stream " << iEvent.streamID();
70 }

References buffer_, cudaCheck, dqmMemoryStats::float, cms::cudatest::Thing::get(), iEvent, recoMuon::in, label_, eostools::move(), TestCUDAProducerGPUKernel::NUM_VALUES, and srcToken_.

◆ fillDescriptions()

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

Definition at line 41 of file TestCUDAProducerGPUtoCPU.cc.

41  {
43  desc.add<edm::InputTag>("src", edm::InputTag())->setComment("Source for cms::cuda::Product<cms::cudatest::Thing>.");
44  descriptions.addWithDefaultLabel(desc);
45  descriptions.setComment(
46  "This EDProducer is part of the TestCUDAProducer* family. It models the GPU->CPU data transfer and formatting of "
47  "the data to legacy data format. Produces int, to be compatible with TestCUDAProducerCPU.");
48 }

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

◆ produce()

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

Definition at line 72 of file TestCUDAProducerGPUtoCPU.cc.

72  {
73  edm::LogVerbatim("TestCUDAProducerGPUtoCPU") << label_ << " TestCUDAProducerGPUtoCPU::produce begin event "
74  << iEvent.id().event() << " stream " << iEvent.streamID();
75 
76  int counter = 0;
77  for (int i = 0; i < TestCUDAProducerGPUKernel::NUM_VALUES; ++i) {
78  counter += buffer_[i];
79  }
80  buffer_.reset(); // not so nice, but no way around?
81 
82  iEvent.emplace(dstToken_, counter);
83 
84  edm::LogVerbatim("TestCUDAProducerGPUtoCPU")
85  << label_ << " TestCUDAProducerGPUtoCPU::produce end event " << iEvent.id().event() << " stream "
86  << iEvent.streamID() << " result " << counter;
87 }

References buffer_, counter, dstToken_, mps_fire::i, iEvent, label_, and TestCUDAProducerGPUKernel::NUM_VALUES.

Member Data Documentation

◆ buffer_

cms::cuda::host::unique_ptr<float[]> TestCUDAProducerGPUtoCPU::buffer_
private

Definition at line 33 of file TestCUDAProducerGPUtoCPU.cc.

Referenced by acquire(), and produce().

◆ dstToken_

const edm::EDPutTokenT<int> TestCUDAProducerGPUtoCPU::dstToken_
private

Definition at line 32 of file TestCUDAProducerGPUtoCPU.cc.

Referenced by produce().

◆ label_

const std::string TestCUDAProducerGPUtoCPU::label_
private

◆ srcToken_

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

Definition at line 31 of file TestCUDAProducerGPUtoCPU.cc.

Referenced by acquire().

counter
Definition: counter.py:1
mps_fire.i
i
Definition: mps_fire.py:428
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
TestCUDAProducerGPUtoCPU::buffer_
cms::cuda::host::unique_ptr< float[]> buffer_
Definition: TestCUDAProducerGPUtoCPU.cc:33
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
TestCUDAProducerGPUKernel::NUM_VALUES
static constexpr int NUM_VALUES
Definition: TestCUDAProducerGPUKernel.h:21
TestCUDAProducerGPUtoCPU::dstToken_
const edm::EDPutTokenT< int > dstToken_
Definition: TestCUDAProducerGPUtoCPU.cc:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
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
iEvent
int iEvent
Definition: GenABIO.cc:224
TestCUDAProducerGPUtoCPU::label_
const std::string label_
Definition: TestCUDAProducerGPUtoCPU.cc:30
TestCUDAProducerGPUtoCPU::srcToken_
const edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > srcToken_
Definition: TestCUDAProducerGPUtoCPU.cc:31
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:17
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:62
cms::cudatest::Thing::get
const float * get() const
Definition: Thing.h:13
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