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

Support for Multiple MPs (including new TrackBuilder) #353

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
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
Next Next commit
First version of code to combine TBs from 8 -> 2
Anders Ryd committed Dec 7, 2024
commit 4f2e92061c3110116cc981e5fe1f411f87ba1a09
18 changes: 10 additions & 8 deletions TestBenches/Macros.h
Original file line number Diff line number Diff line change
@@ -35,14 +35,16 @@ X(PC_D3D4ABCD_, "PC_D3D4ABCD") \
X(PC_L1D1ABCD_, "PC_L1D1ABCD") \
X(PC_L1D1EFGH_, "PC_L1D1EFGH") \
X(PC_L2D1ABCD_, "PC_L2D1ABCD") \
X(FT_D1D2_, "FT_D1D2") \
X(FT_D3D4_, "FT_D3D4") \
X(FT_L1D1_, "FT_L1D1") \
X(FT_L1L2_, "FT_L1L2") \
X(FT_L2D1_, "FT_L2D1") \
X(FT_L2L3_, "FT_L2L3") \
X(FT_L3L4_, "FT_L3L4") \
X(FT_L5L6_, "FT_L5L6") \
X(TB_D1D2_, "TB_D1D2") \
X(TB_D3D4_, "TB_D3D4") \
X(TB_L1D1_, "TB_L1D1") \
X(TB_L1L2_, "TB_L1L2") \
X(TB_L2D1_, "TB_L2D1") \
X(TB_L2L3_, "TB_L2L3") \
X(TB_L3L4_, "TB_L3L4") \
X(TB_L5L6_, "TB_L5L6") \
X(TB_AAAA_, "TB_AAAA") \
X(TB_BBBB_, "TB_BBBB") \
X(IR_2S_1_A_, "IR_2S_1_A") \
X(IR_2S_1_B_, "IR_2S_1_B") \
X(IR_2S_2_A_, "IR_2S_2_A") \
39 changes: 7 additions & 32 deletions TestBenches/TrackBuilder_test.cpp
Original file line number Diff line number Diff line change
@@ -4,49 +4,24 @@
#include "Macros.h"
#include "FileReadUtility.h"

const int nevents = 100; //number of events to run
const int nevents = 5; //number of events to run

using namespace std;

// No macros can be defined from the command line in the case of C/RTL
// cosimulation, so we define defaults here.
#if !defined SEED_
#define SEED_ L1L2_
#define SEED_ AAAA_
#endif
#if !defined MODULE_
#define MODULE_ FT_L1L2_
#define MODULE_ TB_AAAA_
#endif
#if !defined TOP_FUNC_
#define TOP_FUNC_ TrackBuilder_L1L2
#define TOP_FUNC_ TrackBuilder_AAAA
#endif

#if SEED_ == L1L2_
constexpr int kNBarrelStubs = 4;
constexpr int kNDiskStubs = 4;
#elif SEED_ == L2L3_
constexpr int kNBarrelStubs = 3;
constexpr int kNDiskStubs = 4;
#elif SEED_ == L3L4_
constexpr int kNBarrelStubs = 4;
constexpr int kNDiskStubs = 2;
#elif SEED_ == L5L6_
constexpr int kNBarrelStubs = 4;
constexpr int kNDiskStubs = 0;
#elif SEED_ == D1D2_
constexpr int kNBarrelStubs = 2;
constexpr int kNDiskStubs = 3;
#elif SEED_ == D3D4_
constexpr int kNBarrelStubs = 1;
constexpr int kNDiskStubs = 3;
#elif SEED_ == L1D1_
constexpr int kNBarrelStubs = 0;
constexpr int kNDiskStubs = 4;
#elif SEED_ == L2D1_
constexpr int kNBarrelStubs = 1;
constexpr int kNDiskStubs = 3;
#else
# error "Undefined seed"
#endif
constexpr int kNBarrelStubs = 6;
constexpr int kNDiskStubs = 5;

typedef TrackFit<kNBarrelStubs, kNDiskStubs> TrackFit_t;
typedef TrackFitMemory<kNBarrelStubs, kNDiskStubs> TrackFitMemory_t;
@@ -94,7 +69,7 @@ void compareStubsWithFile<0>(int &err, ifstream &fout, const int pos, const Trac

int main()
{
TBHelper tb(string("FT/") + module_name[MODULE_]);
TBHelper tb(string("TB/") + module_name[MODULE_]);

// error counts
int err = 0;
2 changes: 1 addition & 1 deletion TrackletAlgorithm/Constants.h
Original file line number Diff line number Diff line change
@@ -286,7 +286,7 @@ enum regionType {BARRELPS, BARREL2S, BARRELOL, BARREL, DISKPS, DISK2S, DISK, BAR

namespace TF {
// List of seeds
enum seed {UNDEF_SEED, L1L2 = 0, L2L3 = 1, L3L4 = 2, L5L6 = 3, D1D2 = 4, D3D4 = 5, L1D1 = 6, L2D1 = 7};
enum seed {UNDEF_SEED, L1L2 = 0, L2L3 = 1, L3L4 = 2, L5L6 = 3, D1D2 = 4, D3D4 = 5, L1D1 = 6, L2D1 = 7, AAAA = 8, BBBB = 9};

// List of layers and disks
enum layerDisk {L1 = 0, L2 = 1, L3 = 2, L4 = 3, L5 = 4, L6 = 5, D1 = 6, D2 = 7, D3 = 8, D4 = 9, D5 = 10};
85 changes: 77 additions & 8 deletions TrackletAlgorithm/TrackBuilder.h
Original file line number Diff line number Diff line change
@@ -234,13 +234,73 @@ void TrackBuilder(
// with the minimum tracklet ID.
const TCIDType &TCID = (min_id != kInvalidTrackletID) ? (min_id >> kNBits_MemAddr) : TrackletIDType(0);
const ITCType &iTC = TCID.range(kNBitsITC - 1, 0);
const auto mparNPages = getMPARNPages<Seed>(iTC);
const auto mparMem = getMPARMem<Seed>(iTC);
const auto mparPage = getMPARPage<Seed>(iTC);
typename TrackFit<NBarrelStubs, NDiskStubs>::TFSEEDTYPE iseed = TCID >> kNBitsITC; //TCID.range(3+kNBitsITC-1,kNBitsITC);
auto mparNPages = getMPARNPages<Seed>(iTC);
auto mparMem = getMPARMem<Seed>(iTC);
auto mparPage = getMPARPage<Seed>(iTC);
//This block is for AAAA
if (iseed==0) {
if (iTC==0) {mparNPages=3; mparMem=0; mparPage=0;}
if (iTC==1) {mparNPages=3; mparMem=0; mparPage=1;}
if (iTC==2) {mparNPages=3; mparMem=0; mparPage=2;}
if (iTC==3) {mparNPages=2; mparMem=0; mparPage=0;}
if (iTC==4) {mparNPages=2; mparMem=0; mparPage=1;}
if (iTC==5) {mparNPages=1; mparMem=0; mparPage=0;}
if (iTC==6) {mparNPages=1; mparMem=1; mparPage=0;}
if (iTC==7) {mparNPages=2; mparMem=1; mparPage=0;}
if (iTC==8) {mparNPages=2; mparMem=1; mparPage=1;}
if (iTC==9) {mparNPages=3; mparMem=1; mparPage=0;}
if (iTC==10) {mparNPages=3; mparMem=1; mparPage=1;}
if (iTC==11) {mparNPages=3; mparMem=1; mparPage=2;}
}
if (iseed==1) {
if (iTC==0) {mparNPages=4; mparMem=0; mparPage=0;}
if (iTC==1) {mparNPages=4; mparMem=0; mparPage=1;}
if (iTC==2) {mparNPages=4; mparMem=0; mparPage=2;}
if (iTC==3) {mparNPages=4; mparMem=0; mparPage=3;}
}
if (iseed==3) {
if (iTC==0) {mparNPages=4; mparMem=1; mparPage=0;}
if (iTC==1) {mparNPages=4; mparMem=1; mparPage=1;}
if (iTC==2) {mparNPages=4; mparMem=1; mparPage=2;}
if (iTC==3) {mparNPages=4; mparMem=1; mparPage=3;}
}
if (iseed==7) {
if (iTC==0) {mparNPages=4; mparMem=2; mparPage=0;}
if (iTC==1) {mparNPages=4; mparMem=2; mparPage=1;}
if (iTC==2) {mparNPages=4; mparMem=2; mparPage=2;}
if (iTC==3) {mparNPages=4; mparMem=2; mparPage=3;}
}
//This block is for BBBB
if (iseed==2) {
if (iTC==0) {mparNPages=2; mparMem=0; mparPage=0;}
if (iTC==1) {mparNPages=2; mparMem=0; mparPage=1;}
if (iTC==2) {mparNPages=2; mparMem=1; mparPage=0;}
if (iTC==3) {mparNPages=2; mparMem=1; mparPage=1;}
}
if (iseed==4) {
if (iTC==0) {mparNPages=4; mparMem=0; mparPage=0;}
if (iTC==1) {mparNPages=4; mparMem=0; mparPage=1;}
if (iTC==2) {mparNPages=4; mparMem=0; mparPage=2;}
if (iTC==3) {mparNPages=4; mparMem=0; mparPage=3;}
}
if (iseed==5) {
if (iTC==0) {mparNPages=4; mparMem=1; mparPage=0;}
if (iTC==1) {mparNPages=4; mparMem=1; mparPage=1;}
if (iTC==2) {mparNPages=4; mparMem=1; mparPage=2;}
if (iTC==3) {mparNPages=4; mparMem=1; mparPage=3;}
}
if (iseed==6) {
if (iTC==0) {mparNPages=4; mparMem=2; mparPage=0;}
if (iTC==1) {mparNPages=4; mparMem=2; mparPage=1;}
if (iTC==2) {mparNPages=4; mparMem=2; mparPage=2;}
if (iTC==3) {mparNPages=4; mparMem=2; mparPage=3;}
}

const IndexType &trackletIndex = (min_id != kInvalidTrackletID) ? (min_id & TrackletIDType(0x7F)) : TrackletIDType(0);
const typename TrackFit<NBarrelStubs, NDiskStubs>::TFPHIREGION phiRegionOuter = iTC / (Seed == TF::L1L2 ? 3 : (Seed == TF::L1D1 ? 2 : 1));
TrackFit<NBarrelStubs, NDiskStubs> track(typename TrackFit<NBarrelStubs, NDiskStubs>::TFSEEDTYPE(TCID >> kNBitsITC));
const typename TrackFit<NBarrelStubs, NDiskStubs>::TFPHIREGION phiRegionOuter = iTC / (iseed == TF::L1L2 ? 3 : (iseed == TF::L1D1 ? 2 : 1));

TrackFit<NBarrelStubs, NDiskStubs> track(iseed);
track.setPhiRegionOuter(phiRegionOuter);
if ((TPARMask & 0x1) && mparNPages == 1) {
const auto &tpar = trackletParameters1[mparMem].read_mem(bx, trackletIndex);
@@ -267,7 +327,7 @@ void TrackBuilder(
//This is a hack to match the emulation where for D1D2 seeds
//We don't use both L2 and D3 matches
bool barrelD1D2Match1 = false;

barrel_stub_association : for (short j = 0; j < NBarrelStubs; j++) {

const auto &barrel_stub = merger_L_top[j].peek();
@@ -374,7 +434,7 @@ void TrackBuilder(
// Only tracks with at least two matches are valid.
track.setTrackValid(!done && (nMatches >= kMinNMatches));

// Output the track word and eight stub words associated with the TrackFit
// Output the track word and eleven stub words associated with the TrackFit
// object that was constructed.
trackWord[nTracks] = track.getTrackWord();
barrel_stub_words: for (short j = 0 ; NBarrelStubs > 0 && j < NBarrelStubs; j++) { // Note: need to have NBarrelStubs > 0 to prevent compilation error due to -Werror=type-limits flag in CMSSW
@@ -391,6 +451,12 @@ void TrackBuilder(
case 3:
barrelStubWords[j][nTracks] = track.template getBarrelStubWord<3>();
break;
case 4:
barrelStubWords[j][nTracks] = track.template getBarrelStubWord<4>();
break;
case 5:
barrelStubWords[j][nTracks] = track.template getBarrelStubWord<5>();
break;
}
}
disk_stub_words: for (short j = 0 ; NDiskStubs > 0 && j < NDiskStubs; j++) { // Note: need to have NDiskStubs > 0 to prevent compilation error due to -Werror=type-limits flag in CMSSW
@@ -407,6 +473,9 @@ void TrackBuilder(
case 3:
diskStubWords[j][nTracks] = track.template getDiskStubWord<NBarrelStubs + 3>();
break;
case 4:
diskStubWords[j][nTracks] = track.template getDiskStubWord<NBarrelStubs + 4>();
break;
}
}
nTracks += (track.getTrackValid() ? 1 : 0);
4 changes: 2 additions & 2 deletions TrackletAlgorithm/TrackFitMemory.h
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ class TrackFitBase
kTFZ0Size = 10,
kTFTSize = 14,
kTFHitCountSize = 3,
kTFHitMapSize = kTFHitCountSize * 8,
kTFHitMapSize = kTFHitCountSize * kNStubs,
// Bit size for stub word fields
kTFTrackIndexSize = 7,
kTFStubIndexSize = 10,
@@ -89,7 +89,7 @@ class TrackFitBits : public TrackFitBase<NBarrelStubs, NDiskStubs>
return (kTFStubValidLSB(i) + TrackFitBase<NBarrelStubs, NDiskStubs>::kTFValidSize - 1);
}
static constexpr unsigned kTFHitCountSizeLSB(const int i) {
return (kTFStubValidMSB(0) + (7 - i) * TrackFitBase<NBarrelStubs, NDiskStubs>::kTFHitCountSize + 1);
return (kTFStubValidMSB(0) + (kNStubs -1 - i) * TrackFitBase<NBarrelStubs, NDiskStubs>::kTFHitCountSize + 1);
}
static constexpr unsigned kTFHitCountSizeMSB(const int i) {
return (kTFHitCountSizeLSB(i) + TrackFitBase<NBarrelStubs, NDiskStubs>::kTFHitCountSize - 1);
6 changes: 3 additions & 3 deletions emData/download.sh
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ set -e
memprints_url_cm="https://cernbox.cern.ch/remote.php/dav/public-files/P2URd03nlGDfpDt/MemPrints.tar.gz"
luts_url_cm="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_Combined_231208.tgz"
# Split modules - i.e. with PC and VMSMER
memprints_url_split="https://cernbox.cern.ch/remote.php/dav/public-files/MUMRM6yWEBSDWiQ/MemPrints_Split_241116.tgz"
luts_url_split="https://cernbox.cern.ch/remote.php/dav/public-files/lKAs7GNBTXKfR9d/LUTs_Split_241116.tgz"
memprints_url_split="https://cernbox.cern.ch/remote.php/dav/public-files/l6gnLJvrUqy2PFB/MemPrints_Split_241207.tgz"
luts_url_split="https://cernbox.cern.ch/remote.php/dav/public-files/k8e3BOB6RPwN4Ym/LUTs_Split_241207.tgz"
# Reduced Combined modules
memprints_url_reducedcm="https://cernbox.cern.ch/remote.php/dav/public-files/kv2U49bw93chvZG/MemPrints_CMReduced_040424.tar.gz"
luts_url_reducedcm="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_CMReduced_240121.tgz"
@@ -286,7 +286,7 @@ fi
# https://forums.xilinx.com/t5/Installation-and-Licensing/Vivado-2016-4-on-Ubuntu-16-04-LTS-quot-awk-symbol-lookup-error/td-p/747165
unset LD_LIBRARY_PATH

mod_types=(IR FT PD VMRCM VMSMER TP MP PC)
mod_types=(IR TB PD VMRCM VMSMER TP MP PC)

for module_type in ${mod_types[@]}
do
14 changes: 12 additions & 2 deletions emData/generate_MP.py
Original file line number Diff line number Diff line change
@@ -11,8 +11,18 @@
import sys
import argparse

TF_index = ['L1L2', 'L2L3', 'L3L4', 'L5L6', 'D1D2', 'D3D4', 'L1D1', 'L2D1']
TF_index = {k:v for v,k in enumerate(TF_index)}
TF_index = {}
TF_index['L1L2'] = 0
TF_index['L2L3'] = 0
TF_index['L3L4'] = 1
TF_index['L5L6'] = 0
TF_index['D1D2'] = 1
TF_index['D3D4'] = 1
TF_index['L1D1'] = 1
TF_index['L2D1'] = 0
TF_index['AAAA'] = 0
TF_index['BBBB'] = 1


maxTPMems = "constexpr int maxTPMemories["
maxFMMems = "constexpr int maxFMMemories["
6 changes: 3 additions & 3 deletions emData/generate_TB.py
Original file line number Diff line number Diff line change
@@ -64,10 +64,10 @@ class ITC(Enum):
barrelFMMems = {}
diskFMMems = {}
for line in wiresFile:
if " FT_" not in line:
if " TB_" not in line:
continue
line = line.rstrip()
tbName = re.sub(r".*FT_(....).*", r"FT_\1", line)
tbName = re.sub(r".*TB_(....).*", r"TB_\1", line)
seed = tbName.split("_")[1]
memName = line.split()[0]
partype = "TPAR"
@@ -129,7 +129,7 @@ class ITC(Enum):

# Calculate parameters and print out top function for each TB.
for tbName in sorted(tparMems.keys()):
seed = re.sub(r"FT_(....)", r"\1", tbName)
seed = re.sub(r"TB_(....)", r"\1", tbName)
seedNumber = None
if seed == "L1L2":
seedNumber = 0
12 changes: 3 additions & 9 deletions project/script_TB.tcl
Original file line number Diff line number Diff line change
@@ -9,14 +9,8 @@ source env_hls.tcl
# FIXME: FT_D1D2 is excluded for now because it currently produces extra
# entries compared to the emulation
set modules_to_test {
{FT_L1L2}
{FT_L2L3}
{FT_L3L4}
{FT_L5L6}
{FT_D1D2}
{FT_D3D4}
{FT_L1D1}
{FT_L2D1}
{TB_AAAA}
{TB_BBBB}
}
# module_to_export must correspond to the default macros set at the top of the
# test bench; otherwise, the C/RTL cosimulation will fail
@@ -31,7 +25,7 @@ add_files ../TopFunctions/CombinedConfig_FPGA2/TrackBuilderTop.cc -cflags "$CFLA
add_files -tb ../TestBenches/TrackBuilder_test.cpp -cflags "$CFLAGS"

# data files
add_files -tb ../emData/FT/
add_files -tb ../emData/TB/

foreach i $modules_to_test {
puts [join [list "======== TESTING " $i " ========"] ""]