Skip to content

Commit

Permalink
Optimization to selecting MEU to readout out
Browse files Browse the repository at this point in the history
  • Loading branch information
Anders Ryd committed Jul 15, 2024
1 parent 785d552 commit 8f85d34
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
19 changes: 16 additions & 3 deletions TrackletAlgorithm/MatchEngineUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,28 @@ inline ap_uint<kNBits_MemAddr> getProjSeqOld() {
return projseq_;
}

//
// Get start of projseq pipeline
//
inline ap_uint<kNBits_MemAddr> getProjSeqStart() {
#pragma HLS inline
if (idle_) {
ap_uint<kNBits_MemAddr> tmp(0);
return ~tmp;
}
return projseq_;
}



inline ap_uint<kNBits_MemAddr> getProjSeq() {
#pragma HLS inline
#pragma HLS array_partition variable=projseqs_ complete

return empty()?(good____?projseq____:projseqcache_):projseqs_[readindex_];
//return empty()?(good____?projseq____:projseqcache_):projseqs_[readindex_];
//Temporary hack to see how this improves timing
//ap_uint<kNBits_MemAddr> tmp(0);
//return empty()?(~tmp):projseqs_[readindex_];
ap_uint<kNBits_MemAddr> tmp(0);
return empty()?(~tmp):projseqs_[readindex_];
}

inline typename VMProjection<VMProjType>::VMPID getProjindex() {
Expand Down
19 changes: 18 additions & 1 deletion TrackletAlgorithm/MatchProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,12 @@ void MatchProcessor(BXType bx,
ap_uint<2> bestiMEU = 0;
bool increase = false;

ap_uint<kNBits_MemAddr> tmp(0);
ap_uint<kNBits_MemAddr> projseq0123 = ~tmp;
ap_uint<kNBits_MemAddr> projseq01 = ~tmp;
ap_uint<kNBits_MemAddr> projseq23 = ~tmp;


// constants used in reading VMSME memories
constexpr int NUM_PHI_BINS = 1 << kNbitsphibin;
constexpr int BIN_ADDR_WIDTH = 4;
Expand Down Expand Up @@ -1380,10 +1386,21 @@ void MatchProcessor(BXType bx,
ap_uint<1> Bit31 = projseqs[3] < projseqs[1];
ap_uint<1> Bit32 = projseqs[3] < projseqs[2];

bool cleanpipeline[4] = {projseqs[0] <= projseq0123, projseqs[1] <= projseq0123, projseqs[2] <= projseq0123, projseqs[3] <= projseq0123};

// std::cout << "cleapipeline projseq0123_ : " << cleanpipeline << " " << projseq0123_ << " " << matchengine[0].nearFull() << " " << matchengine[1].nearFull() << " " << matchengine[2].nearFull() << " " << matchengine[3].nearFull() << " | " << matchengine[0].getProjSeqStart() << " " << matchengine[1].getProjSeqStart() << " " << matchengine[2].getProjSeqStart() << " " << matchengine[3].getProjSeqStart() << " | " << matchengine[0].getProjSeq() << " " << matchengine[1].getProjSeq() << " " << matchengine[2].getProjSeq() << " " << matchengine[3].getProjSeq() << std::endl;

bestiMEU = ((Bit10 | Bit20 | Bit30) & (Bit31 | Bit21 | ~Bit10) , (Bit10 | Bit20 | Bit30) & (Bit32 | ~Bit21 | ~Bit20));

hasMatch = !emptys[bestiMEU];
hasMatch = (!emptys[bestiMEU]) && cleanpipeline[bestiMEU];

projseq0123 = (projseq01 < projseq23) ? projseq01 : projseq23;

projseq01 = (matchengine[0].getProjSeqStart() < matchengine[1].getProjSeqStart()) ? matchengine[0].getProjSeqStart() : matchengine[1].getProjSeqStart();
projseq23 = (matchengine[2].getProjSeqStart() < matchengine[3].getProjSeqStart()) ? matchengine[2].getProjSeqStart() : matchengine[3].getProjSeqStart();



/*
// old code - keep for now
ap_uint<kNMatchEngines> smallest = ~emptys;
Expand Down

0 comments on commit 8f85d34

Please sign in to comment.