2626
2727using namespace AliceO2 ::roc::CommandLineUtilities;
2828using namespace AliceO2 ::roc;
29- using namespace AliceO2 ::InfoLogger;
3029namespace po = boost::program_options;
3130
3231class ProgramBarStress : public Program
@@ -44,44 +43,32 @@ class ProgramBarStress : public Program
4443 options.add_options ()(" cycles" ,
4544 po::value<long long >(&mOptions .cycles )->default_value (100 ),
4645 " Total bar writes to perform" );
47- options.add_options ()(" print-freq" ,
48- po::value<long long >(&mOptions .printFrequency )->default_value (10 ),
49- " Print every #print-freq cycles" );
50- options.add_options ()(" sleep" ,
51- po::value<int >(&mOptions .sleep )->default_value (0 ),
52- " Sleep for #sleep us between every bar write" );
5346 Options::addOptionCardId (options);
5447 Options::addOptionRegisterAddress (options);
5548 Options::addOptionRegisterValue (options);
5649 Options::addOptionChannel (options);
5750 }
5851
59- int stress (BarInterface* bar, uint32_t address, uint32_t value, long long cycles, long long printFrequency )
52+ int stress (BarInterface* bar, uint32_t address, uint32_t value, long long cycles)
6053 {
61-
6254 std::chrono::high_resolution_clock::time_point start = std::chrono::high_resolution_clock::now ();
6355 std::chrono::high_resolution_clock::time_point finish = std::chrono::high_resolution_clock::now ();
6456
6557 for (long long i = 0 ;; i++) {
66- if (mOptions .sleep ) {
67- std::this_thread::sleep_for (std::chrono::microseconds (mOptions .sleep ));
68- }
6958 bar->writeRegister (address / 4 , value);
59+ bar->readRegister (address / 4 );
7060
71- if (i && ((i % printFrequency == 0 ) || (i == cycles) )) {
61+ if (i == cycles || isSigInt ( )) {
7262 finish = std::chrono::high_resolution_clock::now ();
73- getLogger () << " loops [" << i - printFrequency + 1 << " - " << i << " ]: " << std::chrono::duration_cast<std::chrono::nanoseconds>(finish - start).count () << " ns" << InfoLogger::endm;
74-
75- if (i == cycles || isSigInt ()) { // sigInt only stops at cycles = printFrequency * X
76- double throughput = (printFrequency / (std::chrono::duration_cast<std::chrono::nanoseconds>(finish - start).count () * 1e-9 )); // throughput (ops/time) [ops/sec]
77- getLogger () << " Throughput :" << throughput << " ops/sec" << InfoLogger::endm;
78-
79- double latency = ((std::chrono::duration_cast<std::chrono::nanoseconds>(finish - start).count () * 1e-9 ) / printFrequency); // latency (time/ops) [sec]
80- getLogger () << " Operation latency: " << latency << " sec " << InfoLogger::endm;
81- return i;
82- }
83-
84- start = std::chrono::high_resolution_clock::now ();
63+ std::cout << " cyc: " << i * 2 ;
64+ std::cout << " time: " << std::chrono::duration_cast<std::chrono::nanoseconds>(finish - start).count () * 1e-9 << std::endl;
65+ double throughput = ((i * 2 ) / (std::chrono::duration_cast<std::chrono::nanoseconds>(finish - start).count () * 1e-9 )); // throughput (ops/time) [ops/sec]
66+ std::cout << " Throughput: " << throughput << " ops/sec" << std::endl;
67+ std::cout << " Throughput: " << throughput * 32 / 1e6 << " Mbps/sec" << std::endl;
68+
69+ double latency = ((std::chrono::duration_cast<std::chrono::nanoseconds>(finish - start).count () * 1e-9 ) / (cycles * 2 )); // latency (time/ops) [sec]
70+ std::cout << " Operation latency: " << latency << " sec " << std::endl;
71+ return i;
8572 }
8673 }
8774 }
@@ -96,23 +83,25 @@ class ProgramBarStress : public Program
9683 auto params = AliceO2::roc::Parameters::makeParameters (cardId, channelNumber);
9784 auto bar = AliceO2::roc::ChannelFactory ().getBar (params);
9885
99- getLogger () << " Card ID: " << cardId << InfoLogger::endm;
100- getLogger () << " Total BAR write operations: " << mOptions .cycles << InfoLogger::endm;
101- getLogger () << " Print frequency: " << mOptions .printFrequency << InfoLogger::endm;
86+ std::cout << " Card ID: " << cardId << std::endl;
87+ std::cout << " BAR: " << channelNumber << std::endl;
88+ std::cout << " Total cycles (rd + wr): " << mOptions .cycles << std::endl;
89+ std::cout << " Total BAR operations: " << mOptions .cycles * 2 << std::endl;
10290
103- if (isVerbose ())
104- getLogger () << " Running operations..." << InfoLogger::endm;
91+ std::cout << std::endl
92+ << " Running operations..." << std::endl
93+ << std::endl;
10594
10695 auto start = std::chrono::high_resolution_clock::now ();
10796 long long cycles_run = stress (bar.get (), registerAddress, registerValue,
108- mOptions .cycles , mOptions . printFrequency );
97+ mOptions .cycles );
10998 auto finish = std::chrono::high_resolution_clock::now ();
11099
111100 if (!cycles_run)
112- getLogger () << " Execution terminated because of error..." << InfoLogger::endm ;
101+ std::cout << " Execution terminated because of error..." << std::endl ;
113102
114- getLogger () << " Total duration: " << std::chrono::duration_cast<std::chrono::seconds>(finish - start).count () << " s" << InfoLogger::endm ;
115- getLogger () << " Total bar operations: " << cycles_run << InfoLogger::endm ;
103+ std::cout << " Total duration: " << std::chrono::duration_cast<std::chrono::seconds>(finish - start).count () << " s" << std::endl ;
104+ std::cout << " Total BAR operations: " << cycles_run * 2 << std::endl ;
116105 }
117106
118107 struct OptionsStruct {
0 commit comments