@@ -268,8 +268,7 @@ class ProgramDmaBench: public Program
268268 // Note that we can force unlock because we know for sure this process is not holding the lock. If we did not know
269269 // this, it would be very dangerous to force the lock.
270270 params.setForcedUnlockEnabled (true );
271- mLinkMask = Parameters::linkMaskFromString (mOptions .links );
272- params.setLinkMask (mLinkMask );
271+ params.setLinkMask (Parameters::linkMaskFromString (mOptions .links ));
273272
274273 mInfinitePages = (mOptions .maxBytes <= 0 );
275274 mMaxPages = mOptions .maxBytes / mPageSize ;
@@ -365,14 +364,27 @@ class ProgramDmaBench: public Program
365364 }
366365 }
367366
367+ std::atomic<bool > mDmaLoopBreak {false };
368368 auto isStopDma = [&]{ return mDmaLoopBreak .load (std::memory_order_relaxed); };
369369
370370 // Thread for low priority tasks
371371 auto lowPriorityFuture = std::async (std::launch::async, [&]{
372372 try {
373373 auto next = std::chrono::steady_clock::now ();
374374 while (!isStopDma ()) {
375- lowPriorityTasks ();
375+ // Handle a SIGINT abort
376+ if (isSigInt ()) {
377+ // We want to finish the readout cleanly if possible, so we stop pushing and try to wait a bit until the
378+ // queue is empty
379+ mDmaLoopBreak = true ;
380+ return ;
381+ }
382+
383+ // Status display updates
384+ // Wait until the DMA has really started before printing our table to avoid messy output
385+ if (!mOptions .noDisplay && mPushCount .load (std::memory_order_relaxed) != 0 ) {
386+ updateStatusDisplay ();
387+ }
376388 next += LOW_PRIORITY_INTERVAL;
377389 std::this_thread::sleep_until (next);
378390 }
@@ -621,31 +633,6 @@ class ProgramDmaBench: public Program
621633 }
622634 return false ;
623635
624- // auto check = [&](auto patternFunction) {
625- // for (uint32_t i = START; i < pageSize32; i += PATTERN_STRIDE)
626- // {
627- // uint32_t expectedValue = patternFunction(i);
628- // uint32_t actualValue = page[i];
629- // if (actualValue != expectedValue) {
630- // // Report error
631- // mErrorCount++;
632- // if (mErrorCount < MAX_RECORDED_ERRORS) {
633- // mErrorStream << b::format("event:%d i:%d cnt:%d exp:0x%x val:0x%x\n")
634- // % eventNumber % i % counter % expectedValue % actualValue;
635- // }
636- // return true;
637- // }
638- // }
639- // return false;
640- // };
641- //
642- // switch (mOptions.generatorPattern) {
643- // case GeneratorPattern::Incremental: return check([&](uint32_t i) { return counter * 256 + i / 8; });
644- // case GeneratorPattern::Alternating: return check([&](uint32_t) { return 0xa5a5a5a5; });
645- // case GeneratorPattern::Constant: return check([&](uint32_t) { return 0x12345678; });
646- // default: ;
647- // }
648-
649636 BOOST_THROW_EXCEPTION (Exception ()
650637 << ErrorInfo::Message (" Unsupported pattern for CRU error checking" )
651638 << ErrorInfo::GeneratorPattern (mOptions .generatorPattern ));
@@ -710,23 +697,6 @@ class ProgramDmaBench: public Program
710697 }
711698 }
712699
713- void lowPriorityTasks ()
714- {
715- // Handle a SIGINT abort
716- if (isSigInt ()) {
717- // We want to finish the readout cleanly if possible, so we stop pushing and try to wait a bit until the
718- // queue is empty
719- mDmaLoopBreak = true ;
720- return ;
721- }
722-
723- // Status display updates
724- // Wait until the DMA has really started before printing our table to avoid messy output
725- if (!mOptions .noDisplay && mPushCount .load (std::memory_order_relaxed) != 0 ) {
726- updateStatusDisplay ();
727- }
728- }
729-
730700 void updateStatusDisplay ()
731701 {
732702 if (!mHeaderPrinted ) {
@@ -909,55 +879,74 @@ class ProgramDmaBench: public Program
909879 size_t dataGeneratorSize;
910880 } mOptions ;
911881
912- std::atomic<bool > mDmaLoopBreak {false };
913- bool mInfinitePages = false ;
882+ // / The DMA channel
883+ std::shared_ptr<DmaChannelInterface> mChannel ;
884+
885+ // / The type of the card we're using
886+ CardType::type mCardType ;
887+
888+ // / Page counters per link. Indexed by link ID.
889+ std::array<std::atomic<uint64_t >, MAX_LINKS> mLinkCounters ;
890+
891+ // / Amount of superpages pushed
914892 std::atomic<uint64_t > mPushCount { 0 };
893+
894+ // / Amount of superpages read out
915895 std::atomic<uint64_t > mReadoutCount { 0 };
896+
897+ // / Total amount of errors encountered
916898 int64_t mErrorCount = 0 ;
899+
900+ // / Keep on pushing until we're explicitly stopped
901+ bool mInfinitePages = false ;
902+
903+ // / Size of superpages
917904 size_t mSuperpageSize = 0 ;
905+
906+ // / Maximum amount of superpages
918907 size_t mMaxSuperpages = 0 ;
908+
909+ // / Amount of DMA pages per superpage
919910 size_t mPagesPerSuperpage = 0 ;
920911
912+ // / Maximum size of pages
913+ size_t mPageSize ;
914+
915+ // / Maximum amount of pages to transfer
916+ size_t mMaxPages ;
917+
918+ // / The size of the channel DMA buffer
919+ size_t mBufferSize ;
920+
921+ // / The base address of the channel DMA buffer
922+ uintptr_t mBufferBaseAddress ;
923+
924+ // / The memory mapped file that contains the channel DMA buffer
921925 std::unique_ptr<MemoryMappedFile> mMemoryMappedFile ;
922926
927+ // / Object for BAR throughput testing
928+ std::unique_ptr<BarHammer> mBarHammer ;
929+
923930 // / Stream for file readout, only opened if enabled by the --file program options
924931 std::ofstream mReadoutStream ;
925932
926933 // / Stream for error output
927934 std::ostringstream mErrorStream ;
928935
929- struct RunTime
930- {
931- TimePoint start; // /< Start of run time
932- TimePoint end; // /< End of run time
933- } mRunTime ;
936+ // / InfoLogger instance
937+ InfoLogger mLogger ;
934938
935939 // / Was the header printed?
936940 bool mHeaderPrinted = false ;
937941
938942 // / Indicates the display must add a newline to the table
939943 bool mDisplayUpdateNewline ;
940944
941- size_t mPageSize ;
942-
943- size_t mMaxPages ;
944-
945- std::unique_ptr<BarHammer> mBarHammer ;
946-
947- size_t mBufferSize ;
948-
949- uintptr_t mBufferBaseAddress ;
950-
951- CardType::type mCardType ;
952-
953- InfoLogger mLogger ;
954-
955- std::set<uint32_t > mLinkMask ;
956-
957- std::shared_ptr<DmaChannelInterface> mChannel ;
958-
959- // / Page counters per link. Indexed by link ID.
960- std::array<std::atomic<uint64_t >, MAX_LINKS> mLinkCounters ;
945+ struct RunTime
946+ {
947+ TimePoint start; // /< Start of run time
948+ TimePoint end; // /< End of run time
949+ } mRunTime ;
961950};
962951
963952int main (int argc, char ** argv)
0 commit comments