Commit efc9b89c authored by dauncey's avatar dauncey

Throttling and exceeding

parent 56642b92
...@@ -19,6 +19,9 @@ public: ...@@ -19,6 +19,9 @@ public:
void boj(const BeSlinkSim &b, unsigned nHistory=100000) { void boj(const BeSlinkSim &b, unsigned nHistory=100000) {
fBeSlinkSim=&b; fBeSlinkSim=&b;
fPreviousThrottleActive=false;
fRaisedThrottleBx=-1;
fEndedThrottleBx=-1;
std::ostringstream sout; std::ostringstream sout;
sout << "BeSlinkAna" << std::setw(2) << std::setfill('0') sout << "BeSlinkAna" << std::setw(2) << std::setfill('0')
...@@ -26,15 +29,7 @@ public: ...@@ -26,15 +29,7 @@ public:
std::string sHgcroc[18]={"00","01","02","03","04","05","06","07","08", std::string sHgcroc[18]={"00","01","02","03","04","05","06","07","08",
"09","10","11","12","13","14","15","16","17"}; "09","10","11","12","13","14","15","16","17"};
/*
hBitmapWordsVsChannels=new TH1I((sout.str()+"BitmapWordsVsChannels").c_str(),
";Number of channels per HGCROC packet;Number of words per HGCROC packet",73,-0.5,72.5);
hLabelsWordsVsChannels=new TH1I((sout.str()+"LabelsWordsVsChannels").c_str(),
";Number of channels per HGCROC packet;Number of words per HGCROC packet",73,-0.5,72.5);
hTotalChannels=new TH1D((sout.str()+"TotalChannels").c_str(),
";ECON total number of channels",1300,0,1300);
*/
hTotalEventWords=new TH1D((sout.str()+"TotalEventWords").c_str(), hTotalEventWords=new TH1D((sout.str()+"TotalEventWords").c_str(),
";Total number of bytes per event",250,0,4000); ";Total number of bytes per event",250,0,4000);
...@@ -46,45 +41,22 @@ public: ...@@ -46,45 +41,22 @@ public:
";Number of event buffer words used",1000,0,10000); ";Number of event buffer words used",1000,0,10000);
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(),
";Number of event buffer words used",1000,0,10000);
} }
} }
/*
for(unsigned h(0);h<18;h++) { hThrottleActiveHistory=new TH1I((sout.str()+"ThrottleActiveHistory").c_str(),
hChannels[h]=new TH1D((sout.str()+"Hgcroc"+sHgcroc[h]+"Channels").c_str(), ";BX;Throttle active",nHistory,0,nHistory);
";Number of channels per HGCROC packet",73,0,73); hRaisedThrottleToL1Accept=new TH1D((sout.str()+"RaisedThrottleToL1Accept").c_str(),
hWords[h]=new TH1D((sout.str()+"Hgcroc"+sHgcroc[h]+"Words").c_str(), ";L1Accept - ended throttle (BX)",1000,0,1000);
";Number of words per HGCROC packet",60,0,60); hEndedThrottleToL1Accept=new TH1D((sout.str()+"EndedThrottleToL1Accept").c_str(),
hWordsVsChannels[h]=new TH2D((sout.str()+"Hgcroc"+sHgcroc[h]+"WordsVsChannels").c_str(), ";L1Accept - ended throttle (BX)",1000,0,1000);
";Number of channels per HGCROC packet;Number of words per HGCROC packet",73,-0.5,72.5,60,-0.5,59.5);
}
*/
} }
void analyseL1Accept(uint64_t bx) { void analyseL1Accept(uint64_t bx) {
/* if(fRaisedThrottleBx!=-1) hRaisedThrottleToL1Accept->Fill(bx-fRaisedThrottleBx);
unsigned nChannels(0),nWords(0); if(fEndedThrottleBx!=-1) hEndedThrottleToL1Accept->Fill(bx-fEndedThrottleBx);
for(unsigned h(0);h<18;h++) {
hChannels[h]->Fill(fEconSim->numberOfChannels(h));
hWords[h]->Fill(fEconSim->numberOfWords(h));
hWordsVsChannels[h]->Fill(fEconSim->numberOfChannels(h),fEconSim->numberOfWords(h));
nChannels+=fEconSim->numberOfChannels(h);
nWords+=fEconSim->numberOfWords(h);
}
hTotalChannels->Fill(nChannels);
hTotalWords->Fill(nWords);
for(unsigned block(0);block<fEconSim->fEconArch.fNumberOfBlocks;block++) {
unsigned nBlockChannels(0),nBlockWords(0);
for(unsigned i(0);i<fEconSim->fEconArch.fHgcrocNumber[block].size();i++) {
unsigned h(fEconSim->fEconArch.fHgcrocNumber[block][i]);
nBlockChannels+=fEconSim->numberOfChannels(h);
nBlockWords+=fEconSim->numberOfWords(h);
}
hBlockTotalChannels[block]->Fill(nBlockChannels);
hBlockTotalWords[block]->Fill(nBlockWords);
}
*/
} }
void analyseBx(uint64_t bx) { void analyseBx(uint64_t bx) {
...@@ -94,12 +66,22 @@ public: ...@@ -94,12 +66,22 @@ public:
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()); hEventBufferUsed[e][b]->Fill(fBeSlinkSim->fEventBuffer[e][b].used());
hEventBufferUsedHistory[e][b]->Fill(bx,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());
} }
} }
if(fBeSlinkSim->fL1AcceptEoe) { if(fBeSlinkSim->fL1AcceptEoe) {
hTotalEventWords->Fill(16*fBeSlinkSim->fTotalNumberOfEventWords); hTotalEventWords->Fill(16*fBeSlinkSim->fTotalNumberOfEventWords);
} }
if(fBeSlinkSim->fThrottleActive) {
if(!fPreviousThrottleActive) fRaisedThrottleBx=bx;
hThrottleActiveHistory->Fill(bx);
} else {
if(fPreviousThrottleActive) fEndedThrottleBx=bx;
}
fPreviousThrottleActive=fBeSlinkSim->fThrottleActive;
} }
void eoj() { void eoj() {
...@@ -108,24 +90,18 @@ public: ...@@ -108,24 +90,18 @@ public:
private: private:
const BeSlinkSim *fBeSlinkSim; const BeSlinkSim *fBeSlinkSim;
//TH1I *hBitmapWordsVsChannels; bool fPreviousThrottleActive;
//TH1I *hLabelsWordsVsChannels; uint64_t fRaisedThrottleBx;
uint64_t fEndedThrottleBx;
//TH1D *hMeans;
//TH1D *hChannels[18];
//TH1D *hWords[18];
//TH2D *hWordsVsChannels[18];
//TH1D *hTotalChannels;
//TH1D *hTotalWords;
//TH1D *hBlockTotalChannels[7];
//TH1D *hBlockTotalWords[7];
TH1D *hTotalEventWords; TH1D *hTotalEventWords;
TH1I *hThrottleActiveHistory;
TH1D *hRaisedThrottleToL1Accept;
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];
}; };
#endif #endif
...@@ -15,50 +15,48 @@ class BeSlinkSim { ...@@ -15,50 +15,48 @@ class BeSlinkSim {
public: public:
/* /*
enum { enum {
NumberOfParallelBuffers=2 NumberOfParallelBuffers=2
}; };
enum DataRandomMethod { enum DataRandomMethod {
NotRandom, NotRandom,
Binomial, Binomial,
Flat, Flat,
Mixed Mixed
}; };
enum DataFormatMethod { enum DataFormatMethod {
FixedChannelBitmap, FixedChannelBitmap,
FixedChannelLabels, FixedChannelLabels,
FixedMixture, FixedMixture,
VariableMixture VariableMixture
}; };
enum DataFlowMethod { enum DataFlowMethod {
FixedHgcrocMap, FixedHgcrocMap,
VariableHgcrocMap, VariableHgcrocMap,
EventBuild EventBuild
}; };
*/ */
//BeSlinkSim(unsigned e, unsigned h=18, unsigned m=0) : fEcon(e) { //BeSlinkSim(unsigned e, unsigned h=18, unsigned m=0) : fEcon(e) {
BeSlinkSim() { BeSlinkSim() {
} }
void boj(const SlinkArch &a) { void boj(const SlinkArch &a, unsigned bl) {
//fSlink=a.slinkNumber();
fSlinkArch=&a; fSlinkArch=&a;
fBufferLimit=bl;
if(fPrintLevel>0) { if(fPrintLevel>0) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::ctor() " std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::ctor() "
<< "Entered" << std::endl; << "Entered with buffer limit = " << fBufferLimit << std::endl;
} }
fThrottleActive=false;
fEventActive=false; fEventActive=false;
fActiveInputBuffer=0; fActiveInputBuffer=0;
fWriteElink=0; fWriteElink=0;
//fBufferLimit=1048;
fBufferLimit=1000000000;
fArrayWrite=0; fArrayWrite=0;
for(unsigned i(0);i<4;i++) fArrayWord[i]=0; for(unsigned i(0);i<4;i++) fArrayWord[i]=0;
...@@ -89,82 +87,29 @@ public: ...@@ -89,82 +87,29 @@ public:
void processBx(uint64_t bx, const SlinkElinkData &d) { void processBx(uint64_t bx, const SlinkElinkData &d) {
//#define OLD_METHOD fExceededBuffer=false;
#ifdef OLD_METHOD
if((bx%2)==0) { for(unsigned e(0);e<fSlinkArch->numberOfEcons();e++) {
fSlinkElinkData=d; const EconArch &econArch(fSlinkArch->econArch(e));
} else { for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
uint64_t word,word2; const std::vector<unsigned> &elinkNumber(econArch.elinkNumber(b));
#endif
for(unsigned e(0);e<fSlinkArch->numberOfEcons();e++) {
const EconArch &econArch(fSlinkArch->econArch(e));
for(unsigned b(0);b<econArch.numberOfBlocks();b++) {
const std::vector<unsigned> &elinkNumber(econArch.elinkNumber(b));
#ifdef OLD_METHOD
unsigned eo(0);
for(unsigned w(0);w<elinkNumber.size();w++) {
if((eo%2)==0) {
word=fSlinkElinkData.fData[e][elinkNumber[w]];
} else {
word2=fSlinkElinkData.fData[e][elinkNumber[w]];
word+=(word2<<32);
//if(word!=0) assert(fEventBuffer[e][fSlinkArch->econArch(e).numberOfBlocks()==1?0:w].writeAndIncrementPtr(word));
if(word!=0) assert(fEventBuffer[e][b].writeAndIncrementPtr(word));
}
eo++;
}
for(unsigned w(0);w<elinkNumber.size();w++) {
if((eo%2)==0) {
word=d.fData[e][elinkNumber[w]];
} else {
word2=d.fData[e][elinkNumber[w]];
word+=(word2<<32);
//if(word!=0) assert(fEventBuffer[e][fSlinkArch->econArch(e).numberOfBlocks()==1?0:w].writeAndIncrementPtr(word));
if(word!=0) assert(fEventBuffer[e][b].writeAndIncrementPtr(word));
}
eo++;
}
/*
// DO BY ARCH PROPERLY!!!
for(unsigned w(0);w<Dimensions::MaxNumberOfElinksPerEcon;w++) {
word=fSlinkElinkData.fData[e][w];
if(word!=0) assert(fEventBuffer[e][fSlinkArch->econArch(e).numberOfBlocks()==1?0:w].writeAndIncrementPtr(word));
}
for(unsigned w(0);w<Dimensions::MaxNumberOfElinksPerEcon;w++) {
word=d.fData[e][w];
//word=(word<<32)+fSlinkElinkData.fData[e][w];
if(word!=0) assert(fEventBuffer[e][fSlinkArch->econArch(e).numberOfBlocks()==1?0:w].writeAndIncrementPtr(word));
}
*/
}
#else
uint32_t word; uint32_t word;
for(unsigned w(0);w<elinkNumber.size();w++) { for(unsigned w(0);w<elinkNumber.size();w++) {
word=d.fData[e][elinkNumber[w]]; word=d.fData[e][elinkNumber[w]];
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));
} }
#endif
if(fEventBuffer[e][b].used()>=4095) fExceededBuffer=true;
//processEconBx(e,d.fData[e]);
} }
} }
// Output to Slink // Output to Slink
fL1AcceptBoe=false; fL1AcceptBoe=false;
fL1AcceptEoe=false; fL1AcceptEoe=false;
bool done(false); bool done(false);
uint128_t w; uint128_t w;
fNumberOfSlinkWords=0; fNumberOfSlinkWords=0;
...@@ -251,336 +196,368 @@ public: ...@@ -251,336 +196,368 @@ public:
uint32_t nextWord(0); uint32_t nextWord(0);
assert(fEventBuffer[fEconRead][fBlockRead].halfReadAndIncrementPtr(nextWord)); assert(fEventBuffer[fEconRead][fBlockRead].halfReadAndIncrementPtr(nextWord));
#endif #endif
if(nextWord!=0) { if(nextWord!=0) {
if(fPrintLevel>5) { if(fPrintLevel>5) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::processBx() " std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::processBx() "
<< "Read buffer words = 0x" << std::hex << "Read buffer words = 0x" << std::hex
<< nextWord << std::dec << std::endl; << nextWord << std::dec << std::endl;
} }
fArrayWord[fArrayWrite]=nextWord; fArrayWord[fArrayWrite]=nextWord;
fArrayWrite++; fArrayWrite++;
if(fBlockCheck[fEconRead][fBlockRead].processBx(fArrayWord[fArrayWrite-1])) fBlockRead++; if(fBlockCheck[fEconRead][fBlockRead].processBx(fArrayWord[fArrayWrite-1])) fBlockRead++;
if(fBlockRead==fSlinkArch->econArch(fEconRead).numberOfBlocks()) { if(fBlockRead==fSlinkArch->econArch(fEconRead).numberOfBlocks()) {
fBlockRead=0; fBlockRead=0;
fEconRead++; fEconRead++;
} }
if(fEconRead==fSlinkArch->numberOfEcons()) fArrayWrite=4; if(fEconRead==fSlinkArch->numberOfEcons()) fArrayWrite=4;
} }
} else { } else {
if(fPrintLevel>5) { if(fPrintLevel>5) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::processBx() " std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::processBx() "
<< "Nothing in buffer" << std::endl; << "Nothing in buffer" << std::endl;
} }
done=true; done=true;
}
} }
}
if(fArrayWrite==4) { if(fArrayWrite==4) {
w.first=fArrayWord[1]; w.first=fArrayWord[1];
w.first=(w.first<<32)+fArrayWord[0]; w.first=(w.first<<32)+fArrayWord[0];
w.second=fArrayWord[3]; w.second=fArrayWord[3];
w.second=(w.second<<32)+fArrayWord[2]; w.second=(w.second<<32)+fArrayWord[2];
fSlinkWord[fNumberOfSlinkWords]=std::pair<uint128_t,bool>(w,false); fSlinkWord[fNumberOfSlinkWords]=std::pair<uint128_t,bool>(w,false);
fNumberOfSlinkWords++; fNumberOfSlinkWords++;
fNumberOfEventWords++; fNumberOfEventWords++;
if(fPrintLevel>3) { if(fPrintLevel>3) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::processBx() " std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "]::processBx() "
<< "Writing Slink data word = 0x" << std::hex << w.second << " " << w.first << "Writing Slink data word = 0x" << std::hex << w.second << " " << w.first
<< std::dec << std::endl; << std::dec << std::endl;
} }
fArrayWrite=0; fArrayWrite=0;
for(unsigned i(0);i<4;i++) fArrayWord[i]=0; for(unsigned i(0);i<4;i++) fArrayWord[i]=0;
}
} }
} }
} }
} }
}
void processEconBx(unsigned ec, const uint32_t *d) { bool exceededBuffer() const {
return fExceededBuffer;
}
void processEconBx(unsigned ec, const uint32_t *d) {
return; return;
#ifdef NOT_YET #ifdef NOT_YET
uint32_t a[7]; uint32_t a[7];
// Switch for different dataflow methods // Switch for different dataflow methods
if(fDataFlowMethod==FixedHgcrocMap) { if(fDataFlowMethod==FixedHgcrocMap) {
// 4 words per BX for 7 eLinks // 4 words per BX for 7 eLinks
unsigned nWords(4); unsigned nWords(4);
if(fPrintLevel>3) { if(fPrintLevel>3) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "][" << fEcon << "]::processBx() " std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "][" << fEcon << "]::processBx() "
<< "Data flow method = fixed HGCROC map, reading " << "Data flow method = fixed HGCROC map, reading "
<< nWords << " words per BX" << std::endl; << nWords << " words per BX" << std::endl;
} }
for(unsigned b(0);b<NumberOfParallelBuffers;b++) { for(unsigned b(0);b<NumberOfParallelBuffers;b++) {
if(b!=(fActiveInputBuffer%NumberOfParallelBuffers)) { if(b!=(fActiveInputBuffer%NumberOfParallelBuffers)) {
for(unsigned e(0);e<7;e++) { for(unsigned e(0);e<7;e++) {
if(fReadHgcroc[b]<fEconFile.fNumberOfHgcrocs) { if(fReadHgcroc[b]<fEconFile.fNumberOfHgcrocs) {
for(unsigned w(0);w<nWords;w++) { for(unsigned w(0);w<nWords;w++) {
assert(fReadHgcroc[b]<fEconFile.fNumberOfHgcrocs); assert(fReadHgcroc[b]<fEconFile.fNumberOfHgcrocs);
assert(fReadWord[b]<fFirstBuffer[b][fReadHgcroc[b]].size()); assert(fReadWord[b]<fFirstBuffer[b][fReadHgcroc[b]].size());
if(fPrintLevel>4) { if(fPrintLevel>4) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "][" << fEcon << "]::processBx() " std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "][" << fEcon << "]::processBx() "
<< "Copying BX word " << w << " from first buffer " << b << "Copying BX word " << w << " from first buffer " << b
<< ", HGCROC " << fReadHgcroc[b] << ", word " << fReadWord[b] << ", HGCROC " << fReadHgcroc[b] << ", word " << fReadWord[b]
<< " of " << fFirstBuffer[b][fReadHgcroc[b]].size() << " = " << " of " << fFirstBuffer[b][fReadHgcroc[b]].size() << " = "
<< std::hex << fFirstBuffer[b][fReadHgcroc[b]][fReadWord[b]] << std::hex << fFirstBuffer[b][fReadHgcroc[b]][fReadWord[b]]
<< std::dec << std::endl; << std::dec << std::endl;
}
assert(fElink[fHgcrocToElink[h]].writeAndIncrementPtr(fFirstBuffer[b][fReadHgcrocNumber[b]][fReadWord[b]]));
} }
assert(fElink[fHgcrocToElink[h]].writeAndIncrementPtr(fFirstBuffer[b][fReadHgcrocNumber[b]][fReadWord[b]]));
} }
} }
} }
} }
}
// Add zero padding word if odd // Add zero padding word if odd
//if((nWords%2)==1) assert(fElink[fHgcrocToElink[h]].writeAndIncrementPtr(0)); //if((nWords%2)==1) assert(fElink[fHgcrocToElink[h]].writeAndIncrementPtr(0));
uint64_t d; uint64_t d;
for(unsigned e(0);e<7;e++) { for(unsigned e(0);e<7;e++) {
if(fElink[e].readAndIncrementPtr(d)) a[e]=(d&0xffffffff); if(fElink[e].readAndIncrementPtr(d)) a[e]=(d&0xffffffff);
else a[e]=0; else a[e]=0;
if(fPrintLevel>4) { if(fPrintLevel>4) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "][" << fEcon << "]::processBx() " std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "][" << fEcon << "]::processBx() "
<< "Sending eLink " << e << " = " << "Sending eLink " << e << " = "
<< std::hex << a[e] << std::hex << a[e]
<< std::dec << std::endl; << std::dec << std::endl;
}
} }
}
} else if(fDataFlowMethod==VariableHgcrocMap) { } else if(fDataFlowMethod==VariableHgcrocMap) {
unsigned nWords(0); unsigned nWords(0);
if(fPrintLevel>3) { if(fPrintLevel>3) {
std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "][" << fEcon << "]::processBx() " std::cout << "BeSlinkSim[" << fSlinkArch->slinkNumber() << "][" << fEcon << "]::processBx() "
<< "Data flow method = variable HGCROC map, reading " << "Data flow method = variable HGCROC map, reading "
<< nWords << " words per BX" << std::endl; << nWords << " words per BX" << std::endl;
}