CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #undef PIXEL_DEBUG_PRODUCE
21 
22 class PixelTrackSoAFromCUDA : public edm::stream::EDProducer<edm::ExternalWork> {
23 public:
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  std::cout << "size of SoA" << sizeof(tsoa) << " stride " << maxTracks << std::endl;
67 
68  int32_t nt = 0;
69  for (int32_t it = 0; it < maxTracks; ++it) {
70  auto nHits = tsoa.nHits(it);
71  assert(nHits == int(tsoa.hitIndices.size(it)));
72  if (nHits == 0)
73  break; // this is a guard: maybe we need to move to nTracks...
74  nt++;
75  }
76  std::cout << "found " << nt << " tracks in cpu SoA at " << &tsoa << std::endl;
77 #endif
78 
79  // DO NOT make a copy (actually TWO....)
81 
82  assert(!soa_);
83 }
84 
~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
def move
Definition: eostools.py:511
bool get(ProductID const &oid, Handle< PROD > &result) const
Definition: Event.h:346
ParameterDescriptionBase * add(U const &iLabel, T const &value)
int nt
Definition: AMPTWrapper.h:42
OrphanHandle< PROD > emplace(EDPutTokenT< PROD > token, Args &&...args)
puts a new product
Definition: Event.h:433
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
std::unique_ptr< T, impl::HostDeleter > unique_ptr
tuple cout
Definition: gather_cfg.py:144