CMS 3D CMS Logo

SiStripClustersSOAtoHost.cc
Go to the documentation of this file.
1 /*
2  */
4 
14 
16 
18 
19 #include <memory>
20 
22 public:
23  SiStripSOAtoHost() = default;
24  void makeAsync(const SiStripClustersCUDADevice& clusters_d, cudaStream_t stream) {
25  hostView_ = std::make_unique<SiStripClustersCUDAHost>(clusters_d, stream);
26  }
27  std::unique_ptr<SiStripClustersCUDAHost> getResults() { return std::move(hostView_); }
28 
29 private:
30  std::unique_ptr<SiStripClustersCUDAHost> hostView_;
31 };
32 
33 class SiStripClustersSOAtoHost final : public edm::stream::EDProducer<edm::ExternalWork> {
34 public:
36  : inputToken_(
37  consumes<cms::cuda::Product<SiStripClustersCUDADevice>>(conf.getParameter<edm::InputTag>("ProductLabel"))),
39 
40  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
42 
43  desc.add("ProductLabel", edm::InputTag("siStripClusterizerFromRawGPU"));
44  descriptions.addWithDefaultLabel(desc);
45  }
46 
47 private:
48  void acquire(edm::Event const& ev,
49  edm::EventSetup const& es,
50  edm::WaitingTaskWithArenaHolder waitingTaskHolder) override {
51  const auto& wrapper = ev.get(inputToken_);
52 
53  // Sets the current device and creates a CUDA stream
54  cms::cuda::ScopedContextAcquire ctx{wrapper, std::move(waitingTaskHolder)};
55 
56  const auto& input = ctx.get(wrapper);
57 
58  // Queues asynchronous data transfers and kernels to the CUDA stream
59  // returned by cms::cuda::ScopedContextAcquire::stream()
60  gpuAlgo_.makeAsync(input, ctx.stream());
61 
62  // Destructor of ctx queues a callback to the CUDA stream notifying
63  // waitingTaskHolder when the queued asynchronous work has finished
64  }
65 
66  void produce(edm::Event& ev, const edm::EventSetup& es) override { ev.put(gpuAlgo_.getResults()); }
67 
68 private:
70 
73 };
74 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void acquire(edm::Event const &ev, edm::EventSetup const &es, edm::WaitingTaskWithArenaHolder waitingTaskHolder) override
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
static std::string const input
Definition: EdmProvDump.cc:50
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
SiStripSOAtoHost()=default
std::unique_ptr< SiStripClustersCUDAHost > getResults()
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDPutTokenT< SiStripClustersCUDAHost > outputToken_
Namespace of DDCMS conversion namespace.
edm::EDGetTokenT< cms::cuda::Product< SiStripClustersCUDADevice > > inputToken_
void produce(edm::Event &ev, const edm::EventSetup &es) override
HLT enums.
SiStripClustersSOAtoHost(const edm::ParameterSet &conf)
std::unique_ptr< SiStripClustersCUDAHost > hostView_
void makeAsync(const SiStripClustersCUDADevice &clusters_d, cudaStream_t stream)
def move(src, dest)
Definition: eostools.py:511
static HepMC::HEPEVT_Wrapper wrapper