aboutsummaryrefslogtreecommitdiffstats
path: root/src/MemlessPoly.cpp
diff options
context:
space:
mode:
authorandreas128 <Andreas>2017-08-17 16:28:35 +0200
committerandreas128 <Andreas>2017-08-17 16:28:35 +0200
commita8b1aa0b60a1f5bf884069091d0f43b12c521bb8 (patch)
treec1a670f026215797f97c1acc7298c5ad7e05f85e /src/MemlessPoly.cpp
parent4fe5b4cacad22c84110061cb1cce4c0cf29b79fa (diff)
parentfe62dff97924c045affe10da2e896e29e10e6aed (diff)
downloaddabmod-a8b1aa0b60a1f5bf884069091d0f43b12c521bb8.tar.gz
dabmod-a8b1aa0b60a1f5bf884069091d0f43b12c521bb8.tar.bz2
dabmod-a8b1aa0b60a1f5bf884069091d0f43b12c521bb8.zip
Merge branch 'next_memless' of github.com:Opendigitalradio/ODR-DabMod into next_memless
Diffstat (limited to 'src/MemlessPoly.cpp')
-rw-r--r--src/MemlessPoly.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/MemlessPoly.cpp b/src/MemlessPoly.cpp
index 71ceac3..b0d950c 100644
--- a/src/MemlessPoly.cpp
+++ b/src/MemlessPoly.cpp
@@ -53,9 +53,10 @@ static const std::array<complexf, 8> default_coefficients({{
}});
-MemlessPoly::MemlessPoly(const std::string& coefs_file) :
+MemlessPoly::MemlessPoly(const std::string& coefs_file, unsigned int num_threads) :
PipelinedModCodec(),
RemoteControllable("memlesspoly"),
+ m_num_threads(num_threads),
m_coefs(),
m_coefs_file(coefs_file),
m_coefs_mutex()
@@ -63,6 +64,16 @@ MemlessPoly::MemlessPoly(const std::string& coefs_file) :
PDEBUG("MemlessPoly::MemlessPoly(%s) @ %p\n",
coefs_file.c_str(), this);
+ if (m_num_threads == 0) {
+ const unsigned int hw_concurrency = std::thread::hardware_concurrency();
+ etiLog.level(info) << "Polynomial Predistorter will use " <<
+ hw_concurrency << " threads (auto detected)";
+ }
+ else {
+ etiLog.level(info) << "Polynomial Predistorter will use " <<
+ m_num_threads << " threads (set in config file)";
+ }
+
RC_ADD_PARAMETER(ncoefs, "(Read-only) number of coefficients.");
RC_ADD_PARAMETER(coeffile, "Filename containing coefficients. When written to, the new file gets automatically loaded.");
@@ -156,12 +167,15 @@ int MemlessPoly::internal_process(Buffer* const dataIn, Buffer* dataOut)
std::lock_guard<std::mutex> lock(m_coefs_mutex);
const unsigned int hw_concurrency = std::thread::hardware_concurrency();
- if (hw_concurrency) {
- const size_t step = sizeOut / hw_concurrency;
+ const unsigned int num_threads =
+ (m_num_threads > 0) ? m_num_threads : hw_concurrency;
+
+ if (num_threads) {
+ const size_t step = sizeOut / num_threads;
vector<future<void> > flags;
size_t start = 0;
- for (size_t i = 0; i < hw_concurrency - 1; i++) {
+ for (size_t i = 0; i < num_threads - 1; i++) {
flags.push_back(async(launch::async, apply_coeff,
m_coefs, in, start, start + step, out));
@@ -177,13 +191,6 @@ int MemlessPoly::internal_process(Buffer* const dataIn, Buffer* dataOut)
}
}
else {
- static bool error_printed = false;
- if (not error_printed) {
- etiLog.level(warn) <<
- "Your platform doesn't seem to have hardware concurrency. "
- "MemlessPoly will run single-threaded";
- }
- // For some reason we don't have hw concurrency.
apply_coeff(m_coefs, in, 0, sizeOut, out);
}
}