CMS 3D CMS Logo

PixelTrackSoAFromCUDA.cc
Go to the documentation of this file.
1 #include <cuda_runtime.h>
2 
18 
19 // Switch on to enable checks and printout for found tracks
20 // #define PIXEL_DEBUG_PRODUCE
21 
22 class PixelTrackSoAFromCUDA : public edm::stream::EDProducer<edm::ExternalWork> {
23 public:
24  explicit PixelTrackSoAFromCUDA(const edm::ParameterSet& iConfig);
25  ~PixelTrackSoAFromCUDA() override = default;
26 
27  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
28 
29 private:
30  void acquire(edm::Event const& iEvent,
31  edm::EventSetup const& iSetup,
32  edm::WaitingTaskWithArenaHolder waitingTaskHolder) override;
33  void produce(edm::Event& iEvent, edm::EventSetup const& iSetup) override;
34 
37 
39 };
40 
42  : tokenCUDA_(consumes<cms::cuda::Product<PixelTrackHeterogeneous>>(iConfig.getParameter<edm::InputTag>("src"))),
43  tokenSOA_(produces<PixelTrackHeterogeneous>()) {}
44 
47 
48  desc.add<edm::InputTag>("src", edm::InputTag("pixelTracksCUDA"));
49  descriptions.add("pixelTracksSoA", desc);
50 }
51 
53  edm::EventSetup const& iSetup,
54  edm::WaitingTaskWithArenaHolder waitingTaskHolder) {
55  cms::cuda::Product<PixelTrackHeterogeneous> const& inputDataWrapped = iEvent.get(tokenCUDA_);
56  cms::cuda::ScopedContextAcquire ctx{inputDataWrapped, std::move(waitingTaskHolder)};
57  auto const& inputData = ctx.get(inputDataWrapped);
58 
59  soa_ = inputData.toHostAsync(ctx.stream());
60 }
61 
63 #ifdef PIXEL_DEBUG_PRODUCE
64  auto const& tsoa = *soa_;
65  auto maxTracks = tsoa.stride();
66  auto nTracks = tsoa.nTracks();
67  std::cout << "size of SoA " << sizeof(tsoa) << " stride " << maxTracks << std::endl;
68  std::cout << "found " << nTracks << " tracks in cpu SoA at " << &tsoa << std::endl;
69 
70  int32_t nt = 0;
71  for (int32_t it = 0; it < maxTracks; ++it) {
72  auto nHits = tsoa.nHits(it);
73  assert(nHits == int(tsoa.hitIndices.size(it)));
74  if (nHits == 0)
75  break; // this is a guard: maybe we need to move to nTracks...
76  nt++;
77  }
78  assert(nTracks == nt);
79 #endif
80 
81  // DO NOT make a copy (actually TWO....)
83 
84  assert(!soa_);
85 }
86 
~PixelTrackSoAFromCUDA() override=default
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void acquire(edm::Event const &iEvent, edm::EventSetup const &iSetup, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
edm::EDPutTokenT< PixelTrackHeterogeneous > tokenSOA_
void produce(edm::Event &iEvent, edm::EventSetup const &iSetup) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
HeterogeneousSoA< pixelTrack::TrackSoA > PixelTrackHeterogeneous
PixelTrackSoAFromCUDA(const edm::ParameterSet &iConfig)
cms::cuda::host::unique_ptr< pixelTrack::TrackSoA > soa_
assert(be >=bs)
int iEvent
Definition: GenABIO.cc:224
int nt
Definition: AMPTWrapper.h:42
Namespace of DDCMS conversion namespace.
edm::EDGetTokenT< cms::cuda::Product< PixelTrackHeterogeneous > > tokenCUDA_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
caConstants::TupleMultiplicity const CAHitNtupletGeneratorKernelsGPU::HitToTuple const cms::cuda::AtomicPairCounter GPUCACell const *__restrict__ uint32_t const *__restrict__ gpuPixelDoublets::CellNeighborsVector const gpuPixelDoublets::CellTracksVector const GPUCACell::OuterHitOfCell const int32_t nHits
HLT enums.
std::unique_ptr< T, impl::HostDeleter > unique_ptr
def move(src, dest)
Definition: eostools.py:511