Skip to content

Commit 9f3f40a

Browse files
author
Anders Ryd
committed
Some updates to get agreement between emulation and HLS in MP
1 parent b980fc9 commit 9f3f40a

File tree

6 files changed

+37
-177
lines changed

6 files changed

+37
-177
lines changed

TestBenches/MatchProcessor_test.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using namespace std;
2626
int main()
2727
{
2828
// Define memory patterns
29-
const string trackletProjectionPattern = "TrackletProjections*";
29+
const string trackletProjectionPattern = "TrackletProjections_MPROJ*";
3030
const string allStubPatternarray = "AllStub*";
3131
const string vmStubPatternarray = "VMStubs_VMSME*";
3232
const string fullMatchPattern = "FullMatches*";
@@ -71,6 +71,11 @@ int main()
7171
for (unsigned int ievt = 0; ievt < nevents; ++ievt) {
7272
cout << "Event: " << dec << ievt << endl;
7373

74+
// bx
75+
BXType bx = ievt;
76+
BXType bx_out;
77+
78+
7479
// read event and write to memories
7580
auto &fin_TrackletProjections = tb.files(trackletProjectionPattern);
7681
for (unsigned int i = 0; i < nTrackletProjections; i++)
@@ -85,10 +90,6 @@ int main()
8590
for (unsigned int i = 0; i < nFullMatches; i++)
8691
fullmatcharray[i].clear();
8792

88-
// bx
89-
BXType bx = ievt;
90-
BXType bx_out;
91-
9293
// Unit Under Test
9394
TOP_FUNC_(bx, tprojarray.data(), vmstub, allstub.data(), bx_out, fullmatcharray.data());
9495

@@ -106,10 +107,9 @@ int main()
106107

107108
} // end of event loop
108109

109-
// This is necessary because HLS seems to only return an 8-bit error count, so if err%256==0, the test bench can falsely pass
110+
// This is necessary because HLS seems to only return an 8-bit error count,
111+
// so if err%256==0, the test bench can falsely pass
110112
if (err > 255) err = 255;
111-
// cout << "Module actually has " << err << " errors." << endl;
112-
// return 0;
113113
return err;
114114

115115
}

TestBenches/TrackletProcessor_test.cpp

-140
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@ std::cout<<module_name[MODULE_];
122122
auto &fin_outerStubs = tb.files(outerStubPattern);
123123
auto &fin_outervmStubs = tb.files("VMStubs*");
124124
auto &fout_tpar = tb.files("TrackletParameters*");
125-
auto &fout_tproj = tb.files("TrackletProjections*");
126-
const auto &tproj_names = tb.fileNames("TrackletProjections*");
127125
// print the input files loaded
128126
std::cout << "Loaded the input files:\n";
129127
for (unsigned i = 0; i < nInnerStubMems; i++)
@@ -168,144 +166,6 @@ std::cout<<module_name[MODULE_];
168166
// compare the computed outputs with the expected ones
169167
err += compareMemWithFile<TrackletParameterMemory>(tpar, fout_tpar.at(0), ievt,
170168
"\nTrackletParameter", truncation);
171-
for (unsigned i = 0; i < tproj_names.size(); i++) {
172-
const auto &tproj_name = tproj_names.at(i);
173-
auto &fout = fout_tproj.at(i);
174-
if (tproj_name.find("_D1PHIA") != string::npos)
175-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D1PHIA], fout, ievt,
176-
"\nTrackletProjection (D1PHIA)", truncation);
177-
else if (tproj_name.find("_D1PHIB") != string::npos)
178-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D1PHIB], fout, ievt,
179-
"\nTrackletProjection (D1PHIB)", truncation);
180-
else if (tproj_name.find("_D1PHIC") != string::npos)
181-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D1PHIC], fout, ievt,
182-
"\nTrackletProjection (D1PHIC)", truncation);
183-
else if (tproj_name.find("_D1PHID") != string::npos)
184-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D1PHID], fout, ievt,
185-
"\nTrackletProjection (D1PHID)", truncation);
186-
else if (tproj_name.find("_D2PHIA") != string::npos)
187-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D2PHIA], fout, ievt,
188-
"\nTrackletProjection (D2PHIA)", truncation);
189-
else if (tproj_name.find("_D2PHIB") != string::npos)
190-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D2PHIB], fout, ievt,
191-
"\nTrackletProjection (D2PHIB)", truncation);
192-
else if (tproj_name.find("_D2PHIC") != string::npos)
193-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D2PHIC], fout, ievt,
194-
"\nTrackletProjection (D2PHIC)", truncation);
195-
else if (tproj_name.find("_D2PHID") != string::npos)
196-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D2PHID], fout, ievt,
197-
"\nTrackletProjection (D2PHID)", truncation);
198-
else if (tproj_name.find("_D3PHIA") != string::npos)
199-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D3PHIA], fout, ievt,
200-
"\nTrackletProjection (D3PHIA)", truncation);
201-
else if (tproj_name.find("_D3PHIB") != string::npos)
202-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D3PHIB], fout, ievt,
203-
"\nTrackletProjection (D3PHIB)", truncation);
204-
else if (tproj_name.find("_D3PHIC") != string::npos)
205-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D3PHIC], fout, ievt,
206-
"\nTrackletProjection (D3PHIC)", truncation);
207-
else if (tproj_name.find("_D3PHID") != string::npos)
208-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D3PHID], fout, ievt,
209-
"\nTrackletProjection (D3PHID)", truncation);
210-
else if (tproj_name.find("_D4PHIA") != string::npos)
211-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D4PHIA], fout, ievt,
212-
"\nTrackletProjection (D4PHIA)", truncation);
213-
else if (tproj_name.find("_D4PHIB") != string::npos)
214-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D4PHIB], fout, ievt,
215-
"\nTrackletProjection (D4PHIB)", truncation);
216-
else if (tproj_name.find("_D4PHIC") != string::npos)
217-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D4PHIC], fout, ievt,
218-
"\nTrackletProjection (D4PHIC)", truncation);
219-
else if (tproj_name.find("_D4PHID") != string::npos)
220-
err += compareMemWithFile<TrackletProjectionMemory<DISK> >(tproj_disk[TP::D4PHID], fout, ievt,
221-
"\nTrackletProjection (D4PHID)", truncation);
222-
else if (tproj_name.find("_L1PHIA") != string::npos)
223-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIA], fout, ievt,
224-
"\nTrackletProjection (L1PHIA)", truncation);
225-
else if (tproj_name.find("_L1PHIB") != string::npos)
226-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIB], fout, ievt,
227-
"\nTrackletProjection (L1PHIB)", truncation);
228-
else if (tproj_name.find("_L1PHIC") != string::npos)
229-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIC], fout, ievt,
230-
"\nTrackletProjection (L1PHIC)", truncation);
231-
else if (tproj_name.find("_L1PHID") != string::npos)
232-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHID], fout, ievt,
233-
"\nTrackletProjection (L1PHID)", truncation);
234-
else if (tproj_name.find("_L1PHIE") != string::npos)
235-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIE], fout, ievt,
236-
"\nTrackletProjection (L1PHIE)", truncation);
237-
else if (tproj_name.find("_L1PHIF") != string::npos)
238-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIF], fout, ievt,
239-
"\nTrackletProjection (L1PHIF)", truncation);
240-
else if (tproj_name.find("_L1PHIG") != string::npos)
241-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIG], fout, ievt,
242-
"\nTrackletProjection (L1PHIG)", truncation);
243-
else if (tproj_name.find("_L1PHIH") != string::npos)
244-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L1PHIH], fout, ievt,
245-
"\nTrackletProjection (L1PHIH)", truncation);
246-
else if (tproj_name.find("_L2PHIA") != string::npos)
247-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L2PHIA], fout, ievt,
248-
"\nTrackletProjection (L2PHIA)", truncation);
249-
else if (tproj_name.find("_L2PHIB") != string::npos)
250-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L2PHIB], fout, ievt,
251-
"\nTrackletProjection (L2PHIB)", truncation);
252-
else if (tproj_name.find("_L2PHIC") != string::npos)
253-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L2PHIC], fout, ievt,
254-
"\nTrackletProjection (L2PHIC)", truncation);
255-
else if (tproj_name.find("_L2PHID") != string::npos)
256-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L2PHID], fout, ievt,
257-
"\nTrackletProjection (L2PHID)", truncation);
258-
else if (tproj_name.find("_L3PHIA") != string::npos)
259-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L3PHIA], fout, ievt,
260-
"\nTrackletProjection (L3PHIA)", truncation);
261-
else if (tproj_name.find("_L3PHIB") != string::npos)
262-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L3PHIB], fout, ievt,
263-
"\nTrackletProjection (L3PHIB)", truncation);
264-
else if (tproj_name.find("_L3PHIC") != string::npos)
265-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L3PHIC], fout, ievt,
266-
"\nTrackletProjection (L3PHIC)", truncation);
267-
else if (tproj_name.find("_L3PHID") != string::npos)
268-
err += compareMemWithFile<TrackletProjectionMemory<BARRELPS> >(tproj_barrel_ps[TP::L3PHID], fout, ievt,
269-
"\nTrackletProjection (L3PHID)", truncation);
270-
271-
else if (tproj_name.find("_L4PHIA") != string::npos)
272-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L4PHIA], fout, ievt,
273-
"\nTrackletProjection (L4PHIA)", truncation);
274-
else if (tproj_name.find("_L4PHIB") != string::npos)
275-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L4PHIB], fout, ievt,
276-
"\nTrackletProjection (L4PHIB)", truncation);
277-
else if (tproj_name.find("_L4PHIC") != string::npos)
278-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L4PHIC], fout, ievt,
279-
"\nTrackletProjection (L4PHIC)", truncation);
280-
else if (tproj_name.find("_L4PHID") != string::npos)
281-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L4PHID], fout, ievt,
282-
"\nTrackletProjection (L4PHID)", truncation);
283-
else if (tproj_name.find("_L5PHIA") != string::npos)
284-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L5PHIA], fout, ievt,
285-
"\nTrackletProjection (L5PHIA)", truncation);
286-
else if (tproj_name.find("_L5PHIB") != string::npos)
287-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L5PHIB], fout, ievt,
288-
"\nTrackletProjection (L5PHIB)", truncation);
289-
else if (tproj_name.find("_L5PHIC") != string::npos)
290-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L5PHIC], fout, ievt,
291-
"\nTrackletProjection (L5PHIC)", truncation);
292-
else if (tproj_name.find("_L5PHID") != string::npos)
293-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L5PHID], fout, ievt,
294-
"\nTrackletProjection (L5PHID)", truncation);
295-
else if (tproj_name.find("_L6PHIA") != string::npos)
296-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L6PHIA], fout, ievt,
297-
"\nTrackletProjection (L6PHIA)", truncation);
298-
else if (tproj_name.find("_L6PHIB") != string::npos)
299-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L6PHIB], fout, ievt,
300-
"\nTrackletProjection (L6PHIB)", truncation);
301-
else if (tproj_name.find("_L6PHIC") != string::npos)
302-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L6PHIC], fout, ievt,
303-
"\nTrackletProjection (L6PHIC)", truncation);
304-
else if (tproj_name.find("_L6PHID") != string::npos)
305-
err += compareMemWithFile<TrackletProjectionMemory<BARREL2S> >(tproj_barrel_2s[TP::L6PHID], fout, ievt,
306-
"\nTrackletProjection (L6PHID)", truncation);
307-
308-
}
309169
cout << endl;
310170

311171
} // end of event loop

TrackletAlgorithm/MatchProcessor.h

+13-12
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,8 @@ void MatchCalculator(BXType bx,
913913
const AllStubMemory<ASTYPE>* allstub,
914914
const AllProjection<APTYPE>& proj,
915915
ap_uint<VMStubBase<VMSType>::kVMSIDSize> stubid,
916-
FullMatchMemory<FMTYPE> fullmatch[maxFullMatchCopies]
916+
FullMatchMemory<FMTYPE> fullmatch[maxFullMatchCopies],
917+
int istep
917918
){
918919

919920
#pragma HLS inline
@@ -1127,7 +1128,7 @@ void MatchCalculator(BXType bx,
11271128
goodmatch = true;
11281129
}
11291130

1130-
if(goodmatch) { // Write out only the best match, based on the seeding
1131+
if(goodmatch) { // Write out only the best match, based on the seeding
11311132
switch (proj_seed) {
11321133
case 0:
11331134
if(FMMask<LAYER, PHISEC, TF::L1L2>()) {
@@ -1352,7 +1353,7 @@ void MatchProcessor(BXType bx,
13521353
auto writeptr = projbufferarray.getWritePtr();
13531354
bool empty = emptyUnit<nPRBAbits>()[(readptr,writeptr)];
13541355
bool projBuffNearFull = nearFull4Unit<nPRBAbits>()[(readptr,writeptr)];
1355-
1356+
13561357
ap_uint<3> iphi = 0;
13571358

13581359
ap_uint<kNMatchEngines> idles;
@@ -1377,10 +1378,11 @@ void MatchProcessor(BXType bx,
13771378
}
13781379

13791380
//This printout exactly matches printout in emulation for tracking code differences
1380-
/*
1381-
for(int iMEU = 0; iMEU < kNMatchEngines; ++iMEU) {
1382-
std::cout << " MEU"<<iMEU<<" "<<matchengine[iMEU].readIndex()<<" "<<matchengine[iMEU].writeIndex()<<" "<<matchengine[iMEU].idle()
1383-
<<" "<<matchengine[iMEU].empty()<<" "<<matchengine[iMEU].getTrkID();
1381+
/*
1382+
std::cout << "istep = " << istep << " projBuff: " << readptr << " " << writeptr << " " << projBuffNearFull;
1383+
for(unsigned int iMEU = 0; iMEU < kNMatchEngines; ++iMEU) {
1384+
std::cout << " MEU"<<iMEU<<" "<<matchengine[iMEU].readIndex()<<" "<<matchengine[iMEU].writeIndex()<<" "
1385+
<<matchengine[iMEU].idle()<<" "<<matchengine[iMEU].empty()<<" "<<matchengine[iMEU].getProjSeq();
13841386
}
13851387
std::cout << std::endl;
13861388
*/
@@ -1403,14 +1405,12 @@ void MatchProcessor(BXType bx,
14031405
hasMatch = (!emptys[bestiMEU]) && cleanpipeline[bestiMEU];
14041406

14051407
bestProjSeq = projseqs[bestiMEU];
1406-
1407-
projseq0123 = (projseq01 < projseq23) ? projseq01 : projseq23;
1408-
1408+
14091409
projseq01 = (matchengine[0].getProjSeqStart() < matchengine[1].getProjSeqStart()) ? matchengine[0].getProjSeqStart() : matchengine[1].getProjSeqStart();
14101410
projseq23 = (matchengine[2].getProjSeqStart() < matchengine[3].getProjSeqStart()) ? matchengine[2].getProjSeqStart() : matchengine[3].getProjSeqStart();
14111411

1412+
projseq0123 = (projseq01 < projseq23) ? projseq01 : projseq23;
14121413

1413-
14141414
/*
14151415
// old code - keep for now
14161416
ap_uint<kNMatchEngines> smallest = ~emptys;
@@ -1458,9 +1458,10 @@ void MatchProcessor(BXType bx,
14581458

14591459
if (hasMatch_save) {
14601460
isMatch = newtracklet_save ? ap_uint<1>(0) : isMatch;
1461+
14611462
MatchCalculator<ASTYPE, APTYPE, VMSType, FMTYPE, maxFullMatchCopies, LAYER, PHISEC>
14621463
(bx, newtracklet_save, isMatch, savedMatch, best_delta_z, best_delta_phi, best_delta_rphi, best_delta_r, allstub, allproj_save, stubindex_save,
1463-
fullmatch);
1464+
fullmatch, istep);
14641465
}
14651466

14661467

TrackletAlgorithm/MemoryTemplateBinnedCM.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,12 @@ class MemoryTemplateBinnedCM{
238238

239239
ap_uint<kNBitsRZBinCM> ibin;
240240
ap_uint<kNBitsphibinCM> ireg;
241-
(ireg,ibin)=slot;
241+
(ibin, ireg)=slot;
242242
ap_uint<4> nentry_ibx = nentries_[ibx*kNBinsRZ+ibin].range(ireg*4+3,ireg*4);
243243

244244
DataType data(datastr.c_str(), base);
245245

246-
int slot2 = (ibin,ireg); //swap order, should be changed in the input files
247-
248-
bool success = write_mem(ibx, slot2, data, nentry_ibx);
246+
bool success = write_mem(ibx, slot, data, nentry_ibx);
249247

250248
return success;
251249
}

emData/download.sh

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
54
#### generated with branch VMSMERouterCMSSW13, commit a2c799d ####
65
# Combined modules
76
memprints_url_cm="https://cernbox.cern.ch/remote.php/dav/public-files/P2URd03nlGDfpDt/MemPrints.tar.gz"
87
luts_url_cm="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_Combined_231208.tgz"
98
# Split modules - i.e. with PC and VMSMER
10-
memprints_url_split="https://ahart.web.cern.ch/ahart/tf/test_vectors/MemPrints_Split_240607.tgz"
11-
luts_url_split="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_Split_240607.tgz"
9+
memprints_url_split="https://cernbox.cern.ch/remote.php/dav/public-files/MUMRM6yWEBSDWiQ/MemPrints_Split_241116.tgz"
10+
luts_url_split="https://cernbox.cern.ch/remote.php/dav/public-files/lKAs7GNBTXKfR9d/LUTs_Split_241116.tgz"
1211
# Reduced Combined modules
1312
memprints_url_reducedcm="https://cernbox.cern.ch/remote.php/dav/public-files/kv2U49bw93chvZG/MemPrints_CMReduced_040424.tar.gz"
1413
luts_url_reducedcm="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_CMReduced_240121.tgz"
@@ -19,6 +18,7 @@ luts_url_cm2="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_CMReduced2_24
1918
memprints_url_cmbarrel="https://cernbox.cern.ch/remote.php/dav/public-files/lVII5Ho0VX7nwFA/MemPrints_Barrel_040424.tar.gz"
2019
luts_url_cmbarrel="https://ahart.web.cern.ch/ahart/tf/test_vectors/LUTs_Barrel_240121.tgz"
2120

21+
2222
# Function that prints information regarding the usage of this command
2323
function usage() {
2424
echo "$(basename $0) [-h|--help] [-t|--tables]"
@@ -67,10 +67,14 @@ fi
6767
# Download and unpack LUTs.tar.gz,
6868
# unless LUTS directory already exists (due to previous "download.sh -t" run).
6969

70+
7071
if [ ! -d "LUTs" ]
7172
then
73+
echo "Here10"
7274
wget --no-check-certificate -O LUTs.tgz --quiet ${luts_url_split}
75+
echo "Here11"
7376
tar -xzmf LUTs.tgz
77+
echo "Here12"
7478
mv LUTs LUTsSplit
7579
rm -f LUTs.tgz
7680
wget --no-check-certificate -O LUTs.tgz --quiet ${luts_url_reducedcm}
@@ -91,6 +95,9 @@ then
9195
rm -f LUTs.tgz
9296
fi
9397

98+
echo "Here2"
99+
100+
94101
# Run scripts to generate top functions in TopFunctions/
95102
### combined config
96103
mkdir -p ../TopFunctions/CombinedConfig

0 commit comments

Comments
 (0)