From f600144daee751c8b16eba7986d037b79cf2bdc0 Mon Sep 17 00:00:00 2001 From: Sandro Wenzel Date: Mon, 31 May 2021 10:22:39 +0200 Subject: [PATCH] Avoid inclusion of Vc/Vc in RandomRing Inclusiong of Vc/Vc is argued to cause gcc10 to take lot's of memory leading to crashes in the CI. In this particular case, I think we can avoid the inclusion og Vc/Vc in this header and leave it it to the source files to do so. (But this might not always be possible); --- .../MathUtils/include/MathUtils/RandomRing.h | 15 +++--- .../include/FDDSimulation/Digitizer.h | 4 +- .../FIT/FDD/simulation/src/Digitizer.cxx | 3 +- .../include/FT0Simulation/Digitizer.h | 46 +++---------------- .../FIT/FT0/simulation/src/Digitizer.cxx | 39 ++++++++++++++++ 5 files changed, 59 insertions(+), 48 deletions(-) diff --git a/Common/MathUtils/include/MathUtils/RandomRing.h b/Common/MathUtils/include/MathUtils/RandomRing.h index 37ed564772e54..a603e611ee492 100644 --- a/Common/MathUtils/include/MathUtils/RandomRing.h +++ b/Common/MathUtils/include/MathUtils/RandomRing.h @@ -28,21 +28,19 @@ #ifndef ALICEO2_MATHUTILS_RANDOMRING_H_ #define ALICEO2_MATHUTILS_RANDOMRING_H_ -#include "Vc/Vc" #include #include "TF1.h" #include "TRandom.h" #include -using float_v = Vc::float_v; namespace o2 { namespace math_utils { -template +template class RandomRing { public: @@ -92,10 +90,15 @@ class RandomRing /// used for vectorised programming and increases the buffer /// position by the size of the vector /// @return vector with random values - float_v getNextValueVc() + template + VcType getNextValueVc() { - const float_v value = float_v(&mRandomNumbers[mRingPosition]); - mRingPosition += float_v::size(); + // This function is templated so that we don't need to include the header + // within this header file (to reduce memory problems during compilation). + // The hope is that the calling user calls this with a + // correct Vc type (Vc::float_v) in a source file. + const VcType value = VcType(&mRandomNumbers[mRingPosition]); + mRingPosition += VcType::size(); if (mRingPosition >= mRandomNumbers.size()) { mRingPosition = 0; } diff --git a/Detectors/FIT/FDD/simulation/include/FDDSimulation/Digitizer.h b/Detectors/FIT/FDD/simulation/include/FDDSimulation/Digitizer.h index dec43aeb35737..3cca6624612dc 100644 --- a/Detectors/FIT/FDD/simulation/include/FDDSimulation/Digitizer.h +++ b/Detectors/FIT/FDD/simulation/include/FDDSimulation/Digitizer.h @@ -35,8 +35,8 @@ class Digitizer { private: - typedef math_utils::RandomRing HitRandomRingType; - typedef math_utils::RandomRing PheRandomRingType; + typedef math_utils::RandomRing HitRandomRingType; + typedef math_utils::RandomRing PheRandomRingType; using ChannelBCDataF = std::array; diff --git a/Detectors/FIT/FDD/simulation/src/Digitizer.cxx b/Detectors/FIT/FDD/simulation/src/Digitizer.cxx index 41929ad337052..62be756e9a056 100644 --- a/Detectors/FIT/FDD/simulation/src/Digitizer.cxx +++ b/Detectors/FIT/FDD/simulation/src/Digitizer.cxx @@ -17,6 +17,7 @@ #include #include #include +#include using namespace o2::math_utils; using namespace o2::fdd; @@ -138,7 +139,7 @@ void Digitizer::createPulse(int nPhE, int parID, double timeHit, std::array() * charge * pmtVc; workVc.store(p); p += Vc::float_v::Size; Vc::prefetchForOneRead(p); diff --git a/Detectors/FIT/FT0/simulation/include/FT0Simulation/Digitizer.h b/Detectors/FIT/FT0/simulation/include/FT0Simulation/Digitizer.h index 92ef13b2c674c..03ead1f18d894 100644 --- a/Detectors/FIT/FT0/simulation/include/FT0Simulation/Digitizer.h +++ b/Detectors/FIT/FT0/simulation/include/FT0Simulation/Digitizer.h @@ -37,7 +37,7 @@ class Digitizer { private: using DP = DigitizationConstants; - typedef math_utils::RandomRing NoiseRandomRingType; + typedef math_utils::RandomRing NoiseRandomRingType; public: Digitizer(Int_t mode = 0) : mMode(mode), mRndGaus(NoiseRandomRingType::RandomType::Gaus), mNumNoiseSamples(), mNoiseSamples(), mSincTable(), mSignalTable(), mSignalCache() { initParameters(); } @@ -109,13 +109,15 @@ class Digitizer return mSignalTable[index] + rem * (mSignalTable[index + 1] - mSignalTable[index]); } - inline Vc::float_v signalFormVc(Vc::float_v x) const + template + inline VcType signalFormVc(VcType x) const { // table lookup for the signal shape (SIMD version) + // implemented as template function, so that we don't need to include here auto const y = x / DigitizationParameters::Instance().mBunchWidth * DP::SIGNAL_TABLE_SIZE; - Vc::float_v::IndexType const index = Vc::floor(y); + typename VcType::IndexType const index = floor(y); auto const rem = y - index; - Vc::float_v val(0); - for (size_t i = 0; i < float_v::size(); ++i) { + VcType val(0); + for (size_t i = 0; i < VcType::size(); ++i) { if (y[i] < 0.0f) { continue; } @@ -159,40 +161,6 @@ class Digitizer ClassDefNV(Digitizer, 2); }; -// signal shape function -template -Float signalForm_i(Float x) -{ - using namespace std; - Float const a = -0.45458; - Float const b = -0.83344945; - return x > Float(0) ? -(exp(b * x) - exp(a * x)) / Float(7.8446501) : Float(0); - //return -(exp(-0.83344945 * x) - exp(-0.45458 * x)) * (x >= 0) / 7.8446501; // Maximum should be 7.0/250 mV -}; - -// integrated signal shape function -inline float signalForm_integral(float x) -{ - using namespace std; - double const a = -0.45458; - double const b = -0.83344945; - if (x < 0) { - x = 0; - } - return -(exp(b * x) / b - exp(a * x) / a) / 7.8446501; -}; - -// SIMD version of the integrated signal shape function -inline Vc::float_v signalForm_integralVc(Vc::float_v x) -{ - auto const mask = (x >= 0.0f); - Vc::float_v arg(0); - arg.assign(x, mask); // branchless if - Vc::float_v const a(-0.45458f); - Vc::float_v const b(-0.83344945f); - Vc::float_v result = -(Vc::exp(b * arg) / b - Vc::exp(a * arg) / a) / 7.8446501f; - return result; -}; } // namespace ft0 } // namespace o2 diff --git a/Detectors/FIT/FT0/simulation/src/Digitizer.cxx b/Detectors/FIT/FT0/simulation/src/Digitizer.cxx index 584f70ae8191f..066a247bb2355 100644 --- a/Detectors/FIT/FT0/simulation/src/Digitizer.cxx +++ b/Detectors/FIT/FT0/simulation/src/Digitizer.cxx @@ -21,11 +21,50 @@ #include #include #include +#include using namespace o2::ft0; ClassImp(Digitizer); +namespace o2::ft0 +{ +// signal shape function +template +Float signalForm_i(Float x) +{ + using namespace std; + Float const a = -0.45458; + Float const b = -0.83344945; + return x > Float(0) ? -(exp(b * x) - exp(a * x)) / Float(7.8446501) : Float(0); + //return -(exp(-0.83344945 * x) - exp(-0.45458 * x)) * (x >= 0) / 7.8446501; // Maximum should be 7.0/250 mV +}; + +// integrated signal shape function +inline float signalForm_integral(float x) +{ + using namespace std; + double const a = -0.45458; + double const b = -0.83344945; + if (x < 0) { + x = 0; + } + return -(exp(b * x) / b - exp(a * x) / a) / 7.8446501; +}; + +// SIMD version of the integrated signal shape function +inline Vc::float_v signalForm_integralVc(Vc::float_v x) +{ + auto const mask = (x >= 0.0f); + Vc::float_v arg(0); + arg.assign(x, mask); // branchless if + Vc::float_v const a(-0.45458f); + Vc::float_v const b(-0.83344945f); + Vc::float_v result = -(Vc::exp(b * arg) / b - Vc::exp(a * arg) / a) / 7.8446501f; + return result; +}; +} // namespace o2::ft0 + Digitizer::CFDOutput Digitizer::get_time(const std::vector& times, float deadTime) { assert(std::is_sorted(std::begin(times), std::end(times)));