diff --git a/DataFormats/TrackingRecHitSoA/interface/alpaka/TrackingRecHitsSoACollection.h b/DataFormats/TrackingRecHitSoA/interface/alpaka/TrackingRecHitsSoACollection.h index da3c3bef3928d..3374863ea1327 100644 --- a/DataFormats/TrackingRecHitSoA/interface/alpaka/TrackingRecHitsSoACollection.h +++ b/DataFormats/TrackingRecHitSoA/interface/alpaka/TrackingRecHitsSoACollection.h @@ -34,6 +34,16 @@ namespace cms::alpakatools { template static auto copyAsync(TQueue& queue, TrackingRecHitDevice const& deviceData) { TrackingRecHitHost hostData(queue, deviceData.view().metadata().size()); + + // Don't bother if zero hits + if (deviceData.view().metadata().size() == 0) { + std::memset(hostData.buffer().data(), + 0, + alpaka::getExtentProduct(hostData.buffer()) * + sizeof(alpaka::Elem::Buffer>)); + return hostData; + } + alpaka::memcpy(queue, hostData.buffer(), deviceData.buffer()); #ifdef GPU_DEBUG printf("TrackingRecHitsSoACollection: I'm copying to host.\n"); diff --git a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc index c6615c08d73bf..0abb5d2b1bbc6 100644 --- a/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc +++ b/RecoTracker/PixelSeeding/plugins/alpaka/CAHitNtupletGenerator.cc @@ -299,6 +299,10 @@ namespace ALPAKA_ACCELERATOR_NAMESPACE { TrackSoA tracks(queue); + // Don't bother if less than 2 this + if (hits_d.view().metadata().size() < 2) + return tracks; + GPUKernels kernels(m_params, hits_d.view().metadata().size(), hits_d.offsetBPIX2(), queue); kernels.buildDoublets(hits_d.view(), hits_d.offsetBPIX2(), queue);