diff --git a/algo/detectors/sts/StsHitfinderChain.cxx b/algo/detectors/sts/StsHitfinderChain.cxx index f38562ed957729524b5c711df68e2cfe5bebf950..e2eddc103d10cc9f1c626cf0ce9cf8058302f93d 100644 --- a/algo/detectors/sts/StsHitfinderChain.cxx +++ b/algo/detectors/sts/StsHitfinderChain.cxx @@ -15,6 +15,14 @@ void sts::HitfinderChain::SetParameters(const sts::HitfinderPars& parameters) AllocateStatic(); } +void sts::HitfinderChain::Finalize() +{ + // Explicitly free buffers in constant memory. + // This avoids an issue in xpu with teardown order of static variables when using CPU. + fHitfinder = {}; + xpu::set<TheHitfinder>(fHitfinder); +} + void sts::HitfinderChain::operator()(gsl::span<const CbmStsDigi> digis) { EnsureParameters(); diff --git a/algo/detectors/sts/StsHitfinderChain.h b/algo/detectors/sts/StsHitfinderChain.h index 7676a05f1710b9efd573cb7572cc4551c54ff477..46e59f733e79c9ff9c9517567c26b6edc36a8c40 100644 --- a/algo/detectors/sts/StsHitfinderChain.h +++ b/algo/detectors/sts/StsHitfinderChain.h @@ -43,6 +43,11 @@ namespace cbm::algo::sts void SetParameters(const sts::HitfinderPars& parameters); const sts::HitfinderPars& GetParameters() const { return *fPars; } + /** + * Teardown chain. + */ + void Finalize(); + void operator()(gsl::span<const CbmStsDigi>); private: diff --git a/algo/global/Reco.cxx b/algo/global/Reco.cxx index b8c5b8bc244bc56b9071014ba2ef5e05e921fdf7..0d3c0ffc506e0d30d9429a54bebeeac62caedc73 100644 --- a/algo/global/Reco.cxx +++ b/algo/global/Reco.cxx @@ -106,6 +106,8 @@ void Reco::Run(const fles::Timeslice& ts) void Reco::Finalize() { + fStsHitFinder.Finalize(); + // Pop timer that was started in Init() xpu::timings t = xpu::pop_timer(); if (Opts().CollectKernelTimes()) {