Commit cae5a908 authored by dauncey's avatar dauncey

Redo throttling

parent 132c746f
...@@ -22,6 +22,8 @@ public: ...@@ -22,6 +22,8 @@ public:
fPreviousThrottleActive=false; fPreviousThrottleActive=false;
fRaisedThrottleBx=-1; fRaisedThrottleBx=-1;
fEndedThrottleBx=-1; fEndedThrottleBx=-1;
fThrottleHistWeight=fBeSlinkSim->fBufferLimit;
std::ostringstream sout; std::ostringstream sout;
sout << "BeSlinkAna" << std::setw(2) << std::setfill('0') sout << "BeSlinkAna" << std::setw(2) << std::setfill('0')
...@@ -38,16 +40,23 @@ public: ...@@ -38,16 +40,23 @@ public:
const EconArch &econArch(slinkArch.econArch(e)); const EconArch &econArch(slinkArch.econArch(e));
for(unsigned b(0);b<econArch.numberOfBlocks();b++) { for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
hEventBufferUsed[e][b]=new TH1D((sout.str()+"Econ"+sHgcroc[e]+"Block"+sHgcroc[b]+"EventBufferUsed").c_str(), hEventBufferUsed[e][b]=new TH1D((sout.str()+"Econ"+sHgcroc[e]+"Block"+sHgcroc[b]+"EventBufferUsed").c_str(),
";Number of event buffer words used",1000,0,10000); ";Number of event buffer words used",1200,0,6000);
hEventBufferUsedHistory[e][b]=new TH1I((sout.str()+"Econ"+sHgcroc[e]+"Block"+sHgcroc[b]+"EventBufferUsedHistory").c_str(), hEventBufferUsedHistory[e][b]=new TH1I((sout.str()+"Econ"+sHgcroc[e]+"Block"+sHgcroc[b]+"EventBufferUsedHistory").c_str(),
";BX;Number of event buffer words used",nHistory,0,nHistory); ";BX;Number of event buffer words used",nHistory,0,nHistory);
hEventBufferExceeded[e][b]=new TH1D((sout.str()+"Econ"+sHgcroc[e]+"Block"+sHgcroc[b]+"EventBufferExceeded").c_str(), hEventBufferExceeded[e][b]=new TH1D((sout.str()+"Econ"+sHgcroc[e]+"Block"+sHgcroc[b]+"EventBufferExceeded").c_str(),
";Number of event buffer words used",1000,0,10000); ";Number of event buffer words used",1200,0,6000);
} }
} }
hEventBufferUsedMax=new TH1D((sout.str()+"EventBufferUsedMax").c_str(),
";Number of event buffer words used",1200,0,6000);
hEventBufferUsedHistoryMax=new TH1I((sout.str()+"EventBufferUsedHistoryMax").c_str(),
";BX;Number of event buffer words used",nHistory,0,nHistory);
hThrottleActiveHistory=new TH1I((sout.str()+"ThrottleActiveHistory").c_str(), hThrottleActiveHistory=new TH1I((sout.str()+"ThrottleActiveHistory").c_str(),
";BX;Throttle active",nHistory,0,nHistory); ";BX;Throttle active",nHistory,0,nHistory);
hDelayedThrottleActiveHistory=new TH1I((sout.str()+"DelayedThrottleActiveHistory").c_str(),
";BX;Delayed throttle active",nHistory,0,nHistory);
hRaisedThrottleToL1Accept=new TH1D((sout.str()+"RaisedThrottleToL1Accept").c_str(), hRaisedThrottleToL1Accept=new TH1D((sout.str()+"RaisedThrottleToL1Accept").c_str(),
";L1Accept - ended throttle (BX)",1000,0,1000); ";L1Accept - ended throttle (BX)",1000,0,1000);
hEndedThrottleToL1Accept=new TH1D((sout.str()+"EndedThrottleToL1Accept").c_str(), hEndedThrottleToL1Accept=new TH1D((sout.str()+"EndedThrottleToL1Accept").c_str(),
...@@ -60,27 +69,40 @@ public: ...@@ -60,27 +69,40 @@ public:
} }
void analyseBx(uint64_t bx) { void analyseBx(uint64_t bx) {
unsigned maxBufferUsed(0);
const SlinkArch &slinkArch(*(fBeSlinkSim->fSlinkArch)); const SlinkArch &slinkArch(*(fBeSlinkSim->fSlinkArch));
for(unsigned e(0);e<slinkArch.numberOfEcons();e++) { for(unsigned e(0);e<slinkArch.numberOfEcons();e++) {
const EconArch &econArch(slinkArch.econArch(e)); const EconArch &econArch(slinkArch.econArch(e));
for(unsigned b(0);b<econArch.numberOfBlocks();b++) { for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
hEventBufferUsed[e][b]->Fill(fBeSlinkSim->fEventBuffer[e][b].used()); const unsigned bufferUsed(fBeSlinkSim->fEventBuffer[e][b].used());
hEventBufferUsedHistory[e][b]->Fill(bx,fBeSlinkSim->fEventBuffer[e][b].used()); if(maxBufferUsed<bufferUsed) maxBufferUsed=bufferUsed;
if(fBeSlinkSim->exceededBuffer()) hEventBufferExceeded[e][b]->Fill(fBeSlinkSim->fEventBuffer[e][b].used());
hEventBufferUsed[e][b]->Fill(bufferUsed);
hEventBufferUsedHistory[e][b]->Fill(bx,bufferUsed);
if(fBeSlinkSim->exceededBuffer()) hEventBufferExceeded[e][b]->Fill(bufferUsed);
} }
} }
hEventBufferUsedMax->Fill(maxBufferUsed);
hEventBufferUsedHistoryMax->Fill(bx,maxBufferUsed);
if(fBeSlinkSim->fL1AcceptEoe) { if(fBeSlinkSim->fL1AcceptEoe) {
hTotalEventWords->Fill(16*fBeSlinkSim->fTotalNumberOfEventWords); hTotalEventWords->Fill(16*fBeSlinkSim->fTotalNumberOfEventWords);
} }
if(fBeSlinkSim->fThrottleActive) { // Add +1 as throttle is applied to next BX
if(!fPreviousThrottleActive) fRaisedThrottleBx=bx; if(fBeSlinkSim->throttleActive()) {
hThrottleActiveHistory->Fill(bx); if(!fPreviousThrottleActive) fRaisedThrottleBx=bx+1;
hThrottleActiveHistory->Fill(bx+1,fThrottleHistWeight);
} else { } else {
if(fPreviousThrottleActive) fEndedThrottleBx=bx; if(fPreviousThrottleActive) fEndedThrottleBx=bx+1;
} }
if(fBeSlinkSim->delayedThrottleActive(bx)) {
hDelayedThrottleActiveHistory->Fill(bx+1,fThrottleHistWeight-50);
}
fPreviousThrottleActive=fBeSlinkSim->fThrottleActive; fPreviousThrottleActive=fBeSlinkSim->fThrottleActive;
} }
...@@ -93,15 +115,19 @@ private: ...@@ -93,15 +115,19 @@ private:
bool fPreviousThrottleActive; bool fPreviousThrottleActive;
uint64_t fRaisedThrottleBx; uint64_t fRaisedThrottleBx;
uint64_t fEndedThrottleBx; uint64_t fEndedThrottleBx;
unsigned fThrottleHistWeight;
TH1D *hTotalEventWords; TH1D *hTotalEventWords;
TH1I *hThrottleActiveHistory; TH1I *hThrottleActiveHistory;
TH1I *hDelayedThrottleActiveHistory;
TH1D *hRaisedThrottleToL1Accept; TH1D *hRaisedThrottleToL1Accept;
TH1D *hEndedThrottleToL1Accept; TH1D *hEndedThrottleToL1Accept;
TH1D *hEventBufferUsed[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon]; TH1D *hEventBufferUsed[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
TH1I *hEventBufferUsedHistory[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon]; TH1I *hEventBufferUsedHistory[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
TH1D *hEventBufferExceeded[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon]; TH1D *hEventBufferExceeded[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
TH1D *hEventBufferUsedMax;
TH1I *hEventBufferUsedHistoryMax;
}; };
#endif #endif
...@@ -41,7 +41,8 @@ public: ...@@ -41,7 +41,8 @@ public:
*/ */
//BeSlinkSim(unsigned e, unsigned h=18, unsigned m=0) : fEcon(e) { //BeSlinkSim(unsigned e, unsigned h=18, unsigned m=0) : fEcon(e) {
BeSlinkSim() { BeSlinkSim() : fThrottleDelay(60) {
assert(fThrottleDelay<64);
} }
void boj(const SlinkArch &a, unsigned bl) { void boj(const SlinkArch &a, unsigned bl) {
...@@ -61,6 +62,8 @@ public: ...@@ -61,6 +62,8 @@ public:
fArrayWrite=0; fArrayWrite=0;
for(unsigned i(0);i<4;i++) fArrayWord[i]=0; for(unsigned i(0);i<4;i++) fArrayWord[i]=0;
for(unsigned i(0);i<64;i++) fDelayedThrottleActive[i]=false;
for(unsigned e(0);e<fSlinkArch->numberOfEcons();e++) { for(unsigned e(0);e<fSlinkArch->numberOfEcons();e++) {
const EconArch &econArch(fSlinkArch->econArch(e)); const EconArch &econArch(fSlinkArch->econArch(e));
for(unsigned b(0);b<econArch.numberOfBlocks();b++) { for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
...@@ -87,12 +90,15 @@ public: ...@@ -87,12 +90,15 @@ public:
void processBx(uint64_t bx, const SlinkElinkData &d) { void processBx(uint64_t bx, const SlinkElinkData &d) {
unsigned bufferLimit(fThrottleActive?fBufferLimit-50:fBufferLimit);
fThrottleActive=false;
fExceededBuffer=false; fExceededBuffer=false;
for(unsigned e(0);e<fSlinkArch->numberOfEcons();e++) { for(unsigned e(0);e<fSlinkArch->numberOfEcons();e++) {
const EconArch &econArch(fSlinkArch->econArch(e)); const EconArch &econArch(fSlinkArch->econArch(e));
for(unsigned b(0);b<econArch.numberOfBlocks();b++) { unsigned nBlocks(econArch.numberOfBlocks());
for(unsigned b(0);b<nBlocks;b++) {
const std::vector<unsigned> &elinkNumber(econArch.elinkNumber(b)); const std::vector<unsigned> &elinkNumber(econArch.elinkNumber(b));
uint32_t word; uint32_t word;
...@@ -101,9 +107,12 @@ public: ...@@ -101,9 +107,12 @@ public:
if(word!=0 || fEventBuffer[e][b].isCachedWriteWord()) assert(fEventBuffer[e][b].halfWriteAndIncrementPtr(word)); if(word!=0 || fEventBuffer[e][b].isCachedWriteWord()) assert(fEventBuffer[e][b].halfWriteAndIncrementPtr(word));
} }
if(fEventBuffer[e][b].used()>=4095) fExceededBuffer=true; if(fEventBuffer[e][b].used()>=bufferLimit) fThrottleActive=true;
if(fEventBuffer[e][b].used()>=(nBlocks==1?4095:584)) fExceededBuffer=true;
} }
} }
fDelayedThrottleActive[(bx+fThrottleDelay)&0x3f]=fThrottleActive;
// Output to Slink // Output to Slink
...@@ -425,7 +434,7 @@ public: ...@@ -425,7 +434,7 @@ public:
} }
#endif #endif
} }
/*
bool throttle() { bool throttle() {
if(fThrottleActive) return false; if(fThrottleActive) return false;
...@@ -435,11 +444,22 @@ public: ...@@ -435,11 +444,22 @@ public:
if(fEventBuffer[e][b].used()>=fBufferLimit) { if(fEventBuffer[e][b].used()>=fBufferLimit) {
if(fPrintLevel>5) { if(fPrintLevel>5) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::throttle() " std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::throttle() "
<< "Applying throttle" << "Buffer used = " << fEventBuffer[e][b].used()
<< ", limit = " << fBufferLimit
<< ", applying throttle"
<< std::endl; << std::endl;
} }
fThrottleActive=true; fThrottleActive=true;
return true; return true;
} else {
if(fPrintLevel>5) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::throttle() "
<< "Buffer used = " << fEventBuffer[e][b].used()
<< ", limit = " << fBufferLimit
<< ", not applying throttle"
<< std::endl;
}
} }
} }
} }
...@@ -468,6 +488,14 @@ public: ...@@ -468,6 +488,14 @@ public:
fThrottleActive=false; fThrottleActive=false;
return true; return true;
} }
*/
bool throttleActive() const {
return fThrottleActive;
}
bool delayedThrottleActive(uint64_t bx) const {
return fDelayedThrottleActive[bx&0x3f];
}
unsigned numberOfSlinkWords() const { unsigned numberOfSlinkWords() const {
return fNumberOfSlinkWords; return fNumberOfSlinkWords;
...@@ -521,6 +549,9 @@ public: ...@@ -521,6 +549,9 @@ public:
//unsigned fNumberOfWords[18]; //unsigned fNumberOfWords[18];
bool fThrottleActive; bool fThrottleActive;
const unsigned fThrottleDelay;
bool fDelayedThrottleActive[64];
bool fEventActive; bool fEventActive;
bool fExceededBuffer; bool fExceededBuffer;
unsigned fEconRead; unsigned fEconRead;
...@@ -533,7 +564,6 @@ public: ...@@ -533,7 +564,6 @@ public:
BlockCheck fBlockCheck[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon]; BlockCheck fBlockCheck[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
std::pair<bool,uint32_t> fBlockPair[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon]; std::pair<bool,uint32_t> fBlockPair[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
//unsigned fReadHgcroc[NumberOfParallelBuffers]; //unsigned fReadHgcroc[NumberOfParallelBuffers];
//unsigned fReadWord[NumberOfParallelBuffers]; //unsigned fReadWord[NumberOfParallelBuffers];
//unsigned fReadHgcrocNumber[NumberOfParallelBuffers][20]; //unsigned fReadHgcrocNumber[NumberOfParallelBuffers][20];
......
...@@ -234,6 +234,8 @@ int main(int argc, char* argv[]) { ...@@ -234,6 +234,8 @@ int main(int argc, char* argv[]) {
int initial(1); int initial(1);
if((argc%2)==0) { if((argc%2)==0) {
initial=2; initial=2;
// Nominal = 831274
unsigned nArg(0); unsigned nArg(0);
std::istringstream sArg(argv[1]); std::istringstream sArg(argv[1]);
...@@ -531,8 +533,12 @@ int main(int argc, char* argv[]) { ...@@ -531,8 +533,12 @@ int main(int argc, char* argv[]) {
//TriggerRule tr(50); //TriggerRule tr(50);
std::vector<Throttle> vEconThrottle; //std::vector<Throttle> vEconThrottle;
std::vector<Throttle> vBeThrottle; //std::vector<Throttle> vBeThrottle;
bool econAllowL1a(true);
bool beAllowL1a(true);
catchSignals(); catchSignals();
uint64_t bx; uint64_t bx;
...@@ -553,15 +559,15 @@ int main(int argc, char* argv[]) { ...@@ -553,15 +559,15 @@ int main(int argc, char* argv[]) {
bool newL1AIn(false); bool newL1AIn(false);
bool newL1AOut(false); bool newL1AOut(false);
bool econAllowL1a(true); //bool econAllowL1a(true);
for(unsigned t(0);t<vEconThrottle.size() && econAllowL1a;t++) { //for(unsigned t(0);t<vEconThrottle.size() && econAllowL1a;t++) {
econAllowL1a=vEconThrottle[t].allowL1Accept(bx); //econAllowL1a=vEconThrottle[t].allowL1Accept(bx);
} //}
bool beAllowL1a(true); //bool beAllowL1a(true);
for(unsigned t(0);t<vBeThrottle.size() && beAllowL1a;t++) { //for(unsigned t(0);t<vBeThrottle.size() && beAllowL1a;t++) {
beAllowL1a=vBeThrottle[t].allowL1Accept(bx); //beAllowL1a=vBeThrottle[t].allowL1Accept(bx);
} //}
if(!hgcrocSim.allowL1Accept()) { if(!hgcrocSim.allowL1Accept()) {
nHgcrocDeadtime++; nHgcrocDeadtime++;
...@@ -631,6 +637,7 @@ int main(int argc, char* argv[]) { ...@@ -631,6 +637,7 @@ int main(int argc, char* argv[]) {
if(doingBe) { if(doingBe) {
bool anyExceeded(false); bool anyExceeded(false);
beAllowL1a=true;
for(unsigned sl(0);sl<NumberOfSlinks;sl++) { for(unsigned sl(0);sl<NumberOfSlinks;sl++) {
if(newL1AIn) { if(newL1AIn) {
...@@ -640,13 +647,17 @@ int main(int argc, char* argv[]) { ...@@ -640,13 +647,17 @@ int main(int argc, char* argv[]) {
beSlinkSim[sl].processBx(bx,slinkElinkData[sl]); beSlinkSim[sl].processBx(bx,slinkElinkData[sl]);
/*
if(beSlinkSim[sl].throttle()) vBeThrottle.push_back(Throttle(bx)); if(beSlinkSim[sl].throttle()) vBeThrottle.push_back(Throttle(bx));
if(beSlinkSim[sl].unThrottle()) { if(beSlinkSim[sl].unThrottle()) {
assert(vBeThrottle.size()>0); assert(vBeThrottle.size()>0);
vBeThrottle[vBeThrottle.size()-1].endThrottle(bx); vBeThrottle[vBeThrottle.size()-1].endThrottle(bx);
//vBeThrottle[vBeThrottle.size()-1].print(); //vBeThrottle[vBeThrottle.size()-1].print();
} }
*/
if(beSlinkSim[sl].delayedThrottleActive(bx)) beAllowL1a=false;
if(beSlinkSim[sl].exceededBuffer()) anyExceeded=true; if(beSlinkSim[sl].exceededBuffer()) anyExceeded=true;
beSlinkAna[sl].analyseBx(bx); beSlinkAna[sl].analyseBx(bx);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment