From 15ad36f4f51f6bef84a4b5ad32ba8eddf6f9dbff Mon Sep 17 00:00:00 2001 From: "se.gorbunov" <se.gorbunov@gsi.de> Date: Wed, 7 Sep 2022 13:12:48 +0000 Subject: [PATCH] L1: simd vectors: remove custom memory allocator --- reco/L1/L1Algo/L1Algo.h | 53 +++--- reco/L1/L1Algo/L1CATrackFinder.cxx | 69 ++++---- reco/L1/L1Algo/L1Def.h | 2 - reco/L1/L1Algo/L1Portion.h | 42 +++-- .../CbmL1RichENNRingFinderParallel.cxx | 37 +++-- .../CbmL1RichENNRingFinderParallel.h | 8 +- reco/L1/vectors/L1vec.h | 2 - reco/L1/vectors/std_alloc.h | 151 ------------------ 8 files changed, 99 insertions(+), 265 deletions(-) delete mode 100644 reco/L1/vectors/std_alloc.h diff --git a/reco/L1/L1Algo/L1Algo.h b/reco/L1/L1Algo/L1Algo.h index 861f00b597..fedb3e2e52 100644 --- a/reco/L1/L1Algo/L1Algo.h +++ b/reco/L1/L1Algo/L1Algo.h @@ -309,33 +309,29 @@ public: const L1Vector<char>& mrDuplets, // output - Tindex& n3, nsL1::vector<L1TrackPar>::TSimd& T_3, L1Vector<L1HitIndex_t>& hitsl_3, L1Vector<L1HitIndex_t>& hitsm_3, - L1Vector<L1HitIndex_t>& hitsr_3, nsL1::vector<fvec>::TSimd& u_front_3, nsL1::vector<fvec>::TSimd& u_back_3, - nsL1::vector<fvec>::TSimd& z_Pos_3, - // nsL1::vector<fvec>::TSimd& dx_, - // nsL1::vector<fvec>::TSimd& dy_, - nsL1::vector<fvec>::TSimd& du_, nsL1::vector<fvec>::TSimd& dv_, nsL1::vector<fvec>::TSimd& timeR, - nsL1::vector<fvec>::TSimd& timeER); + Tindex& n3, L1Vector<L1TrackPar>& T_3, L1Vector<L1HitIndex_t>& hitsl_3, L1Vector<L1HitIndex_t>& hitsm_3, + L1Vector<L1HitIndex_t>& hitsr_3, L1Vector<fvec>& u_front_3, L1Vector<fvec>& u_back_3, L1Vector<fvec>& z_Pos_3, + // L1Vector<fvec>& dx_, + // L1Vector<fvec>& dy_, + L1Vector<fvec>& du_, L1Vector<fvec>& dv_, L1Vector<fvec>& timeR, L1Vector<fvec>& timeER); /// Add the right hits to parameters estimation. void findTripletsStep1( // input - Tindex n3_V, const L1Station& star, nsL1::vector<fvec>::TSimd& u_front_3, nsL1::vector<fvec>::TSimd& u_back_3, - nsL1::vector<fvec>::TSimd& z_Pos_3, - // nsL1::vector<fvec>::TSimd& dx_, - // nsL1::vector<fvec>::TSimd& dy_, - nsL1::vector<fvec>::TSimd& du_, nsL1::vector<fvec>::TSimd& dv_, nsL1::vector<fvec>::TSimd& timeR, - nsL1::vector<fvec>::TSimd& timeER, + Tindex n3_V, const L1Station& star, L1Vector<fvec>& u_front_3, L1Vector<fvec>& u_back_3, L1Vector<fvec>& z_Pos_3, + // L1Vector<fvec>& dx_, + // L1Vector<fvec>& dy_, + L1Vector<fvec>& du_, L1Vector<fvec>& dv_, L1Vector<fvec>& timeR, L1Vector<fvec>& timeER, // output - nsL1::vector<L1TrackPar>::TSimd& T_3); + L1Vector<L1TrackPar>& T_3); /// Refit Triplets. void findTripletsStep2( // input - Tindex n3, int istal, nsL1::vector<L1TrackPar>::TSimd& T_3, L1Vector<L1HitIndex_t>& hitsl_3, - L1Vector<L1HitIndex_t>& hitsm_3, L1Vector<L1HitIndex_t>& hitsr_3, int nIterations = 0); + Tindex n3, int istal, L1Vector<L1TrackPar>& T_3, L1Vector<L1HitIndex_t>& hitsl_3, L1Vector<L1HitIndex_t>& hitsm_3, + L1Vector<L1HitIndex_t>& hitsr_3, int nIterations = 0); /// Select triplets. Save them into vTriplets. void findTripletsStep3( // input - Tindex n3, int istal, int istam, int istar, nsL1::vector<L1TrackPar>::TSimd& T_3, L1Vector<L1HitIndex_t>& hitsl_3, + Tindex n3, int istal, int istam, int istar, L1Vector<L1TrackPar>& T_3, L1Vector<L1HitIndex_t>& hitsl_3, L1Vector<L1HitIndex_t>& hitsm_3, L1Vector<L1HitIndex_t>& hitsr_3, // output Tindex& nstaltriplets); @@ -362,8 +358,7 @@ public: /// Find triplets on station void TripletsStaPort( // input int istal, int istam, int istar, Tindex& nstaltriplets, L1TrackPar* T_1, L1FieldRegion* fld_1, - L1HitIndex_t* hitsl_1, - Tindex& n_2, L1Vector<L1HitIndex_t>& i1_2, L1Vector<L1HitIndex_t>& hitsm_2, + L1HitIndex_t* hitsl_1, Tindex& n_2, L1Vector<L1HitIndex_t>& i1_2, L1Vector<L1HitIndex_t>& hitsm_2, const L1Vector<char>& mrDuplets // output ); @@ -521,21 +516,21 @@ public: // fvec zPos[Portion/fvecLen]; // fvec fHitTime[Portion/fvecLen]; - nsL1::vector<L1TrackPar>::TSimd fT_3[L1Constants::size::kMaxNthreads]; + L1Vector<L1TrackPar> fT_3[L1Constants::size::kMaxNthreads] {"fT_3"}; L1Vector<L1HitIndex_t> fhitsl_3[L1Constants::size::kMaxNthreads] {"L1Algo::fhitsl_3"}; L1Vector<L1HitIndex_t> fhitsm_3[L1Constants::size::kMaxNthreads] {"L1Algo::fhitsm_3"}; L1Vector<L1HitIndex_t> fhitsr_3[L1Constants::size::kMaxNthreads] {"L1Algo::fhitsr_3"}; - nsL1::vector<fvec>::TSimd fu_front3[L1Constants::size::kMaxNthreads]; - nsL1::vector<fvec>::TSimd fu_back3[L1Constants::size::kMaxNthreads]; - nsL1::vector<fvec>::TSimd fz_pos3[L1Constants::size::kMaxNthreads]; - nsL1::vector<fvec>::TSimd fTimeR[L1Constants::size::kMaxNthreads]; - nsL1::vector<fvec>::TSimd fTimeER[L1Constants::size::kMaxNthreads]; - nsL1::vector<fvec>::TSimd dx[L1Constants::size::kMaxNthreads]; - nsL1::vector<fvec>::TSimd dy[L1Constants::size::kMaxNthreads]; - nsL1::vector<fvec>::TSimd du[L1Constants::size::kMaxNthreads]; - nsL1::vector<fvec>::TSimd dv[L1Constants::size::kMaxNthreads]; + L1Vector<fvec> fu_front3[L1Constants::size::kMaxNthreads] {"L1Algo::fu_front3"}; + L1Vector<fvec> fu_back3[L1Constants::size::kMaxNthreads] {"L1Algo::fu_back3"}; + L1Vector<fvec> fz_pos3[L1Constants::size::kMaxNthreads] {"L1Algo::fz_pos3"}; + L1Vector<fvec> fTimeR[L1Constants::size::kMaxNthreads] {"L1Algo::fTimeR"}; + L1Vector<fvec> fTimeER[L1Constants::size::kMaxNthreads] {"L1Algo::fTimeER"}; + L1Vector<fvec> dx[L1Constants::size::kMaxNthreads] {"L1Algo::dx"}; + L1Vector<fvec> dy[L1Constants::size::kMaxNthreads] {"L1Algo::dy"}; + L1Vector<fvec> du[L1Constants::size::kMaxNthreads] {"L1Algo::du"}; + L1Vector<fvec> dv[L1Constants::size::kMaxNthreads] {"L1Algo::dv"}; // Tindex NHits_l[L1Constants::size::kMaxNstations]; diff --git a/reco/L1/L1Algo/L1CATrackFinder.cxx b/reco/L1/L1Algo/L1CATrackFinder.cxx index 025e1bf16f..3035054979 100644 --- a/reco/L1/L1Algo/L1CATrackFinder.cxx +++ b/reco/L1/L1Algo/L1CATrackFinder.cxx @@ -39,6 +39,7 @@ #endif // _OPENMP #include "TRandom.h" +#include "TStopwatch.h" #include "L1HitsSortHelper.h" #include "L1Timer.h" @@ -551,13 +552,11 @@ inline void L1Algo::findTripletsStep0( // input L1TrackPar* T_1, L1FieldRegion* fld_1, L1HitIndex_t* hitsl_1, Tindex n2, L1Vector<L1HitIndex_t>& hitsm_2, L1Vector<L1HitIndex_t>& i1_2, const L1Vector<char>& /*mrDuplets*/, // output - Tindex& n3, nsL1::vector<L1TrackPar>::TSimd& T_3, L1Vector<L1HitIndex_t>& hitsl_3, L1Vector<L1HitIndex_t>& hitsm_3, - L1Vector<L1HitIndex_t>& hitsr_3, nsL1::vector<fvec>::TSimd& u_front_3, nsL1::vector<fvec>::TSimd& u_back_3, - nsL1::vector<fvec>::TSimd& z_Pos_3, - // nsL1::vector<fvec>::TSimd& dx_, - // nsL1::vector<fvec>::TSimd& dy_, - nsL1::vector<fvec>::TSimd& dv_, nsL1::vector<fvec>::TSimd& du_, nsL1::vector<fvec>::TSimd& timeR, - nsL1::vector<fvec>::TSimd& timeER) + Tindex& n3, L1Vector<L1TrackPar>& T_3, L1Vector<L1HitIndex_t>& hitsl_3, L1Vector<L1HitIndex_t>& hitsm_3, + L1Vector<L1HitIndex_t>& hitsr_3, L1Vector<fvec>& u_front_3, L1Vector<fvec>& u_back_3, L1Vector<fvec>& z_Pos_3, + // L1Vector<fvec>& dx_, + // L1Vector<fvec>& dy_, + L1Vector<fvec>& dv_, L1Vector<fvec>& du_, L1Vector<fvec>& timeR, L1Vector<fvec>& timeER) { int iStaM = &stam - fParameters.GetStations().begin(); int iStaR = &star - fParameters.GetStations().begin(); @@ -916,14 +915,14 @@ inline void L1Algo::findTripletsStep0( // input n3 = n3 - Ntriplets; - T_3.resize(n3 / fvec::size()); - u_front_3.resize(n3 / fvec::size()); - u_back_3.resize(n3 / fvec::size()); - z_Pos_3.resize(n3 / fvec::size()); - du_.resize(n3 / fvec::size()); - dv_.resize(n3 / fvec::size()); - timeR.resize(n3 / fvec::size()); - timeER.resize(n3 / fvec::size()); + T_3.reset(n3 / fvec::size()); + u_front_3.reset(n3 / fvec::size()); + u_back_3.reset(n3 / fvec::size()); + z_Pos_3.reset(n3 / fvec::size()); + du_.reset(n3 / fvec::size()); + dv_.reset(n3 / fvec::size()); + timeR.reset(n3 / fvec::size()); + timeER.reset(n3 / fvec::size()); cout << "L1: GetMaxTripletPerDoublets==" << fParameters.GetMaxTripletPerDoublets() << " reached in findTripletsStep0()" << endl; //assert(0); @@ -937,15 +936,13 @@ inline void L1Algo::findTripletsStep0( // input /// Add the right hits to parameters estimation. inline void L1Algo::findTripletsStep1( // input - Tindex n3_V, const L1Station& star, nsL1::vector<fvec>::TSimd& u_front_, nsL1::vector<fvec>::TSimd& u_back_, - nsL1::vector<fvec>::TSimd& z_Pos, - // nsL1::vector<fvec>::TSimd& dx_, - // nsL1::vector<fvec>::TSimd& dy_, - nsL1::vector<fvec>::TSimd& dv_, nsL1::vector<fvec>::TSimd& du_, nsL1::vector<fvec>::TSimd& timeR, - nsL1::vector<fvec>::TSimd& timeER, + Tindex n3_V, const L1Station& star, L1Vector<fvec>& u_front_, L1Vector<fvec>& u_back_, L1Vector<fvec>& z_Pos, + // L1Vector<fvec>& dx_, + // L1Vector<fvec>& dy_, + L1Vector<fvec>& dv_, L1Vector<fvec>& du_, L1Vector<fvec>& timeR, L1Vector<fvec>& timeER, // output // L1TrackPar *T_3 - nsL1::vector<L1TrackPar>::TSimd& T_3) + L1Vector<L1TrackPar>& T_3) { for (Tindex i3_V = 0; i3_V < n3_V; ++i3_V) { @@ -998,8 +995,8 @@ inline void L1Algo::findTripletsStep1( // input /// Refit Triplets. inline void L1Algo::findTripletsStep2( // input // TODO not updated after gaps introduction - Tindex n3, int istal, nsL1::vector<L1TrackPar>::TSimd& T_3, L1Vector<L1HitIndex_t>& hitsl_3, - L1Vector<L1HitIndex_t>& hitsm_3, L1Vector<L1HitIndex_t>& hitsr_3, int nIterations) + Tindex n3, int istal, L1Vector<L1TrackPar>& T_3, L1Vector<L1HitIndex_t>& hitsl_3, L1Vector<L1HitIndex_t>& hitsm_3, + L1Vector<L1HitIndex_t>& hitsr_3, int nIterations) { L1Fit fit; fit.SetParticleMass(fDefaultMass); @@ -1174,7 +1171,7 @@ inline void L1Algo::findTripletsStep2( // input // TODO not updated after gaps inline void L1Algo::findTripletsStep3( // input - Tindex n3, int istal, int istam, int istar, nsL1::vector<L1TrackPar>::TSimd& T_3, L1Vector<L1HitIndex_t>& hitsl_3, + Tindex n3, int istal, int istam, int istar, L1Vector<L1TrackPar>& T_3, L1Vector<L1HitIndex_t>& hitsl_3, L1Vector<L1HitIndex_t>& hitsm_3, L1Vector<L1HitIndex_t>& hitsr_3, // output Tindex& nstaltriplets) @@ -1384,7 +1381,7 @@ inline void L1Algo::f5( // input if (level == jlevel + 1) neighCands.push_back(neighLocation); } - // trip->neighbours.resize(0); + // trip->neighbours.reset(0); // for (unsigned int in = 0; in < neighCands.size(); in++) { // int ID = neighCands[in]; // unsigned int Station = TripletId2Station(ID); @@ -1556,19 +1553,19 @@ inline void L1Algo::TripletsStaPort( /// creates triplets: int Thread = 0; #endif - nsL1::vector<L1TrackPar>::TSimd& T_3 = fT_3[Thread]; + L1Vector<L1TrackPar>& T_3 = fT_3[Thread]; L1Vector<L1HitIndex_t>& hitsl_3 = fhitsl_3[Thread]; L1Vector<L1HitIndex_t>& hitsm_3 = fhitsm_3[Thread]; L1Vector<L1HitIndex_t>& hitsr_3 = fhitsr_3[Thread]; - nsL1::vector<fvec>::TSimd& u_front3 = fu_front3[Thread]; - nsL1::vector<fvec>::TSimd& u_back3 = fu_back3[Thread]; - nsL1::vector<fvec>::TSimd& z_pos3 = fz_pos3[Thread]; - nsL1::vector<fvec>::TSimd& timeR = fTimeR[Thread]; - nsL1::vector<fvec>::TSimd& timeER = fTimeER[Thread]; - // nsL1::vector<fvec>::TSimd& dx3 = dx[Thread]; - // nsL1::vector<fvec>::TSimd& dy3 = dy[Thread]; - nsL1::vector<fvec>::TSimd& du3 = du[Thread]; - nsL1::vector<fvec>::TSimd& dv3 = dv[Thread]; + L1Vector<fvec>& u_front3 = fu_front3[Thread]; + L1Vector<fvec>& u_back3 = fu_back3[Thread]; + L1Vector<fvec>& z_pos3 = fz_pos3[Thread]; + L1Vector<fvec>& timeR = fTimeR[Thread]; + L1Vector<fvec>& timeER = fTimeER[Thread]; + // L1Vector<fvec>& dx3 = dx[Thread]; + // L1Vector<fvec>& dy3 = dy[Thread]; + L1Vector<fvec>& du3 = du[Thread]; + L1Vector<fvec>& dv3 = dv[Thread]; T_3.clear(); hitsl_3.clear(); diff --git a/reco/L1/L1Algo/L1Def.h b/reco/L1/L1Algo/L1Def.h index 7178406074..cf4eda7de4 100644 --- a/reco/L1/L1Algo/L1Def.h +++ b/reco/L1/L1Algo/L1Def.h @@ -7,8 +7,6 @@ // #define FAST_CODE // FAST_CODE = more unsafe -#include "TStopwatch.h" - #include <iostream> #include <assert.h> diff --git a/reco/L1/L1Algo/L1Portion.h b/reco/L1/L1Algo/L1Portion.h index a3b8c6367e..56c04ce973 100644 --- a/reco/L1/L1Algo/L1Portion.h +++ b/reco/L1/L1Algo/L1Portion.h @@ -19,12 +19,11 @@ template<> class L1Portion<L1TrackPar> { public: typedef L1TrackPar T; - // typedef vector<T> vType; - typedef nsL1::vector<T>::TSimd vType; + typedef L1Vector<T> vType; - L1Portion() : a(), dataSize(0) {}; - L1Portion(int size) : a(), dataSize(0) { reserve(size); }; - L1Portion(int size, int size2) : a(), dataSize(size2) + L1Portion() {}; + L1Portion(int size) { reserve(size); }; + L1Portion(int size, int size2) : dataSize(size2) { reserve(size); // reserve2(size2); @@ -40,7 +39,7 @@ public: void push_back(vType& v) { a.push_back(v); }; void add_void() { - vType v; + vType v("L1Portion<L1TrackPar>::add_void"); // v.resize(dataSize); a.push_back(v); a[a.size() - 1].reserve(dataSize); @@ -60,21 +59,20 @@ public: }; private: - vector<vType> a; + vector<vType> a {"L1Portion<L1TrackPar>::a"}; // int mainSize; // size of a - int dataSize; // size of vType + int dataSize {0}; // size of vType }; template<> class L1Portion<L1FieldRegion> { public: typedef L1FieldRegion T; - typedef nsL1::vector<T>::TSimd vType; - // typedef std::vector<T, nsL1::SimdAlloc<T> > vType; + typedef L1Vector<T> vType; - L1Portion() : a(), dataSize(0) {}; - L1Portion(int size) : a(), dataSize(0) { reserve(size); }; - L1Portion(int size, int size2) : a(), dataSize(size2) + L1Portion() {}; + L1Portion(int size) { reserve(size); }; + L1Portion(int size, int size2) : dataSize(size2) { reserve(size); // reserve2(size2); @@ -91,7 +89,7 @@ public: void push_back(vType& v) { a.push_back(v); }; void add_void() { - vType v; + vType v("L1Portion<L1FieldRegion>::add_void"); // v.resize(dataSize); a.push_back(v); a[a.size() - 1].reserve(dataSize); @@ -111,9 +109,9 @@ public: }; private: - vector<vType> a; + vector<vType> a {"L1Portion<L1FieldRegion>::a"}; // int mainSize; // size of a - int dataSize; // size of vType + int dataSize {0}; // size of vType }; @@ -122,9 +120,9 @@ class L1Portion { public: typedef vector<T> vType; - L1Portion() : a(), dataSize(0) {}; - L1Portion(int size) : a(), dataSize(0) { reserve(size); }; - L1Portion(int size, int size2) : a(), dataSize(size2) + L1Portion() {}; + L1Portion(int size) { reserve(size); }; + L1Portion(int size, int size2) : dataSize(size2) { reserve(size); // reserve2(size2); @@ -140,7 +138,7 @@ public: void push_back(vType& v) { a.push_back(v); }; void add_void() { - vType v; + vType v("L1Portion<T>::add_void"); // v.resize(dataSize); a.push_back(v); a[a.size() - 1].reserve(dataSize); @@ -160,9 +158,9 @@ public: }; private: - vector<vType> a; + vector<vType> a {"L1Portion<T>::a"}; // int mainSize; // size of a - int dataSize; // size of vType + int dataSize {0}; // size of vType }; #endif // L1Portion_H diff --git a/reco/L1/OffLineInterface/CbmL1RichENNRingFinderParallel.cxx b/reco/L1/OffLineInterface/CbmL1RichENNRingFinderParallel.cxx index 26db240835..506262a95c 100644 --- a/reco/L1/OffLineInterface/CbmL1RichENNRingFinderParallel.cxx +++ b/reco/L1/OffLineInterface/CbmL1RichENNRingFinderParallel.cxx @@ -121,10 +121,10 @@ Int_t CbmL1RichENNRingFinderParallel::DoFind(CbmEvent* event, TClonesArray* HitA sort(Down.begin(), Down.end(), ENNHit::Compare); // save local-out indices correspondece - vector<Int_t> outIndicesUp; // indices in HitArray indexed by index in Up - vector<Int_t> outIndicesDown; // indices in HitArray indexed by index in Down - outIndicesUp.resize(Up.size()); - outIndicesDown.resize(Down.size()); + L1Vector<Int_t> outIndicesUp; // indices in HitArray indexed by index in Up + L1Vector<Int_t> outIndicesDown; // indices in HitArray indexed by index in Down + outIndicesUp.reset(Up.size()); + outIndicesDown.reset(Down.size()); for (THitIndex k = 0; k < Up.size(); k++) { Up[k].localIndex = k; outIndicesUp[k] = Up[k].outIndex; @@ -143,10 +143,10 @@ Int_t CbmL1RichENNRingFinderParallel::DoFind(CbmEvent* event, TClonesArray* HitA #endif // PRINT_TIMING // save local-out indices correspondece - nsL1vector<ENNHitV>::TSimd UpV; - nsL1vector<ENNHitV>::TSimd DownV; - UpV.resize((Up.size() + fvec::size() - 1) / fvec::size()); - DownV.resize((Down.size() + fvec::size() - 1) / fvec::size()); + L1Vector<ENNHitV> UpV; + L1Vector<ENNHitV> DownV; + UpV.reset((Up.size() + fvec::size() - 1) / fvec::size()); + DownV.reset((Down.size() + fvec::size() - 1) / fvec::size()); for (THitIndex k = 0; k < Up.size(); k++) { int k_4 = k % fvec::size(), k_V = k / fvec::size(); ENNHitV& hits = UpV[k_V]; // TODO change on ENNHitV @@ -234,9 +234,8 @@ Int_t CbmL1RichENNRingFinderParallel::DoFind(CbmEvent* event, TClonesArray* HitA } -void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, nsL1vector<ENNHitV>::TSimd& HitsV, - vector<ENNRing>& Rings, float HitSize, THitIndex MinRingHits, - fvec /*RMin*/, fvec RMax) +void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, L1Vector<ENNHitV>& HitsV, vector<ENNRing>& Rings, + float HitSize, THitIndex MinRingHits, fvec /*RMin*/, fvec RMax) { #ifdef PRINT_TIMING GetTimer("All").Start(0); @@ -268,17 +267,17 @@ void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, nsL1vector<E #ifdef PRINT_TIMING GetTimer("Ring finding").Start(0); #endif // PRINT_TIMING - nsL1vector<ENNSearchHitV>::TSimd SearchArea; - nsL1vector<ENNHitV>::TSimd PickUpArea; + L1Vector<ENNSearchHitV> SearchArea; + L1Vector<ENNHitV> PickUpArea; const int MaxAreaHits = 200; // TODO take into account NHits - SearchArea.resize(MaxAreaHits, ENNSearchHitV()); - PickUpArea.resize(MaxAreaHits); + SearchArea.reset(MaxAreaHits, ENNSearchHitV()); + PickUpArea.reset(MaxAreaHits); // TODO 1 #if 0 - nsL1vector<ENNRingV>::TSimd rings_tmp; // simd hits for tmp store - rings_tmp.resize(100); // TODO use NRings + L1Vector<ENNRingV> rings_tmp; // simd hits for tmp store + rings_tmp.reset(100); // TODO use NRings int nRings_tmp = 0; #endif @@ -519,7 +518,7 @@ void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, nsL1vector<E ringV.localIHits.push_back(iHit.localIndex); ringV.NHits = 1; ringV.chi2 = 0; - nsL1vector<fvec>::TSimd Shadow; // save hit indices of hits, which's quality will be changed + L1Vector<fvec> Shadow; // save hit indices of hits, which's quality will be changed Shadow.reserve(25); Shadow.push_back(iHit.localIndex); for( THitIndex ih = 0; ih < MaxSearchAreaSize; ih++){ @@ -734,7 +733,7 @@ void CbmL1RichENNRingFinderParallel::ENNRingFinder(const int NHits, nsL1vector<E const THitIndex maxI = i->localIHits.size(); vector<ENNSearchHitV> shits; - shits.resize(maxI); + shits.reset(maxI); for (THitIndex iih = 0; iih < maxI; iih++) { const THitIndex ih = i->localIHits[iih]; const ENNHitV& hit = HitsV[ih / fvec::size()]; diff --git a/reco/L1/OffLineInterface/CbmL1RichENNRingFinderParallel.h b/reco/L1/OffLineInterface/CbmL1RichENNRingFinderParallel.h index f8248257ea..fec973655b 100644 --- a/reco/L1/OffLineInterface/CbmL1RichENNRingFinderParallel.h +++ b/reco/L1/OffLineInterface/CbmL1RichENNRingFinderParallel.h @@ -24,14 +24,14 @@ #include "CbmRichRingFinder.h" -#include "L1Def.h" +#include "vectors/L1vec.h" //#include "../vectors/PSEUDO_F32vec4.h" // for check //#include "../vectors/PSEUDO_F32vec1.h" // for check #include "TStopwatch.h" #include "TString.h" -#include <vector> +#include "L1Vector.h" class ENNHit; class ENNRing; @@ -179,8 +179,8 @@ class CbmL1RichENNRingFinderParallel : public CbmRichRingFinder { }; - void ENNRingFinder(const int NHits, nsL1vector<ENNHitV>::TSimd& HitsV, std::vector<ENNRing>& Rings, - float HitSize = 1., THitIndex MinRingHits = 5, fvec RMin = 2., fvec RMax = 6.); + void ENNRingFinder(const int NHits, L1Vector<ENNHitV>& HitsV, std::vector<ENNRing>& Rings, float HitSize = 1., + THitIndex MinRingHits = 5, fvec RMin = 2., fvec RMax = 6.); public: /** Standard constructor **/ diff --git a/reco/L1/vectors/L1vec.h b/reco/L1/vectors/L1vec.h index d706949356..901ab2f7fa 100644 --- a/reco/L1/vectors/L1vec.h +++ b/reco/L1/vectors/L1vec.h @@ -8,6 +8,4 @@ #include "vectors/L1vecVc.h" //#include "vectors/L1vecPseudo.h" -#include "std_alloc.h" - #endif diff --git a/reco/L1/vectors/std_alloc.h b/reco/L1/vectors/std_alloc.h deleted file mode 100644 index d744dd1f1d..0000000000 --- a/reco/L1/vectors/std_alloc.h +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright (C) 2010 Frankfurt Institute for Advanced Studies, Goethe-Universität Frankfurt, Frankfurt - SPDX-License-Identifier: GPL-3.0-only - Authors: Igor Kulakov [committer] */ - -#ifndef STD_ALLOC_H -#define STD_ALLOC_H -// ---------------------- Allocator for using STL ------------------------ - -#include <Vc/Vc> -#include <limits> -#include <vector> - -namespace nsL1 -{ - - // #define DEBUG_nsL1 - - template<class T> - class SimdAlloc { - public: - // type definitions - typedef T value_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - // rebind allocator to type U - template<class U> - struct rebind { - typedef SimdAlloc<U> other; - }; - - // return address of values - pointer address(reference value) const { return &value; } - const_pointer address(const_reference value) const { return &value; } - - /* constructors and destructor - * - nothing to do because the allocator has no state - */ - SimdAlloc() throw() {} - SimdAlloc(const SimdAlloc&) throw() {} - template<class U> - SimdAlloc(const SimdAlloc<U>&) throw() - { - } - ~SimdAlloc() throw() {} - - // return maximum number of elements that can be allocated - size_type max_size() const throw() { return std::numeric_limits<std::size_t>::max() / sizeof(T); } - - // allocate but don't initialize num elements of type T - pointer allocate(size_type num, const void* = 0) - { -// print message and allocate memory with global new -#ifdef DEBUG_nsL1 - std::cerr << "Allocator: allocate " << num << " element(s)" - << " of size " << sizeof(T) << std::endl; -#endif // DEBUG_nsL1 - pointer ret = reinterpret_cast<pointer>(/*T::*/ operator new(num * sizeof(T))); -#ifdef DEBUG_nsL1 - std::cerr << " allocated at: " << (void*) ret << std::endl; -#endif // DEBUG_nsL1 - return ret; - } - - // initialize elements of allocated storage p with value value - void construct(pointer p, const T& value) - { - // initialize memory with placement new -#ifdef DEBUG_nsL1 - std::cerr << "Allocator: construct " << p /*<< " " << value*/ << std::endl; -#endif // DEBUG_nsL1 - new (p) T(value); -// p = reinterpret_cast<pointer>( operator new(sizeof(T), p) ); -// *p = value; -#ifdef DEBUG_nsL1 - std::cerr << "done." << std::endl; -#endif // DEBUG_nsL1 - } - - // destroy elements of initialized storage p - void destroy(pointer p) - { - // destroy objects by calling their destructor -#ifdef DEBUG_nsL1 - std::cerr << "Allocator: destroy " << p << std::endl; -#endif // DEBUG_nsL1 - p->~T(); -#ifdef DEBUG_nsL1 - std::cerr << "done." << std::endl; -#endif // DEBUG_nsL1 - } - - // deallocate storage p of deleted elements - void deallocate(pointer p, size_type num) - { - // print message and deallocate memory with global delete -#ifdef DEBUG_nsL1 - std::cerr << "Allocator: deallocate " << num << " element(s)" - << " of size " << sizeof(T) << " at: " << static_cast<void*>(p) << std::endl; -#endif // DEBUG_nsL1 - /*T::*/ operator delete(static_cast<void*>(p), num * sizeof(T)); -#ifdef DEBUG_nsL1 - std::cerr << "done." << std::endl; -#endif // DEBUG_nsL1 - } - - - void* operator new(size_t size, void* ptr) { return ::operator new(size, ptr); } - void* operator new[](size_t size, void* ptr) { return ::operator new(size, ptr); } - void* operator new(size_t size) { return Vc::malloc<T, Vc::AlignOnCacheline>(size / sizeof(T) + 1); } - void* operator new[](size_t size) { return Vc::malloc<T, Vc::AlignOnCacheline>(size / sizeof(T) + 1); } - void operator delete(void* ptr, size_t) { Vc::free(ptr); } - void operator delete[](void* ptr, size_t) { Vc::free(ptr); } - }; // SimdAlloc - - // return that all specializations of this allocator are interchangeable - template<class T1, class T2> - bool operator==(const SimdAlloc<T1>&, const SimdAlloc<T2>&) throw() - { - return true; - }; - template<class T1, class T2> - bool operator!=(const SimdAlloc<T1>&, const SimdAlloc<T2>&) throw() - { - return false; - }; - - template<typename T> - struct vector { - vector() {}; - virtual ~vector() {}; - - typedef std::vector<T> TStd; - // typedef std::vector<T > TSimd; - typedef std::vector<T, SimdAlloc<T>> TSimd; - }; - - typedef nsL1::vector<fvec>::TSimd vector_fvec; -}; // namespace nsL1 - -template<typename T> -struct nsL1vector : - public nsL1::vector<T> // just for use std::vector simultaniosly -{ -}; - -#endif -- GitLab