From c9a16815786236a70d928b05c5a7defd5cd362fe Mon Sep 17 00:00:00 2001 From: Antonio Franco Date: Tue, 8 Mar 2022 19:20:48 +0100 Subject: [PATCH 1/4] Optimize payload buffer read in fast decode page --- .../HMPIDReconstruction/HmpidDecoder2.h | 1 + .../reconstruction/src/HmpidDecoder2.cxx | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Detectors/HMPID/reconstruction/include/HMPIDReconstruction/HmpidDecoder2.h b/Detectors/HMPID/reconstruction/include/HMPIDReconstruction/HmpidDecoder2.h index 6d49663c9e368..fe370a8d6e39b 100644 --- a/Detectors/HMPID/reconstruction/include/HMPIDReconstruction/HmpidDecoder2.h +++ b/Detectors/HMPID/reconstruction/include/HMPIDReconstruction/HmpidDecoder2.h @@ -172,6 +172,7 @@ class HmpidDecoder2 bool getBlockFromStream(uint32_t** streamPtr, uint32_t Size); bool getHeaderFromStream(uint32_t** streamPtr); bool getWordFromStream(uint32_t* word); + uint32_t HmpidDecoder2::readWordFromStream(); uint32_t* getActualStreamPtr() { return (mActualStreamPtr); diff --git a/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx b/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx index 99930b70c9912..cac37bf164126 100644 --- a/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx +++ b/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx @@ -851,10 +851,7 @@ void HmpidDecoder2::decodePageFast(uint32_t** streamBuf) int payIndex = 0; while (payIndex < mNumberWordToRead) { //start the payload loop word by word wpprev = wp; - if (!getWordFromStream(&wp)) { // end the stream - //mPayloadTail = 0; - throw TH_BUFFEREMPTY; - } + wp = readWordFromStream(); if (wp == wpprev) { if (mVerbose > 8) { std::cout << "HMPID Decoder2 : [DEBUG] " @@ -871,9 +868,7 @@ void HmpidDecoder2::decodePageFast(uint32_t** streamBuf) payIndex += 1; } for (int i = 0; i < mPayloadTail; i++) { // move the pointer to skip the Payload Tail - if (!getWordFromStream(&wp)) { - throw TH_BUFFEREMPTY; - } + wp = readWordFromStream(); } *streamBuf = mActualStreamPtr; return; @@ -1232,6 +1227,17 @@ bool HmpidDecoder2::getWordFromStream(uint32_t* word) return (false); } +/// Gets a Word from the stream. +/// @returns Tthe word read +uint32_t HmpidDecoder2::readWordFromStream() +{ + mActualStreamPtr++; + if (mActualStreamPtr > mEndStreamPtr) { + throw TH_WRONGBUFFERDIM; + } + return(*mActualStreamPtr); +} + /// Setup the Input Stream with a Memory Pointer /// the buffer length is in byte, some controls are done /// From cf4b78132e08ae4a8052794b5d3ce3efa951653e Mon Sep 17 00:00:00 2001 From: Antonio Franco Date: Tue, 8 Mar 2022 20:24:47 +0100 Subject: [PATCH 2/4] Fix space error --- Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx b/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx index cac37bf164126..8c47657aff851 100644 --- a/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx +++ b/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx @@ -1235,7 +1235,7 @@ uint32_t HmpidDecoder2::readWordFromStream() if (mActualStreamPtr > mEndStreamPtr) { throw TH_WRONGBUFFERDIM; } - return(*mActualStreamPtr); + return (*mActualStreamPtr); } /// Setup the Input Stream with a Memory Pointer From ff8f6a9eca90ff4524f8c51e2515f55f553c83b3 Mon Sep 17 00:00:00 2001 From: Antonio Franco Date: Tue, 8 Mar 2022 20:35:51 +0100 Subject: [PATCH 3/4] Fix clang --- .../HMPID/reconstruction/src/HmpidDecoder2.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx b/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx index 8c47657aff851..0fa3a043ef4bc 100644 --- a/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx +++ b/Detectors/HMPID/reconstruction/src/HmpidDecoder2.cxx @@ -17,7 +17,7 @@ /// \date 17/11/2020 /* ------ HISTORY --------- -*/ + */ #include "FairLogger.h" // for LOG #include "Framework/Logger.h" @@ -530,7 +530,7 @@ void HmpidDecoder2::decodePage(uint32_t** streamBuf) bool isIt; int payIndex = 0; - while (payIndex < mNumberWordToRead) { //start the payload loop word by word + while (payIndex < mNumberWordToRead) { // start the payload loop word by word if (newOne == true) { wpprev = wp; if (!getWordFromStream(&wp)) { // end the stream @@ -805,7 +805,7 @@ void HmpidDecoder2::setPad(HmpidEquipment* eq, int col, int dil, int ch, uint16_ { eq->setPad(col, dil, ch, charge); mDigits.push_back(o2::hmpid::Digit(charge, eq->getEquipmentId(), col, dil, ch)); - //std::cout << "DI " << mDigits.back() << " "<