File indexing completed on 2024-04-06 12:26:27
0001
0002
0003 #include "DataFormats/SiStripCluster/interface/SiStripCluster.h"
0004
0005 #include "FWCore/Framework/interface/stream/EDProducer.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0008 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0009 #include "FWCore/Utilities/interface/InputTag.h"
0010 #include "FWCore/Framework/interface/Event.h"
0011 #include "FWCore/Framework/interface/EventSetup.h"
0012 #include "FWCore/Framework/interface/ESHandle.h"
0013 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0014
0015 #include "HeterogeneousCore/CUDACore/interface/ScopedContext.h"
0016
0017 #include "CUDADataFormats/SiStripCluster/interface/SiStripClustersCUDA.h"
0018
0019 #include <memory>
0020
0021 class SiStripSOAtoHost {
0022 public:
0023 SiStripSOAtoHost() = default;
0024 void makeAsync(const SiStripClustersCUDADevice& clusters_d, cudaStream_t stream) {
0025 hostView_ = std::make_unique<SiStripClustersCUDAHost>(clusters_d, stream);
0026 }
0027 std::unique_ptr<SiStripClustersCUDAHost> getResults() { return std::move(hostView_); }
0028
0029 private:
0030 std::unique_ptr<SiStripClustersCUDAHost> hostView_;
0031 };
0032
0033 class SiStripClustersSOAtoHost final : public edm::stream::EDProducer<edm::ExternalWork> {
0034 public:
0035 explicit SiStripClustersSOAtoHost(const edm::ParameterSet& conf)
0036 : inputToken_(
0037 consumes<cms::cuda::Product<SiStripClustersCUDADevice>>(conf.getParameter<edm::InputTag>("ProductLabel"))),
0038 outputToken_(produces<SiStripClustersCUDAHost>()) {}
0039
0040 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0041 edm::ParameterSetDescription desc;
0042
0043 desc.add("ProductLabel", edm::InputTag("siStripClusterizerFromRawGPU"));
0044 descriptions.addWithDefaultLabel(desc);
0045 }
0046
0047 private:
0048 void acquire(edm::Event const& ev,
0049 edm::EventSetup const& es,
0050 edm::WaitingTaskWithArenaHolder waitingTaskHolder) override {
0051 const auto& wrapper = ev.get(inputToken_);
0052
0053
0054 cms::cuda::ScopedContextAcquire ctx{wrapper, std::move(waitingTaskHolder)};
0055
0056 const auto& input = ctx.get(wrapper);
0057
0058
0059
0060 gpuAlgo_.makeAsync(input, ctx.stream());
0061
0062
0063
0064 }
0065
0066 void produce(edm::Event& ev, const edm::EventSetup& es) override { ev.put(gpuAlgo_.getResults()); }
0067
0068 private:
0069 SiStripSOAtoHost gpuAlgo_;
0070
0071 edm::EDGetTokenT<cms::cuda::Product<SiStripClustersCUDADevice>> inputToken_;
0072 edm::EDPutTokenT<SiStripClustersCUDAHost> outputToken_;
0073 };
0074
0075 #include "FWCore/Framework/interface/MakerMacros.h"
0076 DEFINE_FWK_MODULE(SiStripClustersSOAtoHost);