aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-30 10:06:47 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-30 10:06:47 +0100
commitc56f572c1026a774bcec768821e64ac31354ceff (patch)
tree42119732d24b14f170921bcb5d376d3b27bc556b
parent18276a5d2eac39b08caa2ce44e196e7a98f1a108 (diff)
downloaddabmod-c56f572c1026a774bcec768821e64ac31354ceff.tar.gz
dabmod-c56f572c1026a774bcec768821e64ac31354ceff.tar.bz2
dabmod-c56f572c1026a774bcec768821e64ac31354ceff.zip
Clear PAPRStats when config gets changed
-rw-r--r--src/OfdmGenerator.cpp11
-rw-r--r--src/OfdmGenerator.h2
-rw-r--r--src/PAPRStats.cpp6
-rw-r--r--src/PAPRStats.h2
4 files changed, 21 insertions, 0 deletions
diff --git a/src/OfdmGenerator.cpp b/src/OfdmGenerator.cpp
index 1a819ee..b00d66b 100644
--- a/src/OfdmGenerator.cpp
+++ b/src/OfdmGenerator.cpp
@@ -187,6 +187,14 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut)
// For performance reasons, do not calculate MER for every symbol.
myMERCalcIndex = (myMERCalcIndex + 1) % myNbSymbols;
+ // The PAPRStats' clear() is not threadsafe, do not access it
+ // from the RC functions.
+ if (myPaprClearRequest.load()) {
+ myPaprBeforeCFR.clear();
+ myPaprAfterCFR.clear();
+ myPaprClearRequest.store(false);
+ }
+
for (size_t i = 0; i < myNbSymbols; ++i) {
myFftIn[0][0] = 0;
myFftIn[0][1] = 0;
@@ -358,12 +366,15 @@ void OfdmGenerator::set_parameter(const std::string& parameter,
if (parameter == "cfr") {
ss >> myCfr;
+ myPaprClearRequest.store(true);
}
else if (parameter == "clip") {
ss >> myCfrClip;
+ myPaprClearRequest.store(true);
}
else if (parameter == "errorclip") {
ss >> myCfrErrorClip;
+ myPaprClearRequest.store(true);
}
else if (parameter == "clip_stats" or parameter == "papr") {
throw ParameterError("Parameter '" + parameter + "' is read-only");
diff --git a/src/OfdmGenerator.h b/src/OfdmGenerator.h
index 8374cf9..cccccf5 100644
--- a/src/OfdmGenerator.h
+++ b/src/OfdmGenerator.h
@@ -37,6 +37,7 @@
#include <cstddef>
#include <vector>
#include <complex>
+#include <atomic>
typedef std::complex<float> complexf;
@@ -105,6 +106,7 @@ class OfdmGenerator : public ModCodec, public RemoteControllable
// Measure PAPR before and after CFR
PAPRStats myPaprBeforeCFR;
PAPRStats myPaprAfterCFR;
+ std::atomic<bool> myPaprClearRequest;
size_t myMERCalcIndex = 0;
std::deque<double> myMERs;
diff --git a/src/PAPRStats.cpp b/src/PAPRStats.cpp
index 2e8bca9..1a72238 100644
--- a/src/PAPRStats.cpp
+++ b/src/PAPRStats.cpp
@@ -100,6 +100,12 @@ double PAPRStats::calculate_papr() const
return 10.0 * std::log10(peak / rms2);
}
+void PAPRStats::clear()
+{
+ m_squared_peaks.clear();
+ m_squared_mean.clear();
+}
+
#if defined(TEST)
/* Test python code:
import numpy as np
diff --git a/src/PAPRStats.h b/src/PAPRStats.h
index 92e5231..86ad8b0 100644
--- a/src/PAPRStats.h
+++ b/src/PAPRStats.h
@@ -66,6 +66,8 @@ class PAPRStats
*/
double calculate_papr(void) const;
+ void clear(void);
+
private:
size_t m_num_blocks_to_accumulate;
std::deque<double> m_squared_peaks;