Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache the SiPixelFedCablingMapGPU across events #209

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class SiPixelRawToClusterHeterogeneous: public HeterogeneousEDProducer<heterogen
void produceCPU(edm::HeterogeneousEvent& iEvent, const edm::EventSetup& iSetup) override;

// GPU implementation
void beginStreamGPUCuda(edm::StreamID streamId, cuda::stream_t<>& cudaStream) override;
void acquireGPUCuda(const edm::HeterogeneousEvent& iEvent, const edm::EventSetup& iSetup, cuda::stream_t<>& cudaStream) override;
void produceGPUCuda(edm::HeterogeneousEvent& iEvent, const edm::EventSetup& iSetup, cuda::stream_t<>& cudaStream) override;
void convertGPUtoCPU(edm::Event& ev, unsigned int nDigis, pixelgpudetails::SiPixelRawToClusterGPUKernel::CPUData) const;
Expand Down Expand Up @@ -149,6 +150,7 @@ std::unique_ptr<PixelUnpackingRegions> regions_;

// GPU algo
pixelgpudetails::SiPixelRawToClusterGPUKernel gpuAlgo_;
std::optional<SiPixelFedCablingMapGPUWrapper::ModulesToUnpack> gpuModulesToUnpack_;
PixelDataFormatter::Errors errors_;

bool enableTransfer_;
Expand Down Expand Up @@ -311,6 +313,11 @@ const FEDRawDataCollection *SiPixelRawToClusterHeterogeneous::initialize(const e


// -----------------------------------------------------------------------------
void SiPixelRawToClusterHeterogeneous::beginStreamGPUCuda(edm::StreamID streamId, cuda::stream_t<>& cudaStream) {
// Allocate GPU resources here
gpuModulesToUnpack_.emplace(cudaStream);
}

void SiPixelRawToClusterHeterogeneous::produceCPU(edm::HeterogeneousEvent& ev, const edm::EventSetup& es)
{
const auto buffers = initialize(ev.event(), es);
Expand Down Expand Up @@ -462,14 +469,13 @@ void SiPixelRawToClusterHeterogeneous::produceCPU(edm::HeterogeneousEvent& ev, c
void SiPixelRawToClusterHeterogeneous::acquireGPUCuda(const edm::HeterogeneousEvent& ev, const edm::EventSetup& es, cuda::stream_t<>& cudaStream) {
const auto buffers = initialize(ev.event(), es);

auto gpuModulesToUnpack = SiPixelFedCablingMapGPUWrapper::ModulesToUnpack(cudaStream);
if (regions_) {
std::set<unsigned int> modules = *(regions_->modulesToUnpack());
gpuModulesToUnpack.fillAsync(*cablingMap_, modules, cudaStream);
auto const& modules = *(regions_->modulesToUnpack());
gpuModulesToUnpack_->fillAsync(*cablingMap_, modules, cudaStream);
}
else if(recordWatcherUpdatedSinceLastTransfer_) {
// If regions_ are disabled, it is enough to fill and transfer only if cablingMap has changed
gpuModulesToUnpack.fillAsync(*cablingMap_, std::set<unsigned int>(), cudaStream);
// If regions are disabled, it is enough to fill and transfer only if cablingMap has changed
gpuModulesToUnpack_->fillAsync(*cablingMap_, std::set<unsigned int>(), cudaStream);
recordWatcherUpdatedSinceLastTransfer_ = false;
}

Expand Down Expand Up @@ -548,7 +554,7 @@ void SiPixelRawToClusterHeterogeneous::acquireGPUCuda(const edm::HeterogeneousEv

} // end of for loop

gpuAlgo_.makeClustersAsync(gpuMap, gpuModulesToUnpack.get(), hgains->getGPUProductAsync(cudaStream),
gpuAlgo_.makeClustersAsync(gpuMap, gpuModulesToUnpack_->get(), hgains->getGPUProductAsync(cudaStream),
wordFedAppender,
wordCounterGPU, fedCounter, convertADCtoElectrons,
useQuality, includeErrors, enableTransfer_, debug, cudaStream);
Expand Down