CMS 3D CMS Logo

PixelTrackSoAFromCUDA.cc
Go to the documentation of this file.
1 #include <cuda_runtime.h>
2 
19 
20 // Switch on to enable checks and printout for found tracks
21 #undef PIXEL_DEBUG_PRODUCE
22 
23 class PixelTrackSoAFromCUDA : public edm::stream::EDProducer<edm::ExternalWork> {
24 public:
25  explicit PixelTrackSoAFromCUDA(const edm::ParameterSet& iConfig);
26  ~PixelTrackSoAFromCUDA() override = default;
27 
28  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
29 
30 private:
31  void acquire(edm::Event const& iEvent,
32  edm::EventSetup const& iSetup,
33  edm::WaitingTaskWithArenaHolder waitingTaskHolder) override;
34  void produce(edm::Event& iEvent, edm::EventSetup const& iSetup) override;
35 
38 
40 };
41 
43  : tokenCUDA_(consumes<cms::cuda::Product<PixelTrackHeterogeneous>>(iConfig.getParameter<edm::InputTag>("src"))),
44  tokenSOA_(produces<PixelTrackHeterogeneous>()) {}
45 
48 
49  desc.add<edm::InputTag>("src", edm::InputTag("caHitNtupletCUDA"));
50  descriptions.add("pixelTrackSoA", desc);
51 }
52 
54  edm::EventSetup const& iSetup,
55  edm::WaitingTaskWithArenaHolder waitingTaskHolder) {
56  cms::cuda::Product<PixelTrackHeterogeneous> const& inputDataWrapped = iEvent.get(tokenCUDA_);
57  cms::cuda::ScopedContextAcquire ctx{inputDataWrapped, std::move(waitingTaskHolder)};
58  auto const& inputData = ctx.get(inputDataWrapped);
59 
60  soa_ = inputData.toHostAsync(ctx.stream());
61 }
62 
64 #ifdef PIXEL_DEBUG_PRODUCE
65  auto const& tsoa = *soa_;
66  auto maxTracks = tsoa.stride();
67  std::cout << "size of SoA" << sizeof(tsoa) << " stride " << maxTracks << std::endl;
68 
69  int32_t nt = 0;
70  for (int32_t it = 0; it < maxTracks; ++it) {
71  auto nHits = tsoa.nHits(it);
72  assert(nHits == int(tsoa.hitIndices.size(it)));
73  if (nHits == 0)
74  break; // this is a guard: maybe we need to move to nTracks...
75  nt++;
76  }
77  std::cout << "found " << nt << " tracks in cpu SoA at " << &tsoa << std::endl;
78 #endif
79 
80  // DO NOT make a copy (actually TWO....)
82 
83  assert(!soa_);
84 }
85 
ConfigurationDescriptions.h
Handle.h
PixelTrackSoAFromCUDA::tokenSOA_
edm::EDPutTokenT< PixelTrackHeterogeneous > tokenSOA_
Definition: PixelTrackSoAFromCUDA.cc:37
PixelTrackSoAFromCUDA::~PixelTrackSoAFromCUDA
~PixelTrackSoAFromCUDA() override=default
ESHandle.h
nt
int nt
Definition: AMPTWrapper.h:42
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::EDPutTokenT
Definition: EDPutToken.h:33
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PixelTrackSoAFromCUDA::acquire
void acquire(edm::Event const &iEvent, edm::EventSetup const &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
Definition: PixelTrackSoAFromCUDA.cc:53
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
cms::cuda::assert
assert(be >=bs)
EDProducer.h
HostProduct.h
HeterogeneousSoA
Definition: HeterogeneousSoA.h:13
SiPixelRawToDigi_cfi.cuda
cuda
Definition: SiPixelRawToDigi_cfi.py:14
PixelTrackSoAFromCUDA::produce
void produce(edm::Event &iEvent, edm::EventSetup const &iSetup) override
Definition: PixelTrackSoAFromCUDA.cc:63
edm::WaitingTaskWithArenaHolder
Definition: WaitingTaskWithArenaHolder.h:34
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
nHits
const caConstants::TupleMultiplicity *__restrict__ const HitsOnGPU *__restrict__ double *__restrict__ float *__restrict__ double *__restrict__ uint32_t nHits
Definition: BrokenLineFitOnGPU.h:27
ParameterSetDescription.h
EDGetToken.h
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
PixelTrackSoAFromCUDA
Definition: PixelTrackSoAFromCUDA.cc:23
edm::ParameterSet
Definition: ParameterSet.h:47
PixelTrackSoAFromCUDA::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PixelTrackSoAFromCUDA.cc:46
Event.h
PixelTrackSoAFromCUDA::soa_
cms::cuda::host::unique_ptr< pixelTrack::TrackSoA > soa_
Definition: PixelTrackSoAFromCUDA.cc:39
HLT_FULL_cff.maxTracks
maxTracks
Definition: HLT_FULL_cff.py:33248
ModuleDef.h
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::stream::EDProducer
Definition: EDProducer.h:38
PixelTrackSoAFromCUDA::tokenCUDA_
edm::EDGetTokenT< cms::cuda::Product< PixelTrackHeterogeneous > > tokenCUDA_
Definition: PixelTrackSoAFromCUDA.cc:36
edm::EventSetup
Definition: EventSetup.h:58
InputTag.h
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
PixelTrackSoAFromCUDA::PixelTrackSoAFromCUDA
PixelTrackSoAFromCUDA(const edm::ParameterSet &iConfig)
Definition: PixelTrackSoAFromCUDA.cc:42
cms::cuda::host::unique_ptr
std::unique_ptr< T, impl::HostDeleter > unique_ptr
Definition: host_unique_ptr.h:21
cms::cuda::Product
Definition: Product.h:34
ScopedContext.h
EventSetup.h
PixelTrackHeterogeneous.h
ParameterSet.h
edm::Event
Definition: Event.h:73
PixelTrackHeterogeneous
HeterogeneousSoA< pixelTrack::TrackSoA > PixelTrackHeterogeneous
Definition: PixelTrackHeterogeneous.h:7
edm::InputTag
Definition: InputTag.h:15
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21