Skip to content

Commit

Permalink
Merge pull request #34749 from fwyzard/HCAL_GPU_modules_protect_for_e…
Browse files Browse the repository at this point in the history
…mpty_events_120x

Protect HCAL GPU-related modules against empty events [12.0.x]
  • Loading branch information
cmsbuild committed Aug 5, 2021
2 parents 2c9cc65 + 444c63e commit 3f7d8b5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions RecoLocalCalo/HcalRecProducers/src/HcalCPURecHitsProducer.cc
Expand Up @@ -76,6 +76,11 @@ void HcalCPURecHitsProducer::acquire(edm::Event const& event,
std::cout << "num rec Hits = " << recHits.size << std::endl;
#endif

// do not try to copy the rechits if they are empty
if (recHits.size == 0) {
return;
}

auto lambdaToTransfer = [&ctx](auto& dest, auto* src) {
using vector_type = typename std::remove_reference<decltype(dest)>::type;
using src_data_type = typename std::remove_pointer<decltype(src)>::type;
Expand Down
12 changes: 6 additions & 6 deletions RecoLocalCalo/HcalRecProducers/src/MahiGPU.cu
Expand Up @@ -1048,14 +1048,14 @@ namespace hcal {
cudaStream_t cudaStream) {
auto const totalChannels = inputGPU.f01HEDigis.size + inputGPU.f5HBDigis.size + inputGPU.f3HBDigis.size;

// protections when the detector is out
if (totalChannels == 0)
return;
// FIXME: the number of channels in output might change given that some channesl might be filtered out

// FIXME: may be move this assignment to emphasize this more clearly
// FIXME: number of channels for output might change given that
// some channesl might be filtered out
// do not run when there are no rechits (e.g. if HCAL is not being read),
// but do set the size of the output collection to 0
outputGPU.recHits.size = totalChannels;
if (totalChannels == 0) {
return;
}

// TODO: this can be lifted by implementing a separate kernel
// similar to the default one, but properly handling the diff in #sample
Expand Down

0 comments on commit 3f7d8b5

Please sign in to comment.