RecoLocalCalo
HGCalRecProducers
plugins
EERecHitGPUtoSoA.cc
Go to the documentation of this file.
1
#include <iostream>
2
#include <memory>
3
#include <chrono>
4
#include <cuda_runtime.h>
5
6
#include "
FWCore/Framework/interface/ESProducer.h
"
7
#include "
FWCore/Framework/interface/stream/EDProducer.h
"
8
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
9
#include "
FWCore/Utilities/interface/Exception.h
"
10
#include "
HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h
"
11
#include "
DataFormats/HGCRecHit/interface/HGCRecHit.h
"
12
#include "
DataFormats/HGCRecHit/interface/HGCRecHitCollections.h
"
13
#include "
DataFormats/ForwardDetId/interface/HGCSiliconDetId.h
"
14
#include "
FWCore/Utilities/interface/EDGetToken.h
"
15
#include "
FWCore/Utilities/interface/EDPutToken.h
"
16
#include "
FWCore/Utilities/interface/InputTag.h
"
17
18
#include "
RecoLocalCalo/HGCalRecAlgos/interface/RecHitTools.h
"
19
#include "
Geometry/HGCalGeometry/interface/HGCalGeometry.h
"
20
#include "
Geometry/HGCalCommonData/interface/HGCalDDDConstants.h
"
21
#include "
Geometry/HGCalCommonData/interface/HGCalWaferIndex.h
"
22
23
#include "
HeterogeneousCore/CUDACore/interface/ScopedContext.h
"
24
#include "
HeterogeneousCore/CUDACore/interface/ContextState.h
"
25
#include "
HeterogeneousCore/CUDAServices/interface/CUDAService.h
"
26
#include "
HeterogeneousCore/CUDAUtilities/interface/cudaCheck.h
"
27
28
#include "
FWCore/ServiceRegistry/interface/Service.h
"
29
#include "
CommonTools/UtilAlgos/interface/TFileService.h
"
30
#include "
RecoLocalCalo/HGCalRecProducers/plugins/KernelManagerHGCalRecHit.h
"
31
32
#include "
CUDADataFormats/HGCal/interface/HGCRecHitGPUProduct.h
"
33
#include "
CUDADataFormats/HGCal/interface/HGCRecHitCPUProduct.h
"
34
35
class
EERecHitGPUtoSoA
:
public
edm::stream::EDProducer
<edm::ExternalWork> {
36
public
:
37
explicit
EERecHitGPUtoSoA
(
const
edm::ParameterSet
& ps);
38
~EERecHitGPUtoSoA
()
override
;
39
40
void
acquire
(
edm::Event
const
&,
edm::EventSetup
const
&,
edm::WaitingTaskWithArenaHolder
)
override
;
41
void
produce
(
edm::Event
&,
const
edm::EventSetup
&)
override
;
42
43
private
:
44
cms::cuda::ContextState
ctxState_
;
45
edm::EDGetTokenT<cms::cuda::Product<HGCRecHitGPUProduct>
>
recHitGPUToken_
;
46
edm::EDPutTokenT<HGCRecHitCPUProduct>
recHitCPUSoAToken_
;
47
48
std::unique_ptr<HGCRecHitCPUProduct>
prodPtr_
;
49
};
50
51
EERecHitGPUtoSoA::EERecHitGPUtoSoA
(
const
edm::ParameterSet
& ps)
52
: recHitGPUToken_{consumes<cms::cuda::Product<HGCRecHitGPUProduct>>(
53
ps.
getParameter
<
edm::InputTag
>(
"EERecHitGPUTok"
))},
54
recHitCPUSoAToken_(produces<HGCRecHitCPUProduct>()) {}
55
56
EERecHitGPUtoSoA::~EERecHitGPUtoSoA
() {}
57
58
void
EERecHitGPUtoSoA::acquire
(
edm::Event
const
&
event
,
59
edm::EventSetup
const
&
setup
,
60
edm::WaitingTaskWithArenaHolder
w
) {
61
cms::cuda::ScopedContextAcquire
ctx{
event
.streamID(),
std::move
(
w
)};
62
const
auto
& gpuRecHits = ctx.get(
event
,
recHitGPUToken_
);
63
64
prodPtr_
= std::make_unique<HGCRecHitCPUProduct>(gpuRecHits.nHits(), ctx.stream());
65
66
HGCRecHitCPUProduct
& prod_ = *
prodPtr_
;
67
KernelManagerHGCalRecHit
km(prod_.get(), gpuRecHits.get());
68
km.
transfer_soa_to_host
(ctx.stream());
69
}
70
71
void
EERecHitGPUtoSoA::produce
(
edm::Event
&
event
,
const
edm::EventSetup
&
setup
) {
event
.put(
std::move
(
prodPtr_
)); }
72
73
#include "
FWCore/Framework/interface/MakerMacros.h
"
74
DEFINE_FWK_MODULE
(
EERecHitGPUtoSoA
);
EERecHitGPUtoSoA::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition:
EERecHitGPUtoSoA.cc:71
EERecHitGPUtoSoA
Definition:
EERecHitGPUtoSoA.cc:35
HGCRecHitCPUProduct
Definition:
HGCRecHitCPUProduct.h:12
HGCRecHitGPUProduct.h
edm::EDGetTokenT
Definition:
EDGetToken.h:33
edm::EDPutTokenT< HGCRecHitCPUProduct >
HGCSiliconDetId.h
RecHitTools.h
ESProducer.h
EERecHitGPUtoSoA::prodPtr_
std::unique_ptr< HGCRecHitCPUProduct > prodPtr_
Definition:
EERecHitGPUtoSoA.cc:48
EDProducer.h
KernelManagerHGCalRecHit
Definition:
KernelManagerHGCalRecHit.h:33
HGCRecHitCPUProduct.h
singleTopDQM_cfi.setup
setup
Definition:
singleTopDQM_cfi.py:37
EERecHitGPUtoSoA::recHitGPUToken_
edm::EDGetTokenT< cms::cuda::Product< HGCRecHitGPUProduct > > recHitGPUToken_
Definition:
EERecHitGPUtoSoA.cc:45
EERecHitGPUtoSoA::recHitCPUSoAToken_
edm::EDPutTokenT< HGCRecHitCPUProduct > recHitCPUSoAToken_
Definition:
EERecHitGPUtoSoA.cc:46
EERecHitGPUtoSoA::~EERecHitGPUtoSoA
~EERecHitGPUtoSoA() override
Definition:
EERecHitGPUtoSoA.cc:56
edm::WaitingTaskWithArenaHolder
Definition:
WaitingTaskWithArenaHolder.h:34
MakerMacros.h
HGCalWaferIndex.h
HGCRecHit.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
Service.h
w
const double w
Definition:
UKUtility.cc:23
KernelManagerHGCalRecHit.h
EDGetToken.h
TFileService.h
KernelManagerHGCalRecHit::transfer_soa_to_host
void transfer_soa_to_host(const cudaStream_t &)
cms::cuda::ContextState
Definition:
ContextState.h:15
HGCRecHitCollections.h
HGCalGeometry.h
edm::ParameterSet
Definition:
ParameterSet.h:47
EERecHitGPUtoSoA::acquire
void acquire(edm::Event const &, edm::EventSetup const &, edm::WaitingTaskWithArenaHolder) override
Definition:
EERecHitGPUtoSoA.cc:58
EDPutToken.h
cudaCheck.h
edm::stream::EDProducer
Definition:
EDProducer.h:38
edm::EventSetup
Definition:
EventSetup.h:58
InputTag.h
CUDAService.h
cms::cuda::ScopedContextAcquire
Definition:
ScopedContext.h:101
ContextState.h
eostools.move
def move(src, dest)
Definition:
eostools.py:511
ScopedContext.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
Exception.h
EERecHitGPUtoSoA::ctxState_
cms::cuda::ContextState ctxState_
Definition:
EERecHitGPUtoSoA.cc:44
HGCalDDDConstants.h
ParameterSet.h
EERecHitGPUtoSoA::EERecHitGPUtoSoA
EERecHitGPUtoSoA(const edm::ParameterSet &ps)
Definition:
EERecHitGPUtoSoA.cc:51
event
Definition:
event.py:1
edm::Event
Definition:
Event.h:73
edm::InputTag
Definition:
InputTag.h:15
Generated for CMSSW Reference Manual by
1.8.16