Skip to content

Commit

Permalink
MP updates (fixed) (#81)
Browse files Browse the repository at this point in the history
* Updates to MatchProcessor so that we can get full agreement with HLS version

* Fix to LUT for adding stub in VMStubsTEMemory when running extendted tracking

Co-authored-by: Anders Ryd <aryd@cern.ch>
  • Loading branch information
skinnari and aryd committed Jul 9, 2021
1 parent bc4c0fa commit b57a3f4
Show file tree
Hide file tree
Showing 5 changed files with 313 additions and 173 deletions.
19 changes: 17 additions & 2 deletions L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h
Expand Up @@ -35,10 +35,13 @@ namespace trklet {
bool usesecondMinus,
bool usesecondPlus,
bool isPSseed,
Tracklet* proj);
Tracklet* proj,
bool print);

bool empty() const { return candmatches_.empty(); }

int TCID() const;

std::pair<Tracklet*, const Stub*> read() { return candmatches_.read(); }

std::pair<Tracklet*, const Stub*> peek() const { return candmatches_.peek(); }
Expand All @@ -47,8 +50,16 @@ namespace trklet {

bool idle() const { return idle_; }

bool active() const { return !idle_||goodpair_||goodpair__||!empty(); }

bool have_() const { return havepair_; }
bool have__() const { return havepair__; }

void reset();

unsigned int rptr() const { return candmatches_.rptr(); }
unsigned int wptr() const { return candmatches_.wptr(); }

void step(bool print);

private:
Expand Down Expand Up @@ -77,7 +88,11 @@ namespace trklet {
//LUT for bend consistency with rinv
const TrackletLUT& luttable_;


//Pipeline variables
std::pair<Tracklet*, const Stub*> tmppair_, tmppair__;
bool goodpair_, goodpair__;
bool havepair_, havepair__;

//save the candidate matches
CircularBuffer<std::pair<Tracklet*, const Stub*>> candmatches_;
};
Expand Down
2 changes: 2 additions & 0 deletions L1Trigger/TrackFindingTracklet/interface/TrackletLUT.h
Expand Up @@ -59,6 +59,8 @@ namespace trklet {

int lookup(unsigned int index) const;

unsigned int size() const { return table_.size(); }

private:

int getphiCorrValue(unsigned int layerdisk, unsigned int ibend, unsigned int irbin,
Expand Down
94 changes: 79 additions & 15 deletions L1Trigger/TrackFindingTracklet/src/MatchEngineUnit.cc
Expand Up @@ -4,10 +4,14 @@
using namespace std;
using namespace trklet;

MatchEngineUnit::MatchEngineUnit(bool barrel, unsigned int layerdisk, const TrackletLUT& luttable) : luttable_(luttable), candmatches_(5) {
MatchEngineUnit::MatchEngineUnit(bool barrel, unsigned int layerdisk, const TrackletLUT& luttable) : luttable_(luttable), candmatches_(3) {
idle_ = true;
barrel_ = barrel;
layerdisk_ = layerdisk;
goodpair_ = false;
goodpair__ = false;
havepair_ = false;
havepair__ = false;
}

void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory,
Expand All @@ -23,7 +27,8 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory,
bool usesecondMinus,
bool usesecondPlus,
bool isPSseed,
Tracklet* proj) {
Tracklet* proj,
bool) {
vmstubsmemory_ = vmstubsmemory;
idle_ = false;
nrzbins_ = nrzbins;
Expand All @@ -39,22 +44,53 @@ void MatchEngineUnit::init(VMStubsMEMemory* vmstubsmemory,
if (usefirstMinus) {
use_.emplace_back(0, 0);
}
if (usefirstPlus) {
use_.emplace_back(0, 1);
}
if (usesecondMinus) {
use_.emplace_back(1, 0);
}
if (usefirstPlus) {
use_.emplace_back(0, 1);
}
if (usesecondPlus) {
use_.emplace_back(1, 1);
}
assert(use_.size() != 0);
isPSseed_ = isPSseed;
proj_ = proj;

//Even when you init a new projection you need to process the pipeline
//This should be fixed to be done more cleanly - but require synchronizaton
//with the HLS code
if (goodpair__) {
candmatches_.store(tmppair__);
}

havepair__ = havepair_;
goodpair__ = goodpair_;
tmppair__ = tmppair_;

havepair_ = false;
goodpair_ = false;


}

void MatchEngineUnit::step(bool print) {
if (idle() || candmatches_.almostfull())
void MatchEngineUnit::step(bool) {

bool almostfull = candmatches_.nearfull();

if (goodpair__) {
assert(havepair__);
candmatches_.store(tmppair__);
}

havepair__ = havepair_;
goodpair__ = goodpair_;
tmppair__ = tmppair_;

havepair_ = false;
goodpair_ = false;

if (idle() || almostfull)
return;

unsigned int slot = (phibin_ + use_[iuse_].second) * nrzbins_ + rzbin_ + use_[iuse_].first;
Expand Down Expand Up @@ -106,16 +142,21 @@ void MatchEngineUnit::step(bool print) {
}
}

if (print)
cout << "MEU TrkId stubindex : " << 128 * proj_->TCIndex() + proj_->trackletIndex() << " "
<< vmstub.stubindex().value() << " " << ((pass && dphicut) && luttable_.lookup(index)) << " index=" << index
<< " projrinv bend : " << projrinv_ << " " << vmstub.bend().value() << " shift_ isPSseed_ :" << shift_ << " "
<< isPSseed_ << " slot=" << slot << endl;
// Detailed printout for comparison with HLS code
//if (print)
// cout << "MEU TrkId stubindex : " << 128 * proj_->TCIndex() + proj_->trackletIndex() << " "
// << vmstub.stubindex().value() << " " << ((pass && dphicut) && luttable_.lookup(index)) << " index=" << index
// << " projrinv bend : " << projrinv_ << " " << vmstub.bend().value() << " shift_ isPSseed_ :" << shift_ << " "
// << isPSseed_ << " slot=" << slot << endl;

//Check if stub bend and proj rinv consistent
if ((pass && dphicut) && luttable_.lookup(index)) {
std::pair<Tracklet*, const Stub*> tmp(proj_, vmstub.stub());
candmatches_.store(tmp);

goodpair_ = (pass && dphicut) && luttable_.lookup(index);
havepair_ = true;

if (havepair_) {
std::pair<Tracklet*, const Stub*> tmppair(proj_, vmstub.stub());
tmppair_ = tmppair;
}

istub_++;
Expand All @@ -133,4 +174,27 @@ void MatchEngineUnit::reset() {
candmatches_.reset();
idle_ = true;
istub_ = 0;
goodpair_ = false;
goodpair__ = false;
havepair_ = false;
havepair__ = false;
}

int MatchEngineUnit::TCID() const {

if (!empty()) {
return peek().first->TCID();
}

if (idle_&&!havepair_&&!havepair__) {
return 16383;
}
if (havepair__) {
return tmppair__.first->TCID();
}
if (havepair_) {
return tmppair_.first->TCID();
}
return proj_->TCID();

}

0 comments on commit b57a3f4

Please sign in to comment.