Skip to content

Commit

Permalink
Duplicate MPs to Reduce Truncation in MatchProcessor (#276)
Browse files Browse the repository at this point in the history
* Duplicating L3,4 PHI B,C MPs to reduce truncation effects

* Triggering CI

* Allowing multiple VMStubs to be written

* Fixing code format

* Changing L4 duplicated MP projection load

* Adding duplicate MPs for phi A, D

* Adding option to enable / disable duplicate MP config in Settings.h

* Fixing code format

* Adding option to choose which layers/disks duplicated for, removing phi A,D duplicated

* Fixing code format for CMSSW
  • Loading branch information
mlarson02 authored Aug 26, 2024
1 parent 8befcea commit abfcf90
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 35 deletions.
26 changes: 26 additions & 0 deletions L1Trigger/TrackFindingTracklet/interface/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,13 @@ namespace trklet {

bool extended() const { return extended_; }
void setExtended(bool extended) { extended_ = extended; }
bool duplicateMPs() const { return duplicateMPs_; }
std::array<bool, N_LAYER + N_DISK> layersDisksDuplicatedEqualProjBalance() const {
return layersDisksDuplicatedEqualProjBalance_;
}
std::array<bool, N_LAYER + N_DISK> layersDisksDuplicatedWeightedProjBalance() const {
return layersDisksDuplicatedWeightedProjBalance_;
}
bool combined() const { return combined_; }
void setCombined(bool combined) { combined_ = combined; }
bool reduced() const { return reduced_; }
Expand Down Expand Up @@ -1035,6 +1042,25 @@ namespace trklet {
// If you don't want them, edit l1tTTTracksFromTrackletEmulation_cfi.py
// to refer to *_hourglassExtended.dat .

// Use chain with duplicated MPs for L3,L4 to reduce truncation issue
// Balances load from projections roughly in half for each of the two MPs
bool duplicateMPs_{false};

// Determines which layers, disks the MatchProcessor is duplicated for
// (note: in TCB by default always duplicated for phi B, C as truncation is significantly worse than A, D)
// All layers, disks disabled by default, also is overwritten by above duplicateMPs bool

// EqualProjBalancing is for layers for which the projections to each duplicated MP are split in half sequentially
std::array<bool, N_LAYER + N_DISK> layersDisksDuplicatedEqualProjBalance_{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};

// Weighted proj balancing is for specifically L4, L5 where the split of the projections is weighted to account for
// Higher occupancy in the L1L2 seed to minimize truncation
std::array<bool, N_LAYER + N_DISK> layersDisksDuplicatedWeightedProjBalance_{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};

// Example use where for L3, L4, L5, D2, D3, the layers/disks where truncation is worst
//std::array<bool, N_LAYER + N_DISK> layersDisksDuplicatedEqualProjBalance_{{0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0}};
//std::array<bool, N_LAYER + N_DISK> layersDisksDuplicatedWeightedProjBalance_{{0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0}};

std::string skimfile_{""}; //if not empty events will be written out in ascii format to this file

double bfield_{3.8112}; //B-field in T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ namespace trklet {
unsigned int NSector_; //Number of sectors
double rcrit_; //critical radius that defines the sector

bool duplicateMPs_; //if true write configuration with MPs duplicated for L3,L4
bool combinedmodules_; //if true write configuration for combined modules

bool extended_; //if true write configuration for extended configuration
Expand Down
188 changes: 160 additions & 28 deletions L1Trigger/TrackFindingTracklet/src/TrackletConfigBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ TrackletConfigBuilder::TrackletConfigBuilder(const Settings& settings, const tt:
NSector_ = N_SECTOR;
rcrit_ = settings.rcrit();

duplicateMPs_ = settings.duplicateMPs();
combinedmodules_ = settings.combined();

extended_ = settings.extended();
Expand Down Expand Up @@ -516,12 +517,52 @@ void TrackletConfigBuilder::writeProjectionMemories(std::ostream& os, std::ostre
for (unsigned int imem = 0; imem < projections_[ilayer][ireg].size(); imem++) {
unsigned int iSeed = projections_[ilayer][ireg][imem].first;
unsigned int iTC = projections_[ilayer][ireg][imem].second;

memories << "TrackletProjections: " + TPROJName(iSeed, iTC, ilayer, ireg) + " [54]" << std::endl;

os << TPROJName(iSeed, iTC, ilayer, ireg) << " input=> " << TCName(iSeed, iTC) << ".projout"
<< LayerName(ilayer) << "PHI" << iTCStr(ireg) << " output=> " << PRName(ilayer, ireg) << ".projin"
<< std::endl;
if (combinedmodules_) {
if (duplicateMPs_) {
if ((settings_.layersDisksDuplicatedEqualProjBalance()[ilayer]) && (ireg == 1 || ireg == 2)) {
memories << "TrackletProjections: " + TPROJName(iSeed, iTC, ilayer, ireg) + " [54]" << std::endl;
if (imem < projections_[ilayer][ireg].size() / 2) {
os << TPROJName(iSeed, iTC, ilayer, ireg) << " input=> " << TCName(iSeed, iTC) << ".projout"
<< LayerName(ilayer) << "PHI" << iTCStr(ireg) << " output=> " << PRName(ilayer, ireg) << ".projin"
<< std::endl;
} else {
os << TPROJName(iSeed, iTC, ilayer, ireg) << " input=> " << TCName(iSeed, iTC) << ".projout"
<< LayerName(ilayer) << "PHI" << iTCStr(ireg) << " output=> " << PRName(ilayer, ireg) + "_E"
<< ".projin" // duplicate MPs denoted by extra _E
<< std::endl;
}
} else if ((settings_.layersDisksDuplicatedWeightedProjBalance()[ilayer]) && (ireg == 1 || ireg == 2)) {
memories << "TrackletProjections: " + TPROJName(iSeed, iTC, ilayer, ireg) + " [54]" << std::endl;
if (imem < 4 ||
imem >
9) { // FIXME need to replace magic numbers, corresponds to allowing MP1 4 L1L2 TCs, 3 L5L6 TCs, MP2 3 L1L2 3 L3L4 TCs
os << TPROJName(iSeed, iTC, ilayer, ireg) << " input=> " << TCName(iSeed, iTC) << ".projout"
<< LayerName(ilayer) << "PHI" << iTCStr(ireg) << " output=> " << PRName(ilayer, ireg) << ".projin"
<< std::endl;
} else {
os << TPROJName(iSeed, iTC, ilayer, ireg) << " input=> " << TCName(iSeed, iTC) << ".projout"
<< LayerName(ilayer) << "PHI" << iTCStr(ireg) << " output=> " << PRName(ilayer, ireg) + "_E"
<< ".projin" // duplicate MPs
<< std::endl;
}
} else {
memories << "TrackletProjections: " + TPROJName(iSeed, iTC, ilayer, ireg) + " [54]" << std::endl;
os << TPROJName(iSeed, iTC, ilayer, ireg) << " input=> " << TCName(iSeed, iTC) << ".projout"
<< LayerName(ilayer) << "PHI" << iTCStr(ireg) << " output=> " << PRName(ilayer, ireg) << ".projin"
<< std::endl;
}
} else { // non-duplicate MPs configuration
memories << "TrackletProjections: " + TPROJName(iSeed, iTC, ilayer, ireg) + " [54]" << std::endl;
os << TPROJName(iSeed, iTC, ilayer, ireg) << " input=> " << TCName(iSeed, iTC) << ".projout"
<< LayerName(ilayer) << "PHI" << iTCStr(ireg) << " output=> " << PRName(ilayer, ireg) << ".projin"
<< std::endl;
}
} else { // non-combined modules
memories << "TrackletProjections: " + TPROJName(iSeed, iTC, ilayer, ireg) + " [54]" << std::endl;
os << TPROJName(iSeed, iTC, ilayer, ireg) << " input=> " << TCName(iSeed, iTC) << ".projout"
<< LayerName(ilayer) << "PHI" << iTCStr(ireg) << " output=> " << PRName(ilayer, ireg) << ".projin"
<< std::endl;
}
}
}
}
Expand Down Expand Up @@ -868,15 +909,51 @@ void TrackletConfigBuilder::writeFMMemories(std::ostream& os, std::ostream& memo
if (combinedmodules_) {
for (unsigned int ilayer = 0; ilayer < N_LAYER + N_DISK; ilayer++) {
for (unsigned int iReg = 0; iReg < NRegions_[ilayer]; iReg++) {
modules << "MatchProcessor: MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) {
if (matchport_[iSeed][ilayer] == -1)
continue;
memories << "FullMatch: FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg)
<< " [36]" << std::endl;
os << "FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << " input=> MP_"
<< LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".matchout1 output=> FT_" << iSeedStr(iSeed)
<< ".fullmatch" << matchport_[iSeed][ilayer] << "in" << iReg + 1 << std::endl;
if (duplicateMPs_) {
if ((settings_.layersDisksDuplicatedEqualProjBalance()[ilayer] ||
settings_.layersDisksDuplicatedWeightedProjBalance()[ilayer]) &&
(iReg == 1 || iReg == 2)) { // regions with worst truncation
modules << "MatchProcessor: MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
modules << "MatchProcessor: MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) + "_E" << std::endl;
for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) {
if (matchport_[iSeed][ilayer] == -1)
continue;
memories << "FullMatch: FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg)
<< " [36]" << std::endl;
memories << "FullMatch: FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI"
<< iTCStr(iReg) + "_E"
<< " [36]" << std::endl;
os << "FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << " input=> MP_"
<< LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".matchout1 output=> FT_" << iSeedStr(iSeed)
<< ".fullmatch" << matchport_[iSeed][ilayer] << "in" << iReg + 1 << std::endl;
os << "FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) + "_E"
<< " input=> MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) + "_E"
<< ".matchout1 output=> FT_" << iSeedStr(iSeed) << ".fullmatch" << matchport_[iSeed][ilayer] << "in"
<< iReg + 1 << std::endl;
}
} else {
modules << "MatchProcessor: MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) {
if (matchport_[iSeed][ilayer] == -1)
continue;
memories << "FullMatch: FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg)
<< " [36]" << std::endl;
os << "FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << " input=> MP_"
<< LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".matchout1 output=> FT_" << iSeedStr(iSeed)
<< ".fullmatch" << matchport_[iSeed][ilayer] << "in" << iReg + 1 << std::endl;
}
}
} else { // non-duplicate MPs configuration
modules << "MatchProcessor: MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
for (unsigned int iSeed = 0; iSeed < N_SEED_PROMPT; iSeed++) {
if (matchport_[iSeed][ilayer] == -1)
continue;
memories << "FullMatch: FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg)
<< " [36]" << std::endl;
os << "FM_" << iSeedStr(iSeed) << "_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << " input=> MP_"
<< LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".matchout1 output=> FT_" << iSeedStr(iSeed)
<< ".fullmatch" << matchport_[iSeed][ilayer] << "in" << iReg + 1 << std::endl;
}
}
}
}
Expand Down Expand Up @@ -910,16 +987,50 @@ void TrackletConfigBuilder::writeASMemories(std::ostream& os, std::ostream& memo
//First write AS memories used by MatchProcessor
for (unsigned int ilayer = 0; ilayer < N_LAYER + N_DISK; ilayer++) {
for (unsigned int iReg = 0; iReg < NRegions_[ilayer]; iReg++) {
memories << "AllStubs: AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " [42]" << std::endl;
if (combinedmodules_) {
modules << "VMRouterCM: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
} else {
modules << "VMRouter: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
if (duplicateMPs_) {
if ((settings_.layersDisksDuplicatedEqualProjBalance()[ilayer] ||
settings_.layersDisksDuplicatedWeightedProjBalance()[ilayer]) &&
(iReg == 1 || iReg == 2)) {
memories << "AllStubs: AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " [42]" << std::endl;
memories << "AllStubs: AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n2"
<< " [42]" << std::endl;
if (combinedmodules_) {
modules << "VMRouterCM: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
} else {
modules << "VMRouter: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
}
os << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> MP_"
<< LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubin" << std::endl;
os << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n2"
<< " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> MP_"
<< LayerName(ilayer) << "PHI" << iTCStr(iReg) + "_E"
<< ".allstubin" << std::endl;
} else {
memories << "AllStubs: AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " [42]" << std::endl;
if (combinedmodules_) {
modules << "VMRouterCM: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
} else {
modules << "VMRouter: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
}
os << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> MP_"
<< LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubin" << std::endl;
}
} else { // non duplicate MPs configuration
memories << "AllStubs: AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " [42]" << std::endl;
if (combinedmodules_) {
modules << "VMRouterCM: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
} else {
modules << "VMRouter: VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << std::endl;
}
os << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> MP_"
<< LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubin" << std::endl;
}
os << "AS_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubout output=> MP_"
<< LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".allstubin" << std::endl;
}
}

Expand Down Expand Up @@ -1110,10 +1221,31 @@ void TrackletConfigBuilder::writeVMSMemories(std::ostream& os, std::ostream& mem
//First write VMS memories used by MatchProcessor
for (unsigned int ilayer = 0; ilayer < N_LAYER + N_DISK; ilayer++) {
for (unsigned int iReg = 0; iReg < NRegions_[ilayer]; iReg++) {
memories << "VMStubsME: VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1 [18]" << std::endl;
os << "VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstuboutPHI" << iTCStr(iReg)
<< " output=> MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstubin" << std::endl;
if (duplicateMPs_) {
if ((settings_.layersDisksDuplicatedEqualProjBalance()[ilayer] ||
settings_.layersDisksDuplicatedWeightedProjBalance()[ilayer]) &&
(iReg == 1 || iReg == 2)) {
memories << "VMStubsME: VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1 [18]" << std::endl;
memories << "VMStubsME: VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n2 [18]" << std::endl;
os << "VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstuboutPHI" << iTCStr(iReg)
<< " output=> MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstubin" << std::endl;
os << "VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n2"
<< " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstuboutPHI" << iTCStr(iReg)
<< " output=> MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) + "_E"
<< ".vmstubin" << std::endl;
} else {
memories << "VMStubsME: VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1 [18]" << std::endl;
os << "VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstuboutPHI" << iTCStr(iReg)
<< " output=> MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstubin" << std::endl;
}
} else { // non duplicate MPs configuration
memories << "VMStubsME: VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1 [18]" << std::endl;
os << "VMSME_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << "n1"
<< " input=> VMR_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstuboutPHI" << iTCStr(iReg)
<< " output=> MP_" << LayerName(ilayer) << "PHI" << iTCStr(iReg) << ".vmstubin" << std::endl;
}
}
}

Expand Down
14 changes: 7 additions & 7 deletions L1Trigger/TrackFindingTracklet/src/VMRouterCM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ VMRouterCM::VMRouterCM(string name, Settings const& settings, Globals* global)
unsigned int region = name[9] - 'A';
assert(region < settings_.nallstubs(layerdisk_));

vmstubsMEPHI_.resize(1, nullptr);

overlapbits_ = 7;
nextrabits_ = overlapbits_ - (settings_.nbitsallstubs(layerdisk_) + settings_.nbitsvmme(layerdisk_));

Expand Down Expand Up @@ -83,8 +81,7 @@ void VMRouterCM::addOutput(MemoryBase* memory, string output) {
VMStubsMEMemory* tmp = dynamic_cast<VMStubsMEMemory*>(memory);
assert(tmp != nullptr);
tmp->resize(nvmmebins_ * settings_.nvmme(layerdisk_));
assert(vmstubsMEPHI_[0] == nullptr);
vmstubsMEPHI_[0] = tmp;
vmstubsMEPHI_.push_back(tmp);
} else {
throw cms::Exception("LogicError") << __FILE__ << " " << __LINE__ << " memory: " << memory->getName()
<< " => should never get here!";
Expand Down Expand Up @@ -258,8 +255,11 @@ void VMRouterCM::execute(unsigned int) {
FPGAWord(stub->bend().value(), nbendbits, true, __LINE__, __FILE__),
allStubIndex);

if (vmstubsMEPHI_[0] != nullptr) {
vmstubsMEPHI_[0]->addStub(vmstub, ivm * nvmmebins_ + vmbin);
unsigned int nmems = vmstubsMEPHI_.size();

for (unsigned int i = 0; i < nmems; i++) { // allows multiple VMStubs to be written for duplicated MPs
if (vmstubsMEPHI_[i] != nullptr)
vmstubsMEPHI_[i]->addStub(vmstub, ivm * nvmmebins_ + vmbin);
}

//Fill the TE VM memories
Expand Down Expand Up @@ -315,4 +315,4 @@ void VMRouterCM::execute(unsigned int) {
}
}
}
}
}

0 comments on commit abfcf90

Please sign in to comment.