1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 23:55:13 -05:00

Benchmarking: added int to float decimation

This commit is contained in:
f4exb 2018-05-01 19:49:47 +02:00
parent efa168ec77
commit a81e2f297a
10 changed files with 1349 additions and 8 deletions

View File

@ -21,6 +21,7 @@ set(sdrbase_SOURCES
dsp/ctcssdetector.cpp
dsp/cwkeyer.cpp
dsp/cwkeyersettings.cpp
dsp/decimatorsif.cpp
dsp/decimatorsff.cpp
dsp/decimatorsfi.cpp
dsp/dspcommands.cpp
@ -105,6 +106,7 @@ set(sdrbase_HEADERS
dsp/cwkeyer.h
dsp/cwkeyersettings.h
dsp/decimators.h
dsp/decimatorsif.h
dsp/decimatorsff.h
dsp/decimatorsfi.h
dsp/decimatorsu.h

View File

@ -0,0 +1,22 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "decimatorsif.h"
const float decimation_scale<8>::scaleIn = 1.0/128.0;
const float decimation_scale<12>::scaleIn = 1.0/2048.0;
const float decimation_scale<16>::scaleIn = 1.0/32768.0;

1249
sdrbase/dsp/decimatorsif.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -170,7 +170,7 @@ const int32_t HBFIRFilterTraits<64>::hbCoeffs[16] = {
// (qint32)( 0.317657589850154464805598308885237202048 * (1 << hbShift)),
};
const double HBFIRFilterTraits<64>::hbCoeffsF[16] = {
const float HBFIRFilterTraits<64>::hbCoeffsF[16] = {
-0.0004653050334792540416659067936677729449,
0.0007120490624526883919470643391491648799,
-0.0012303473710125558716887983479182366864,

View File

@ -69,7 +69,7 @@ struct SDRBASE_API HBFIRFilterTraits<64>
static const int32_t hbShift = 12;
static const int16_t hbMod[64+6];
static const int32_t hbCoeffs[16] __attribute__ ((aligned (32)));
static const double hbCoeffsF[16];
static const float hbCoeffsF[16];
};
template<>

View File

@ -107,9 +107,9 @@ public:
}
protected:
double m_even[2][HBFIRFilterTraits<HBFilterOrder>::hbOrder]; // double buffer technique
double m_odd[2][HBFIRFilterTraits<HBFilterOrder>::hbOrder]; // double buffer technique
double m_samples[HBFIRFilterTraits<HBFilterOrder>::hbOrder][2]; // double buffer technique
float m_even[2][HBFIRFilterTraits<HBFilterOrder>::hbOrder]; // double buffer technique
float m_odd[2][HBFIRFilterTraits<HBFilterOrder>::hbOrder]; // double buffer technique
float m_samples[HBFIRFilterTraits<HBFilterOrder>::hbOrder][2]; // double buffer technique
int m_ptr;
int m_size;
@ -140,8 +140,8 @@ protected:
void doFIR(float *x, float *y)
{
double iAcc = 0;
double qAcc = 0;
float iAcc = 0;
float qAcc = 0;
//#if defined(USE_SSE4_1) && !defined(NO_DSP_SIMD)
// IntHalfbandFilterEO1Intrisics<HBFilterOrder>::work(

View File

@ -28,7 +28,7 @@ MainBench::MainBench(qtwebapp::LoggerWithFile *logger, const ParserBench& parser
m_logger(logger),
m_parser(parser),
m_uniform_distribution_f(-1.0, 1.0),
m_uniform_distribution_s16(-32768,32767)
m_uniform_distribution_s16(-2048, 2047)
{
qDebug() << "MainBench::MainBench: start";
m_instance = this;
@ -49,6 +49,8 @@ void MainBench::run()
if (m_parser.getTestType() == ParserBench::TestDecimatorsII) {
testDecimateII();
} else if (m_parser.getTestType() == ParserBench::TestDecimatorsIF) {
testDecimateIF();
} else if (m_parser.getTestType() == ParserBench::TestDecimatorsFI) {
testDecimateFI();
} else if (m_parser.getTestType() == ParserBench::TestDecimatorsFF) {
@ -87,6 +89,33 @@ void MainBench::testDecimateII()
delete[] buf;
}
void MainBench::testDecimateIF()
{
QElapsedTimer timer;
qint64 nsecs = 0;
qDebug() << "MainBench::testDecimateIF: create test data";
qint16 *buf = new qint16[m_parser.getNbSamples()*2];
m_convertBufferF.resize(m_parser.getNbSamples()/(1<<m_parser.getLog2Factor()));
auto my_rand = std::bind(m_uniform_distribution_s16, m_generator);
std::generate(buf, buf + m_parser.getNbSamples()*2 - 1, my_rand);
qDebug() << "MainBench::testDecimateIF: run test";
for (uint32_t i = 0; i < m_parser.getRepetition(); i++)
{
timer.start();
decimateIF(buf, m_parser.getNbSamples()*2);
nsecs += timer.nsecsElapsed();
}
printResults("MainBench::testDecimateIF", nsecs);
qDebug() << "MainBench::testDecimateIF: cleanup test data";
delete[] buf;
}
void MainBench::testDecimateFI()
{
QElapsedTimer timer;
@ -173,6 +202,38 @@ void MainBench::decimateII(const qint16* buf, int len)
}
}
void MainBench::decimateIF(const qint16* buf, int len)
{
FSampleVector::iterator it = m_convertBufferF.begin();
switch (m_parser.getLog2Factor())
{
case 0:
m_decimatorsIF.decimate1(&it, buf, len);
break;
case 1:
m_decimatorsIF.decimate2_cen(&it, buf, len);
break;
case 2:
m_decimatorsIF.decimate4_cen(&it, buf, len);
break;
case 3:
m_decimatorsIF.decimate8_cen(&it, buf, len);
break;
case 4:
m_decimatorsIF.decimate16_cen(&it, buf, len);
break;
case 5:
m_decimatorsIF.decimate32_cen(&it, buf, len);
break;
case 6:
m_decimatorsIF.decimate64_cen(&it, buf, len);
break;
default:
break;
}
}
void MainBench::decimateFI(const float *buf, int len)
{
SampleVector::iterator it = m_convertBuffer.begin();

View File

@ -24,6 +24,7 @@
#include <functional>
#include "dsp/decimators.h"
#include "dsp/decimatorsif.h"
#include "dsp/decimatorsfi.h"
#include "dsp/decimatorsff.h"
#include "parserbench.h"
@ -47,9 +48,11 @@ signals:
private:
void testDecimateII();
void testDecimateIF();
void testDecimateFI();
void testDecimateFF();
void decimateII(const qint16 *buf, int len);
void decimateIF(const qint16 *buf, int len);
void decimateFI(const float *buf, int len);
void decimateFF(const float *buf, int len);
void printResults(const QString& prefix, qint64 nsecs);
@ -66,6 +69,7 @@ private:
#else
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> m_decimatorsII;
#endif
DecimatorsIF<qint16, 12> m_decimatorsIF;
DecimatorsFI m_decimatorsFI;
DecimatorsFF m_decimatorsFF;

View File

@ -118,6 +118,8 @@ ParserBench::TestType ParserBench::getTestType() const
return TestDecimatorsFI;
} else if (m_testStr == "decimateff") {
return TestDecimatorsFF;
}else if (m_testStr == "decimateif") {
return TestDecimatorsIF;
} else {
return TestDecimatorsII;
}

View File

@ -27,6 +27,7 @@ public:
typedef enum
{
TestDecimatorsII,
TestDecimatorsIF,
TestDecimatorsFI,
TestDecimatorsFF
} TestType;