EventFilter
SiPixelRawToDigi
plugins
SiPixelDigiErrorsSoAFromCUDA.cc
Go to the documentation of this file.
1
#include "
CUDADataFormats/Common/interface/Product.h
"
2
#include "
CUDADataFormats/SiPixelDigi/interface/SiPixelDigiErrorsCUDA.h
"
3
#include "
DataFormats/SiPixelRawData/interface/SiPixelErrorsSoA.h
"
4
#include "
FWCore/Framework/interface/EventSetup.h
"
5
#include "
FWCore/Framework/interface/Event.h
"
6
#include "
FWCore/Framework/interface/MakerMacros.h
"
7
#include "
FWCore/Framework/interface/stream/EDProducer.h
"
8
#include "
FWCore/ParameterSet/interface/ConfigurationDescriptions.h
"
9
#include "
FWCore/ParameterSet/interface/ParameterSetDescription.h
"
10
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
11
#include "
HeterogeneousCore/CUDACore/interface/ScopedContext.h
"
12
#include "
HeterogeneousCore/CUDAUtilities/interface/host_unique_ptr.h
"
13
14
class
SiPixelDigiErrorsSoAFromCUDA
:
public
edm::stream::EDProducer
<edm::ExternalWork> {
15
public
:
16
explicit
SiPixelDigiErrorsSoAFromCUDA
(
const
edm::ParameterSet
& iConfig);
17
~SiPixelDigiErrorsSoAFromCUDA
()
override
=
default
;
18
19
static
void
fillDescriptions
(
edm::ConfigurationDescriptions
& descriptions);
20
21
private
:
22
void
acquire
(
const
edm::Event
&
iEvent
,
23
const
edm::EventSetup
& iSetup,
24
edm::WaitingTaskWithArenaHolder
waitingTaskHolder)
override
;
25
void
produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup)
override
;
26
27
edm::EDGetTokenT<cms::cuda::Product<SiPixelDigiErrorsCUDA>
>
digiErrorGetToken_
;
28
edm::EDPutTokenT<SiPixelErrorsSoA>
digiErrorPutToken_
;
29
30
cms::cuda::host::unique_ptr<SiPixelErrorCompact[]>
data_
;
31
cms::cuda::SimpleVector<SiPixelErrorCompact>
error_
;
32
const
SiPixelFormatterErrors
*
formatterErrors_
=
nullptr
;
33
};
34
35
SiPixelDigiErrorsSoAFromCUDA::SiPixelDigiErrorsSoAFromCUDA
(
const
edm::ParameterSet
& iConfig)
36
: digiErrorGetToken_(
37
consumes<
cms
::
cuda
::Product<
SiPixelDigiErrorsCUDA
>>(iConfig.getParameter<
edm
::
InputTag
>(
"src"
))),
38
digiErrorPutToken_(produces<
SiPixelErrorsSoA
>()) {}
39
40
void
SiPixelDigiErrorsSoAFromCUDA::fillDescriptions
(
edm::ConfigurationDescriptions
& descriptions) {
41
edm::ParameterSetDescription
desc
;
42
desc
.add<
edm::InputTag
>(
"src"
,
edm::InputTag
(
"siPixelClustersCUDA"
));
43
descriptions.
addWithDefaultLabel
(
desc
);
44
}
45
46
void
SiPixelDigiErrorsSoAFromCUDA::acquire
(
const
edm::Event
&
iEvent
,
47
const
edm::EventSetup
& iSetup,
48
edm::WaitingTaskWithArenaHolder
waitingTaskHolder) {
49
// Do the transfer in a CUDA stream parallel to the computation CUDA stream
50
cms::cuda::ScopedContextAcquire
ctx{
iEvent
.streamID(),
std::move
(waitingTaskHolder)};
51
52
const
auto
& gpuDigiErrors = ctx.get(
iEvent
,
digiErrorGetToken_
);
53
54
auto
tmp
= gpuDigiErrors.dataErrorToHostAsync(ctx.stream());
55
error_
=
tmp
.first;
56
data_
=
std::move
(
tmp
.second);
57
formatterErrors_
= &(gpuDigiErrors.formatterErrors());
58
}
59
60
void
SiPixelDigiErrorsSoAFromCUDA::produce
(
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup) {
61
// The following line copies the data from the pinned host memory to
62
// regular host memory. In principle that feels unnecessary (why not
63
// just use the pinned host memory?). There are a few arguments for
64
// doing it though
65
// - Now can release the pinned host memory back to the (caching) allocator
66
// * if we'd like to keep the pinned memory, we'd need to also
67
// keep the CUDA stream around as long as that, or allow pinned
68
// host memory to be allocated without a CUDA stream
69
// - What if a CPU algorithm would produce the same SoA? We can't
70
// use cudaMallocHost without a GPU...
71
iEvent
.emplace(
digiErrorPutToken_
,
error_
.
size
(),
error_
.
data
(),
formatterErrors_
);
72
73
error_
= cms::cuda::make_SimpleVector<SiPixelErrorCompact>(0,
nullptr
);
74
data_
.reset();
75
formatterErrors_
=
nullptr
;
76
}
77
78
// define as framework plugin
79
DEFINE_FWK_MODULE
(
SiPixelDigiErrorsSoAFromCUDA
);
ConfigurationDescriptions.h
SiPixelDigiErrorsSoAFromCUDA::data_
cms::cuda::host::unique_ptr< SiPixelErrorCompact[]> data_
Definition:
SiPixelDigiErrorsSoAFromCUDA.cc:30
SiPixelDigiErrorsSoAFromCUDA::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition:
SiPixelDigiErrorsSoAFromCUDA.cc:40
SiPixelDigiErrorsSoAFromCUDA::digiErrorGetToken_
edm::EDGetTokenT< cms::cuda::Product< SiPixelDigiErrorsCUDA > > digiErrorGetToken_
Definition:
SiPixelDigiErrorsSoAFromCUDA.cc:27
cms::cuda::SimpleVector::data
constexpr const T * data() const
Definition:
SimpleVector.h:111
SiPixelDigiErrorsSoAFromCUDA::SiPixelDigiErrorsSoAFromCUDA
SiPixelDigiErrorsSoAFromCUDA(const edm::ParameterSet &iConfig)
Definition:
SiPixelDigiErrorsSoAFromCUDA.cc:35
edm::EDGetTokenT
Definition:
EDGetToken.h:33
edm
HLT enums.
Definition:
AlignableModifier.h:19
SiPixelDigiErrorsSoAFromCUDA::~SiPixelDigiErrorsSoAFromCUDA
~SiPixelDigiErrorsSoAFromCUDA() override=default
edm::EDPutTokenT< SiPixelErrorsSoA >
HLT_FULL_cff.InputTag
InputTag
Definition:
HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition:
ParameterSetDescription.h:52
SiPixelDigiErrorsSoAFromCUDA::produce
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
Definition:
SiPixelDigiErrorsSoAFromCUDA.cc:60
EDProducer.h
createJobs.tmp
tmp
align.sh
Definition:
createJobs.py:716
cms::cuda::SimpleVector< SiPixelErrorCompact >
edm::WaitingTaskWithArenaHolder
Definition:
WaitingTaskWithArenaHolder.h:34
MakerMacros.h
SiPixelDigiErrorsSoAFromCUDA
Definition:
SiPixelDigiErrorsSoAFromCUDA.cc:14
SiPixelDigiErrorsSoAFromCUDA::acquire
void acquire(const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
Definition:
SiPixelDigiErrorsSoAFromCUDA.cc:46
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
host_unique_ptr.h
SiPixelDigiErrorsCUDA
Definition:
SiPixelDigiErrorsCUDA.h:12
ParameterSetDescription.h
SiPixelDigiErrorsSoAFromCUDA::error_
cms::cuda::SimpleVector< SiPixelErrorCompact > error_
Definition:
SiPixelDigiErrorsSoAFromCUDA.cc:31
edm::ConfigurationDescriptions
Definition:
ConfigurationDescriptions.h:28
SiPixelDigiErrorsSoAFromCUDA::digiErrorPutToken_
edm::EDPutTokenT< SiPixelErrorsSoA > digiErrorPutToken_
Definition:
SiPixelDigiErrorsSoAFromCUDA.cc:28
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::stream::EDProducer
Definition:
EDProducer.h:38
SiPixelDigiErrorsCUDA.h
edm::EventSetup
Definition:
EventSetup.h:58
SiPixelErrorsSoA
Definition:
SiPixelErrorsSoA.h:10
cms::cuda::ScopedContextAcquire
Definition:
ScopedContext.h:101
Product.h
submitPVResolutionJobs.desc
string desc
Definition:
submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition:
eostools.py:511
SiPixelErrorsSoA.h
cms::cuda::host::unique_ptr
std::unique_ptr< T, impl::HostDeleter > unique_ptr
Definition:
host_unique_ptr.h:21
ScopedContext.h
ecalDigis_cff.cuda
cuda
Definition:
ecalDigis_cff.py:35
EventSetup.h
SiPixelFormatterErrors
std::map< cms_uint32_t, std::vector< SiPixelRawDataError > > SiPixelFormatterErrors
Definition:
SiPixelFormatterErrors.h:10
ParameterSet.h
edm::Event
Definition:
Event.h:73
cms::cuda::SimpleVector::size
constexpr int size() const
Definition:
SimpleVector.h:109
SiPixelDigiErrorsSoAFromCUDA::formatterErrors_
const SiPixelFormatterErrors * formatterErrors_
Definition:
SiPixelDigiErrorsSoAFromCUDA.cc:32
edm::InputTag
Definition:
InputTag.h:15
edm::ConfigurationDescriptions::addWithDefaultLabel
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
Definition:
ConfigurationDescriptions.cc:87
cms
Namespace of DDCMS conversion namespace.
Definition:
ProducerAnalyzer.cc:21
Generated for CMSSW Reference Manual by
1.8.16