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

Optimize MP for CMSSW CPU resources #351

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions TrackletAlgorithm/MatchEngineUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ inline void step(const VMStub<VMSType> stubmem[4][1<<(kNbitsrzbinMP+kNbitsphibin
#endif

inline void set_empty() {
empty_ = emptyUnit<MatchEngineUnitBase<VMProjType>::kNBitsBuffer>()[(readindex_,writeindex_)];
static const EmptyUnitClass<MatchEngineUnitBase<VMProjType>::kNBitsBuffer> EmptyUnitClass;
empty_ = EmptyUnitClass.lut[(readindex_,writeindex_)];
//empty_ = emptyUnit<MatchEngineUnitBase<VMProjType>::kNBitsBuffer>()[(readindex_,writeindex_)];
}

inline bool empty() const {
Expand All @@ -291,7 +293,9 @@ inline void step(const VMStub<VMSType> stubmem[4][1<<(kNbitsrzbinMP+kNbitsphibin
}

inline bool nearFull() {
return nearFull3Unit<MatchEngineUnitBase<VMProjType>::kNBitsBuffer>()[(readindex_,writeindex_)];
static const NearFull3Class<MatchEngineUnitBase<VMProjType>::kNBitsBuffer> NearFull3Class;
return NearFull3Class.lut[(readindex_,writeindex_)];
//return nearFull3Unit<MatchEngineUnitBase<VMProjType>::kNBitsBuffer>()[(readindex_,writeindex_)];
}

inline bool idle() {
Expand Down
37 changes: 36 additions & 1 deletion TrackletAlgorithm/MatchEngineUnit_parameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,28 @@ static bool nearFullUnitBool(ap_uint<kNBitsBuffer> rptr, ap_uint<kNBitsBuffer> w
return wptr1==rptr || wptr2==rptr;
}

template<int kNBitsBuffer>
class NearFull3Class {
public:
ap_uint<(1 << (2 * kNBitsBuffer))> lut;
NearFull3Class() {
for (unsigned int i = 0; i < (1 << (2 * kNBitsBuffer)); i++) {
// Store complicated calculation in LUT array
ap_uint<kNBitsBuffer> wptr, rptr;
ap_uint<2 * kNBitsBuffer> address(i);
(rptr,wptr) = address;
ap_uint<kNBitsBuffer> wptr1 = wptr+1;
ap_uint<kNBitsBuffer> wptr2 = wptr+2;
ap_uint<kNBitsBuffer> wptr3 = wptr+3;
bool result = wptr1==rptr || wptr2==rptr || wptr3==rptr;
lut[i] = result;
}
}
};

template<int kNBitsBuffer>
static const ap_uint<(1 << (2 * kNBitsBuffer))> nearFull3Unit() {
ap_uint<(1 << (2 * kNBitsBuffer))> lut;
static ap_uint<(1 << (2 * kNBitsBuffer))> lut;
for(int i = 0; i < (1 << (2 * kNBitsBuffer)); ++i) {
#pragma HLS unroll
ap_uint<kNBitsBuffer> wptr, rptr;
Expand Down Expand Up @@ -80,6 +99,22 @@ static bool nearFull4UnitBool(ap_uint<kNBitsBuffer> rptr, ap_uint<kNBitsBuffer>
return wptr1==rptr || wptr2==rptr || wptr3==rptr || wptr4==rptr;
}

template<int kNBitsBuffer>
class EmptyUnitClass {
public:
ap_uint<(1 << (2 * kNBitsBuffer))> lut;
EmptyUnitClass() {
for (unsigned int i = 0; i < (1 << (2 * kNBitsBuffer)); i++) {
// Store complicated calculation in LUT array
ap_uint<kNBitsBuffer> wptr, rptr;
ap_uint<2 * kNBitsBuffer> address(i);
(rptr,wptr) = address;
bool result = wptr==rptr;
lut[i] = result;
}
}
};

template<int kNBitsBuffer>
static const ap_uint<(1 << (2 * kNBitsBuffer))> emptyUnit() {
ap_uint<(1 << (2 * kNBitsBuffer))> lut;
Expand Down
Loading