Commit cae5a908 authored by dauncey's avatar dauncey

Redo throttling

parent 132c746f
......@@ -22,6 +22,8 @@ public:
fPreviousThrottleActive=false;
fRaisedThrottleBx=-1;
fEndedThrottleBx=-1;
fThrottleHistWeight=fBeSlinkSim->fBufferLimit;
std::ostringstream sout;
sout << "BeSlinkAna" << std::setw(2) << std::setfill('0')
......@@ -38,16 +40,23 @@ public:
const EconArch &econArch(slinkArch.econArch(e));
for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
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(),
";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(),
";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(),
";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(),
";L1Accept - ended throttle (BX)",1000,0,1000);
hEndedThrottleToL1Accept=new TH1D((sout.str()+"EndedThrottleToL1Accept").c_str(),
......@@ -60,27 +69,40 @@ public:
}
void analyseBx(uint64_t bx) {
unsigned maxBufferUsed(0);
const SlinkArch &slinkArch(*(fBeSlinkSim->fSlinkArch));
for(unsigned e(0);e<slinkArch.numberOfEcons();e++) {
const EconArch &econArch(slinkArch.econArch(e));
for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
hEventBufferUsed[e][b]->Fill(fBeSlinkSim->fEventBuffer[e][b].used());
hEventBufferUsedHistory[e][b]->Fill(bx,fBeSlinkSim->fEventBuffer[e][b].used());
if(fBeSlinkSim->exceededBuffer()) hEventBufferExceeded[e][b]->Fill(fBeSlinkSim->fEventBuffer[e][b].used());
const unsigned bufferUsed(fBeSlinkSim->fEventBuffer[e][b].used());
if(maxBufferUsed<bufferUsed) maxBufferUsed=bufferUsed;
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) {
hTotalEventWords->Fill(16*fBeSlinkSim->fTotalNumberOfEventWords);
}
if(fBeSlinkSim->fThrottleActive) {
if(!fPreviousThrottleActive) fRaisedThrottleBx=bx;
hThrottleActiveHistory->Fill(bx);
// Add +1 as throttle is applied to next BX
if(fBeSlinkSim->throttleActive()) {
if(!fPreviousThrottleActive) fRaisedThrottleBx=bx+1;
hThrottleActiveHistory->Fill(bx+1,fThrottleHistWeight);
} else {
if(fPreviousThrottleActive) fEndedThrottleBx=bx;
if(fPreviousThrottleActive) fEndedThrottleBx=bx+1;
}
if(fBeSlinkSim->delayedThrottleActive(bx)) {
hDelayedThrottleActiveHistory->Fill(bx+1,fThrottleHistWeight-50);
}
fPreviousThrottleActive=fBeSlinkSim->fThrottleActive;
}
......@@ -93,15 +115,19 @@ private:
bool fPreviousThrottleActive;
uint64_t fRaisedThrottleBx;
uint64_t fEndedThrottleBx;
unsigned fThrottleHistWeight;
TH1D *hTotalEventWords;
TH1I *hThrottleActiveHistory;
TH1I *hDelayedThrottleActiveHistory;
TH1D *hRaisedThrottleToL1Accept;
TH1D *hEndedThrottleToL1Accept;
TH1D *hEventBufferUsed[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
TH1I *hEventBufferUsedHistory[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
TH1D *hEventBufferExceeded[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
TH1D *hEventBufferUsedMax;
TH1I *hEventBufferUsedHistoryMax;
};
#endif
......@@ -41,7 +41,8 @@ public:
*/
//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) {
......@@ -61,6 +62,8 @@ public:
fArrayWrite=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++) {
const EconArch &econArch(fSlinkArch->econArch(e));
for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
......@@ -87,12 +90,15 @@ public:
void processBx(uint64_t bx, const SlinkElinkData &d) {
unsigned bufferLimit(fThrottleActive?fBufferLimit-50:fBufferLimit);
fThrottleActive=false;
fExceededBuffer=false;
for(unsigned e(0);e<fSlinkArch->numberOfEcons();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));
uint32_t word;
......@@ -101,9 +107,12 @@ public:
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
......@@ -425,7 +434,7 @@ public:
}
#endif
}
/*
bool throttle() {
if(fThrottleActive) return false;
......@@ -435,11 +444,22 @@ public:
if(fEventBuffer[e][b].used()>=fBufferLimit) {
if(fPrintLevel>5) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::throttle() "
<< "Applying throttle"
<< "Buffer used = " << fEventBuffer[e][b].used()
<< ", limit = " << fBufferLimit
<< ", applying throttle"
<< std::endl;
}
fThrottleActive=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:
fThrottleActive=false;
return true;
}
*/
bool throttleActive() const {
return fThrottleActive;
}
bool delayedThrottleActive(uint64_t bx) const {
return fDelayedThrottleActive[bx&0x3f];
}
unsigned numberOfSlinkWords() const {
return fNumberOfSlinkWords;
......@@ -521,6 +549,9 @@ public:
//unsigned fNumberOfWords[18];
bool fThrottleActive;
const unsigned fThrottleDelay;
bool fDelayedThrottleActive[64];
bool fEventActive;
bool fExceededBuffer;
unsigned fEconRead;
......@@ -533,7 +564,6 @@ public:
BlockCheck fBlockCheck[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
std::pair<bool,uint32_t> fBlockPair[Dimensions::MaxNumberOfEconsPerSlink][Dimensions::MaxNumberOfBlocksPerEcon];
//unsigned fReadHgcroc[NumberOfParallelBuffers];
//unsigned fReadWord[NumberOfParallelBuffers];
//unsigned fReadHgcrocNumber[NumberOfParallelBuffers][20];
......
......@@ -234,6 +234,8 @@ int main(int argc, char* argv[]) {
int initial(1);
if((argc%2)==0) {
initial=2;
// Nominal = 831274
unsigned nArg(0);
std::istringstream sArg(argv[1]);
......@@ -531,8 +533,12 @@ int main(int argc, char* argv[]) {
//TriggerRule tr(50);
std::vector<Throttle> vEconThrottle;
std::vector<Throttle> vBeThrottle;
//std::vector<Throttle> vEconThrottle;
//std::vector<Throttle> vBeThrottle;
bool econAllowL1a(true);
bool beAllowL1a(true);
catchSignals();
uint64_t bx;
......@@ -553,15 +559,15 @@ int main(int argc, char* argv[]) {
bool newL1AIn(false);
bool newL1AOut(false);
bool econAllowL1a(true);
for(unsigned t(0);t<vEconThrottle.size() && econAllowL1a;t++) {
econAllowL1a=vEconThrottle[t].allowL1Accept(bx);
}
//bool econAllowL1a(true);
//for(unsigned t(0);t<vEconThrottle.size() && econAllowL1a;t++) {
//econAllowL1a=vEconThrottle[t].allowL1Accept(bx);
//}
bool beAllowL1a(true);
for(unsigned t(0);t<vBeThrottle.size() && beAllowL1a;t++) {
beAllowL1a=vBeThrottle[t].allowL1Accept(bx);
}
//bool beAllowL1a(true);
//for(unsigned t(0);t<vBeThrottle.size() && beAllowL1a;t++) {
//beAllowL1a=vBeThrottle[t].allowL1Accept(bx);
//}
if(!hgcrocSim.allowL1Accept()) {
nHgcrocDeadtime++;
......@@ -631,6 +637,7 @@ int main(int argc, char* argv[]) {
if(doingBe) {
bool anyExceeded(false);
beAllowL1a=true;
for(unsigned sl(0);sl<NumberOfSlinks;sl++) {
if(newL1AIn) {
......@@ -640,13 +647,17 @@ int main(int argc, char* argv[]) {
beSlinkSim[sl].processBx(bx,slinkElinkData[sl]);
/*
if(beSlinkSim[sl].throttle()) vBeThrottle.push_back(Throttle(bx));
if(beSlinkSim[sl].unThrottle()) {
assert(vBeThrottle.size()>0);
vBeThrottle[vBeThrottle.size()-1].endThrottle(bx);
//vBeThrottle[vBeThrottle.size()-1].print();
}
*/
if(beSlinkSim[sl].delayedThrottleActive(bx)) beAllowL1a=false;
if(beSlinkSim[sl].exceededBuffer()) anyExceeded=true;
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