Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MP cleanup 220208 + MC fix #133

Merged
merged 23 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
353e13c
fixing integer range check in FPGAWord.
tschuh Jan 27, 2022
75849e9
Fixing `zmatchcut_` for L1 and L2
bryates Jan 28, 2022
e259406
Undo the -0.06 in Settings.h as there is a cleaner fix to the overflows
aryd Jan 29, 2022
85cfe99
Slight rewerite to use <= instead < and not do subtracktion
aryd Jan 29, 2022
15a3d9e
Fixing `zmatchcut_` for L1 and L2
bryates Jan 28, 2022
b92f2d8
Undo the -0.06 in Settings.h as there is a cleaner fix to the overflows
aryd Jan 29, 2022
b81bcfd
Some updates to MP to converge with HLS code
aryd Feb 8, 2022
ffeab98
Further clenup of the MP code
aryd Feb 9, 2022
dc76a69
More cleanup -removal of hardcoded numbers
aryd Feb 10, 2022
5b3c41b
Further cleanup
aryd Feb 10, 2022
a5acd3b
Fixing `zmatchcut_` for L1 and L2
bryates Jan 28, 2022
b501583
Undo the -0.06 in Settings.h as there is a cleaner fix to the overflows
aryd Jan 29, 2022
420f120
fixing integer range check in FPGAWord.
tschuh Jan 27, 2022
a9012dd
Fixing `zmatchcut_` for L1 and L2
bryates Jan 28, 2022
2dc4894
Undo the -0.06 in Settings.h as there is a cleaner fix to the overflows
aryd Jan 29, 2022
c192159
Slight rewerite to use <= instead < and not do subtracktion
aryd Jan 29, 2022
bad1fa9
Some updates to MP to converge with HLS code
aryd Feb 8, 2022
6d4fdf2
Further clenup of the MP code
aryd Feb 9, 2022
c244424
More cleanup -removal of hardcoded numbers
aryd Feb 10, 2022
86a9e1b
Further cleanup
aryd Feb 10, 2022
415ab54
Fixes to the MC to allow full agreement with HLS
aryd Feb 15, 2022
817dea8
Added a comment header and pipeline description
bryates Feb 16, 2022
df1154e
Added comment about MC iterations
bryates Feb 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion L1Trigger/TrackFindingTracklet/interface/MatchCalculator.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace trklet {
void addOutput(MemoryBase* memory, std::string output) override;
void addInput(MemoryBase* memory, std::string input) override;

void execute(double phioffset);
void execute(unsigned int iSector, double phioffset);

std::vector<std::pair<std::pair<Tracklet*, int>, const Stub*> > mergeMatches(
std::vector<CandidateMatchMemory*>& candmatch);
Expand Down
61 changes: 44 additions & 17 deletions L1Trigger/TrackFindingTracklet/interface/MatchEngineUnit.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/****************************************************************
* MatchEngineUnit (MEU) is a single instance of the MatchEngine
* section of the MatchProcessor (MP)
*
* Manual pipelining is implemented to properly emulate the HLS
* implementation (required to meet II=1)
*
* A total of `nMatchEngines_` MEUs are used in the MP
****************************************************************/
#ifndef L1Trigger_TrackFindingTracklet_interface_MatchEngineUnit_h
#define L1Trigger_TrackFindingTracklet_interface_MatchEngineUnit_h

Expand All @@ -18,7 +27,7 @@ namespace trklet {

class MatchEngineUnit {
public:
MatchEngineUnit(bool barrel, unsigned int layerdisk, const TrackletLUT& luttable);
MatchEngineUnit(const Settings& settings, bool barrel, unsigned int layerdisk, const TrackletLUT& luttable);

~MatchEngineUnit() = default;

Expand All @@ -35,9 +44,7 @@ namespace trklet {
bool usesecondMinus,
bool usesecondPlus,
bool isPSseed,
Tracklet* proj,
bool print,
int imeu);
Tracklet* proj);

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

Expand All @@ -47,32 +54,40 @@ namespace trklet {

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

Tracklet* currentProj() const { return proj_; }

bool idle() const { return idle_; }

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

//needed for consistency with HLS FW version ("_" vs "__" indicating different pipelining stages)
bool have_() const { return havepair_; }
bool active() const { return !idle_ || good__ || good___ || !empty(); }

void setAlmostFull();

void setimeu(int imeu) {
imeu_ = imeu;
}

void setprint(bool print) {
print_ = print;
}

void reset();

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

void step(bool print);
void step();

void processPipeline();

private:

//Provide access to constants
const Settings& settings_;

VMStubsMEMemory* vmstubsmemory_;

unsigned int nrzbins_;
unsigned int rzbin_;
unsigned int phibin_;
int shift_;
int imeu_;

unsigned int istub_;
unsigned int iuse_;
Expand All @@ -83,7 +98,7 @@ namespace trklet {
int projfinephi_;
std::vector<std::pair<unsigned int, unsigned int>> use_;
bool isPSseed_;
Tracklet* proj_;
Tracklet *proj_;

bool idle_;

Expand All @@ -95,13 +110,25 @@ namespace trklet {
//LUT for bend consistency with rinv
const TrackletLUT& luttable_;

//Pipeline variables
std::pair<Tracklet*, const Stub*> tmppair_;
bool goodpair_;
bool havepair_;
//Various manually pipelined variables
//Each _ represents a layer of pipelining
//e.g., good__ is set and one iteration later good___ is updated
VMStubME vmstub__, vmstub___;
bryates marked this conversation as resolved.
Show resolved Hide resolved
bool isPSseed__, isPSseed___;
bool good__, good___;
int projfinerz__, projfinerz___;
int projfinephi__, projfinephi___;
int projrinv__, projrinv___;
Tracklet *proj__, *proj___;

//save the candidate matches
CircularBuffer<std::pair<Tracklet*, const Stub*>> candmatches_;

//debugging help
int imeu_;
bool print_;


};

}; // namespace trklet
Expand Down
5 changes: 4 additions & 1 deletion L1Trigger/TrackFindingTracklet/interface/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,10 @@ namespace trklet {
{"TC", 108},
{"PR", 108},
{"ME", 108},
{"MC", 104},
tomalin marked this conversation as resolved.
Show resolved Hide resolved
//NOTE: The MC is set to 108, but `mergedepth`
//removes 3 iterations to emulate the delay
//due to the HLS priority encoder
{"MC", 108},
{"TB", 108},
{"MP", 108},
{"TP", 108},
Expand Down
13 changes: 11 additions & 2 deletions L1Trigger/TrackFindingTracklet/src/MatchCalculator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "DataFormats/Math/interface/deltaPhi.h"

#include <filesystem>
#include <algorithm>

using namespace std;
using namespace trklet;
Expand Down Expand Up @@ -113,15 +114,23 @@ void MatchCalculator::addInput(MemoryBase* memory, string input) {
throw cms::Exception("BadConfig") << __FILE__ << " " << __LINE__ << " could not find input " << input;
}

void MatchCalculator::execute(double phioffset) {
void MatchCalculator::execute(unsigned int iSector, double phioffset) {
unsigned int countall = 0;
unsigned int countsel = 0;

//bool print = getName() == "MC_L4PHIC" && iSector == 3;

Tracklet* oldTracklet = nullptr;

std::vector<std::pair<std::pair<Tracklet*, int>, const Stub*> > mergedMatches = mergeMatches(matches_);

for (unsigned int j = 0; j < mergedMatches.size(); j++) {
// Number of clock cycles the pipeline in HLS takes to process the projection merging to
// produce the first projectio
unsigned int mergedepth = 3;

unsigned int maxProc = std::min(settings_.maxStep("MC") - mergedepth, (unsigned int)mergedMatches.size());

for (unsigned int j = 0; j < maxProc; j++) {
if (settings_.debugTracklet() && j == 0) {
edm::LogVerbatim("Tracklet") << getName() << " has " << mergedMatches.size() << " candidate matches";
}
Expand Down
Loading