@@ -127,6 +127,9 @@ class ProgramDmaBench: public Program
127127 (" bytes" ,
128128 SuffixOption<uint64_t >::make (&mOptions .maxBytes )->default_value (" 0" ),
129129 " Limit of bytes to transfer. Give 0 for infinite." )
130+ (" byte-count" ,
131+ po::bool_switch (&mOptions .byteCountEnabled ),
132+ " Flag to enable byte-count; use the actual dma page for throughput (not always 8K)" )
130133 (" buffer-full-check" ,
131134 po::bool_switch (&mOptions .bufferFullCheck ),
132135 " Test how quickly the readout buffer gets full, if it's not emptied" )
@@ -559,8 +562,14 @@ class ProgramDmaBench: public Program
559562 // Read out pages
560563 int pages = mSuperpageSize / mPageSize ;
561564 for (int i = 0 ; i < pages; ++i) {
565+ auto pageAddress = mBufferBaseAddress + offset + i * mPageSize ;
562566 auto readoutCount = fetchAddReadoutCount ();
563- readoutPage (mBufferBaseAddress + offset + i * mPageSize , mPageSize , readoutCount);
567+ readoutPage (pageAddress, mPageSize , readoutCount);
568+
569+ if (mOptions .byteCountEnabled && !(mOptions .loopbackModeString == " INTERNAL" )) {
570+ const auto bytes = Cru::DataFormat::getEventSize (reinterpret_cast <const char *>(pageAddress));
571+ mByteCount .fetch_add (bytes, std::memory_order_relaxed);
572+ }
564573 }
565574
566575 // Page has been read out
@@ -990,7 +999,8 @@ class ProgramDmaBench: public Program
990999 format % (mReadoutCount .load (std::memory_order_relaxed) / mPagesPerSuperpage );
9911000
9921001 double runTime = std::chrono::duration<double >(steady_clock::now () - mRunTime .start ).count ();
993- double bytes = double (mReadoutCount .load (std::memory_order_relaxed)) * mPageSize ;
1002+ double bytes = mOptions .byteCountEnabled ? double (mByteCount .load (std::memory_order_relaxed)) :
1003+ double (mReadoutCount .load (std::memory_order_relaxed)) * mPageSize ;
9941004 double Gb = bytes * 8 / (1000 * 1000 * 1000 );
9951005 double Gbps = Gb / runTime;
9961006 format % Gbps;
@@ -1035,7 +1045,8 @@ class ProgramDmaBench: public Program
10351045 {
10361046 // Calculating throughput
10371047 double runTime = std::chrono::duration<double >(mRunTime .end - mRunTime .start ).count ();
1038- double bytes = double (mReadoutCount .load ()) * mPageSize ;
1048+ double bytes = mOptions .byteCountEnabled ? double (mByteCount .load ()) :
1049+ double (mReadoutCount .load ()) * mPageSize ;
10391050 double GB = bytes / (1000 * 1000 * 1000 );
10401051 double GBs = GB / runTime;
10411052 double GiB = bytes / (1024 * 1024 * 1024 );
@@ -1207,6 +1218,7 @@ class ProgramDmaBench: public Program
12071218 uint64_t pauseRead;
12081219 size_t maxRdhPacketCounter;
12091220 bool stbrd = false ;
1221+ bool byteCountEnabled = false ;
12101222 } mOptions ;
12111223
12121224 // / The DMA channel
@@ -1231,6 +1243,9 @@ class ProgramDmaBench: public Program
12311243 // Amount of DMA pages read out
12321244 std::atomic<uint64_t > mReadoutCount { 0 };
12331245
1246+ // Amount of bytes read out (as reported in the RDH)
1247+ std::atomic<uint64_t > mByteCount { 0 };
1248+
12341249 // / Total amount of errors encountered
12351250 int64_t mErrorCount = 0 ;
12361251
0 commit comments