@@ -20,79 +20,49 @@ using namespace AliceO2::roc;
2020using namespace AliceO2 ::InfoLogger;
2121namespace po = boost::program_options;
2222
23+ constexpr uint32_t SWT_WR_WORD_L = 0x0f00040 / 4 ;
24+
2325class ProgramBarStress : public Program
2426{
2527 public:
2628
2729 virtual Description getDescription ()
2830 {
2931 return {" Bar Stress" , " Stress the Bar Accessor" ,
30- " roc-bar-stress --id 42:00.0 --gbt-link 0 -- cycles 100000 --print-freq 10000 --errorcheck " };
32+ " roc-bar-stress --id 42:00.0 --cycles 100000 --print-freq 10000" };
3133 }
3234
3335 virtual void addOptions (boost::program_options::options_description& options)
3436 {
3537 options.add_options ()
36- (" gbt-link" ,
37- po::value<uint32_t >(&mOptions .gbtLink )->default_value (0 ),
38- " GBT link over which the bar writes will be performed. CRU is 0-17" )
3938 (" cycles" ,
4039 po::value<long long >(&mOptions .cycles )->default_value (100 ),
41- " Cycles of SWT writes(/reads) to perform" )
40+ " Total bar writes to perform" )
4241 (" print-freq" ,
4342 po::value<long long >(&mOptions .printFrequency )->default_value (10 ),
44- " Print every #print-freq cycles" )
45- (" errorcheck" ,
46- po::bool_switch (&mOptions .errorCheck ),
47- " Perform data validation" );
43+ " Print every #print-freq cycles" );
4844 Options::addOptionCardId (options);
4945 }
5046
51- int stress (Swt *swt , long long cycles, long long printFrequency, bool errorCheck )
47+ int stress (BarInterface *bar , long long cycles, long long printFrequency)
5248 {
5349
54- SwtWord swtWordWr = SwtWord (0x0 , 0x0 , 0x0 );
55- SwtWord swtWordRd = SwtWord (0x0 , 0x0 , 0x0 );
56-
57- /* swtWordCheck for testing */
58- // SwtWord swtWordCheck = SwtWord(0x42, 0x42, 0x42);
59-
6050 std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now ();
6151 std::chrono::high_resolution_clock::time_point finish = std::chrono::high_resolution_clock::now ();
6252
6353 for (long long i=0 ;; i++){
64- swtWordWr.setLow ((0x1 + i)%0xffffffff );
65- swtWordWr.setMed ((0x2 + i)%0xffffffff );
66- swtWordWr.setHigh ((0x3 + i)%0xffff );
54+ bar->writeRegister (SWT_WR_WORD_L, 0x42 );
6755
68- uint32_t mon = swt->write (swtWordWr);
69- if (isVerbose ())
70- getLogger () << " WR MON: 0x" << std::setfill (' 0' ) << std::hex << mon << InfoLogger::endm;
71-
72- if (errorCheck){
73- uint32_t mon = swt->read (swtWordRd);
74- if (swtWordRd != swtWordWr){
75- getLogger () << " SWT validation failed" << InfoLogger::endm;
76- getLogger () << " Read: " << swtWordRd << " | Expected: " << swtWordWr << InfoLogger::endm;
77- return -1 ;
78- }
79-
80- if (isVerbose ()){
81- getLogger () << " RD MON: 0x" << std::setfill (' 0' ) << std::hex << mon << InfoLogger::endm;
82- getLogger () << " Read swtWord: " << swtWordRd << InfoLogger::endm;
83- }
84- }
85-
86- if (i && (i%printFrequency == 0 )){
56+ if (i && ((i%printFrequency == 0 ) || (i == cycles))){
8757 finish = std::chrono::high_resolution_clock::now ();
8858 getLogger () << " loops [" << i-printFrequency+1 << " - " << i << " ]: " <<
8959 std::chrono::duration_cast<std::chrono::nanoseconds> (finish - start).count () << " ns" << InfoLogger::endm;
9060
9161 if (i == cycles || isSigInt ()){ // sigInt only stops at cycles = printFrequency * X
92- double throughput = (barOps /(std::chrono::duration_cast<std::chrono::nanoseconds> (finish - start).count () * 1e-9 )); // throughput (ops/time) [ops/sec]
62+ double throughput = (printFrequency /(std::chrono::duration_cast<std::chrono::nanoseconds> (finish - start).count () * 1e-9 )); // throughput (ops/time) [ops/sec]
9363 getLogger () << " Throughput :" << throughput << " ops/sec" << InfoLogger::endm;
9464
95- double latency = ((std::chrono::duration_cast<std::chrono::nanoseconds> (finish - start).count () * 1e-9 ) / barOps ); // latency (time/ops) [sec]
65+ double latency = ((std::chrono::duration_cast<std::chrono::nanoseconds> (finish - start).count () * 1e-9 ) / printFrequency ); // latency (time/ops) [sec]
9666 getLogger () << " Operation latency: " << latency << " sec " << InfoLogger::endm;
9767 return i;
9868 }
@@ -108,19 +78,9 @@ class ProgramBarStress: public Program
10878 auto cardId = Options::getOptionCardId (map);
10979
11080 getLogger () << " Card ID: " << cardId << InfoLogger::endm;
111- getLogger () << " GBT Link: " << mOptions .gbtLink << InfoLogger::endm;
112- getLogger () << " Cycles of SWT write(/read) operations: " << mOptions .cycles << InfoLogger::endm;
81+ getLogger () << " Total BAR write operations: " << mOptions .cycles << InfoLogger::endm;
11382 getLogger () << " Print frequency: " << mOptions .printFrequency << InfoLogger::endm;
114- getLogger () << " Error Check enabled: " << mOptions .errorCheck << InfoLogger::endm;
115-
116- /* bar(Writes | Reads | Ops) every #printFrequency cycles */
117- barWrites = (SWT_WRITE_BAR_WRITES + SWT_READ_BAR_WRITES*mOptions .errorCheck )*mOptions .printFrequency ;
118- barReads = (SWT_WRITE_BAR_READS + SWT_READ_BAR_READS*mOptions .errorCheck )*mOptions .printFrequency ;
119- barOps = barWrites + barReads;
12083
121- getLogger () << " Logging time every " << barOps << " bar operations, of which:" << InfoLogger::endm;
122- getLogger () << " barWrites: " << barWrites << " | barReads: " << barReads << InfoLogger::endm;
123-
12484 std::shared_ptr<BarInterface>
12585 bar0 = ChannelFactory ().getBar (cardId, 0 );
12686 std::shared_ptr<BarInterface>
@@ -130,38 +90,26 @@ class ProgramBarStress: public Program
13090 getLogger () << " Resetting card..." << InfoLogger::endm;
13191 bar0->writeRegister (Cru::Registers::RESET_CONTROL.index , 0x1 );
13292
133- if (isVerbose ())
134- getLogger () << " Initializing SWT..." << InfoLogger::endm;
135- auto swt = Swt (*bar2, mOptions .gbtLink );
136-
13793 if (isVerbose ())
13894 getLogger () << " Running operations..." << InfoLogger::endm;
13995
14096 auto start = std::chrono::high_resolution_clock::now ();
141- long long cycles_run = stress (&swt , mOptions .cycles , mOptions .printFrequency , mOptions . errorCheck );
97+ long long cycles_run = stress (bar2. get () , mOptions .cycles , mOptions .printFrequency );
14298 auto finish = std::chrono::high_resolution_clock::now ();
14399
144100 if (!cycles_run)
145101 getLogger () << " Execution terminated because of error..." << InfoLogger::endm;
146102
147103 getLogger () << " Total duration: " << std::chrono::duration_cast<std::chrono::seconds> (finish-start).count () << " s" << InfoLogger::endm;
148- getLogger () << " Total bar operations: " << barOps * (cycles_run/mOptions .printFrequency ) << InfoLogger::endm;
149- getLogger () << " Total bar writes " << barWrites * (cycles_run/mOptions .printFrequency ) << InfoLogger::endm;
150- getLogger () << " Total bar reads: " << barReads * (cycles_run/mOptions .printFrequency ) << InfoLogger::endm;
104+ getLogger () << " Total bar operations: " << cycles_run << InfoLogger::endm;
151105 }
152106
153107 struct OptionsStruct
154108 {
155- uint32_t gbtLink = 0 ;
156109 long long cycles = 100 ;
157110 long long printFrequency = 10 ;
158- bool errorCheck = true ;
159111 }mOptions ;
160112
161- long long barOps = 0 ;
162- long long barWrites = 0 ;
163- long long barReads = 0 ;
164-
165113 private:
166114};
167115
0 commit comments