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
 
 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::host::unique_ptr< float[]> buffer_
 
edm::EDPutTokenT< int > const dstToken_
 
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 16 of file TestCUDAProducerGPUtoCPU.cc.

Constructor & Destructor Documentation

◆ TestCUDAProducerGPUtoCPU()

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

Definition at line 36 of file TestCUDAProducerGPUtoCPU.cc.

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

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>()} {}
edm::EDPutTokenT< int > const dstToken_
edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > const srcToken_

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

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

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 }
const float * get() const
Definition: Thing.h:13
Log< level::Info, true > LogVerbatim
cms::cuda::host::unique_ptr< float[]> buffer_
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< cms::cuda::Product< cms::cudatest::Thing > > const srcToken_
#define cudaCheck(ARG,...)
Definition: cudaCheck.h:69
def move(src, dest)
Definition: eostools.py:511

◆ fillDescriptions()

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

Definition at line 41 of file TestCUDAProducerGPUtoCPU.cc.

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

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

◆ produce()

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

Definition at line 72 of file TestCUDAProducerGPUtoCPU.cc.

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

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 }
Log< level::Info, true > LogVerbatim
cms::cuda::host::unique_ptr< float[]> buffer_
int iEvent
Definition: GenABIO.cc:224
edm::EDPutTokenT< int > const dstToken_
static std::atomic< unsigned int > counter

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_

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

Definition at line 32 of file TestCUDAProducerGPUtoCPU.cc.

Referenced by produce().

◆ label_

std::string const TestCUDAProducerGPUtoCPU::label_
private

◆ srcToken_

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

Definition at line 31 of file TestCUDAProducerGPUtoCPU.cc.

Referenced by acquire().