mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 17:28:50 -05:00
Floating point to floating point decimator optimization using the even/odd algorithm
This commit is contained in:
parent
48cc6df8a7
commit
efa168ec77
@ -32,7 +32,7 @@ void DecimatorsFF::decimate1(FSampleVector::iterator* it, const float* buf, qint
|
||||
|
||||
void DecimatorsFF::decimate2_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double intbuf[2];
|
||||
float intbuf[2];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 3; pos += 4)
|
||||
{
|
||||
@ -54,7 +54,7 @@ void DecimatorsFF::decimate2_cen(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate2_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double xreal, yimag;
|
||||
float xreal, yimag;
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 7; pos += 8)
|
||||
{
|
||||
@ -74,7 +74,7 @@ void DecimatorsFF::decimate2_inf(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate2_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double xreal, yimag;
|
||||
float xreal, yimag;
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 7; pos += 8)
|
||||
{
|
||||
@ -94,7 +94,7 @@ void DecimatorsFF::decimate2_sup(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate4_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double xreal, yimag;
|
||||
float xreal, yimag;
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 7; pos += 8)
|
||||
{
|
||||
@ -116,7 +116,7 @@ void DecimatorsFF::decimate4_sup(FSampleVector::iterator* it, const float* buf,
|
||||
// Inf (LSB):
|
||||
// x y x y x y x y / x -> 0,-3,-4,7 / y -> 1,2,-5,-6
|
||||
// [ rotate: 0, 1, -3, 2, -4, -5, 7, -6]
|
||||
double xreal, yimag;
|
||||
float xreal, yimag;
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 7; pos += 8)
|
||||
{
|
||||
@ -132,7 +132,7 @@ void DecimatorsFF::decimate4_sup(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate8_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double xreal[2], yimag[2];
|
||||
float xreal[2], yimag[2];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 15; pos += 8)
|
||||
{
|
||||
@ -154,7 +154,7 @@ void DecimatorsFF::decimate8_inf(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate8_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double xreal[2], yimag[2];
|
||||
float xreal[2], yimag[2];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 15; pos += 8)
|
||||
{
|
||||
@ -178,7 +178,7 @@ void DecimatorsFF::decimate16_inf(FSampleVector::iterator* it, const float* buf,
|
||||
{
|
||||
// Offset tuning: 4x downsample and rotate, then
|
||||
// downsample 4x more. [ rotate: 0, 1, -3, 2, -4, -5, 7, -6]
|
||||
double xreal[4], yimag[4];
|
||||
float xreal[4], yimag[4];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 31; )
|
||||
{
|
||||
@ -205,7 +205,7 @@ void DecimatorsFF::decimate16_sup(FSampleVector::iterator* it, const float* buf,
|
||||
{
|
||||
// Offset tuning: 4x downsample and rotate, then
|
||||
// downsample 4x more. [ rotate: 1, 0, -2, 3, -5, -4, 6, -7]
|
||||
double xreal[4], yimag[4];
|
||||
float xreal[4], yimag[4];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 31; )
|
||||
{
|
||||
@ -230,7 +230,7 @@ void DecimatorsFF::decimate16_sup(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate32_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double xreal[8], yimag[8];
|
||||
float xreal[8], yimag[8];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 63; )
|
||||
{
|
||||
@ -260,7 +260,7 @@ void DecimatorsFF::decimate32_inf(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate32_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double xreal[8], yimag[8];
|
||||
float xreal[8], yimag[8];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 63; )
|
||||
{
|
||||
@ -290,7 +290,7 @@ void DecimatorsFF::decimate32_sup(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate64_inf(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double xreal[16], yimag[16];
|
||||
float xreal[16], yimag[16];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 127; )
|
||||
{
|
||||
@ -329,7 +329,7 @@ void DecimatorsFF::decimate64_inf(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate64_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double xreal[16], yimag[16];
|
||||
float xreal[16], yimag[16];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 127; )
|
||||
{
|
||||
@ -368,7 +368,7 @@ void DecimatorsFF::decimate64_sup(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate4_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double intbuf[4];
|
||||
float intbuf[4];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 7; pos += 8)
|
||||
{
|
||||
@ -402,7 +402,7 @@ void DecimatorsFF::decimate4_cen(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate8_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double intbuf[8];
|
||||
float intbuf[8];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 15; pos += 16)
|
||||
{
|
||||
@ -461,7 +461,7 @@ void DecimatorsFF::decimate8_cen(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate16_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double intbuf[16];
|
||||
float intbuf[16];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 31; pos += 32)
|
||||
{
|
||||
@ -569,7 +569,7 @@ void DecimatorsFF::decimate16_cen(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate32_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double intbuf[32];
|
||||
float intbuf[32];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 63; pos += 64)
|
||||
{
|
||||
@ -774,7 +774,7 @@ void DecimatorsFF::decimate32_cen(FSampleVector::iterator* it, const float* buf,
|
||||
|
||||
void DecimatorsFF::decimate64_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ)
|
||||
{
|
||||
double intbuf[64];
|
||||
float intbuf[64];
|
||||
|
||||
for (int pos = 0; pos < nbIAndQ - 127; pos += 128)
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
||||
#ifndef SDRBASE_DSP_DECIMATORSFF_H_
|
||||
#define SDRBASE_DSP_DECIMATORSFF_H_
|
||||
|
||||
#include "dsp/inthalfbandfilterdbf.h"
|
||||
#include "dsp/inthalfbandfiltereof.h"
|
||||
#include "export.h"
|
||||
|
||||
#define DECIMATORSFF_HB_FILTER_ORDER 64
|
||||
@ -46,12 +46,12 @@ public:
|
||||
void decimate64_sup(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ);
|
||||
void decimate64_cen(FSampleVector::iterator* it, const float* buf, qint32 nbIAndQ);
|
||||
|
||||
IntHalfbandFilterDBF<double, float, DECIMATORSFF_HB_FILTER_ORDER> m_decimator2; // 1st stages
|
||||
IntHalfbandFilterDBF<double, float, DECIMATORSFF_HB_FILTER_ORDER> m_decimator4; // 2nd stages
|
||||
IntHalfbandFilterDBF<double, float, DECIMATORSFF_HB_FILTER_ORDER> m_decimator8; // 3rd stages
|
||||
IntHalfbandFilterDBF<double, float, DECIMATORSFF_HB_FILTER_ORDER> m_decimator16; // 4th stages
|
||||
IntHalfbandFilterDBF<double, float, DECIMATORSFF_HB_FILTER_ORDER> m_decimator32; // 5th stages
|
||||
IntHalfbandFilterDBF<double, float, DECIMATORSFF_HB_FILTER_ORDER> m_decimator64; // 6th stages
|
||||
IntHalfbandFilterEOF<DECIMATORSFF_HB_FILTER_ORDER> m_decimator2; // 1st stages
|
||||
IntHalfbandFilterEOF<DECIMATORSFF_HB_FILTER_ORDER> m_decimator4; // 2nd stages
|
||||
IntHalfbandFilterEOF<DECIMATORSFF_HB_FILTER_ORDER> m_decimator8; // 3rd stages
|
||||
IntHalfbandFilterEOF<DECIMATORSFF_HB_FILTER_ORDER> m_decimator16; // 4th stages
|
||||
IntHalfbandFilterEOF<DECIMATORSFF_HB_FILTER_ORDER> m_decimator32; // 5th stages
|
||||
IntHalfbandFilterEOF<DECIMATORSFF_HB_FILTER_ORDER> m_decimator64; // 6th stages
|
||||
};
|
||||
|
||||
|
||||
|
@ -27,7 +27,8 @@ MainBench::MainBench(qtwebapp::LoggerWithFile *logger, const ParserBench& parser
|
||||
QObject(parent),
|
||||
m_logger(logger),
|
||||
m_parser(parser),
|
||||
m_uniform_distribution(-1.0, 1.0)
|
||||
m_uniform_distribution_f(-1.0, 1.0),
|
||||
m_uniform_distribution_s16(-32768,32767)
|
||||
{
|
||||
qDebug() << "MainBench::MainBench: start";
|
||||
m_instance = this;
|
||||
@ -62,22 +63,24 @@ void MainBench::run()
|
||||
void MainBench::testDecimateII()
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
qint64 nsecs;
|
||||
qint64 nsecs = 0;
|
||||
|
||||
qDebug() << "MainBench::testDecimateII: create test data";
|
||||
|
||||
qint16 *buf = new qint16[m_parser.getNbSamples()*2];
|
||||
m_convertBuffer.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::testDecimateII: run test";
|
||||
timer.start();
|
||||
|
||||
for (uint32_t i = 0; i < m_parser.getRepetition(); i++)
|
||||
{
|
||||
timer.start();
|
||||
decimateII(buf, m_parser.getNbSamples()*2);
|
||||
nsecs += timer.nsecsElapsed();
|
||||
}
|
||||
|
||||
nsecs = timer.nsecsElapsed();
|
||||
printResults("MainBench::testDecimateII", nsecs);
|
||||
|
||||
qDebug() << "MainBench::testDecimateII: cleanup test data";
|
||||
@ -87,24 +90,24 @@ void MainBench::testDecimateII()
|
||||
void MainBench::testDecimateFI()
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
qint64 nsecs;
|
||||
qint64 nsecs = 0;
|
||||
|
||||
qDebug() << "MainBench::testDecimateFI: create test data";
|
||||
|
||||
float *buf = new float[m_parser.getNbSamples()*2];
|
||||
m_convertBuffer.resize(m_parser.getNbSamples()/(1<<m_parser.getLog2Factor()));
|
||||
auto my_rand = std::bind(m_uniform_distribution, m_generator);
|
||||
auto my_rand = std::bind(m_uniform_distribution_f, m_generator);
|
||||
std::generate(buf, buf + m_parser.getNbSamples()*2 - 1, my_rand); // make sure data is in [-1.0..1.0] range
|
||||
|
||||
qDebug() << "MainBench::testDecimateFI: run test";
|
||||
timer.start();
|
||||
|
||||
for (uint32_t i = 0; i < m_parser.getRepetition(); i++)
|
||||
{
|
||||
timer.start();
|
||||
decimateFI(buf, m_parser.getNbSamples()*2);
|
||||
nsecs += timer.nsecsElapsed();
|
||||
}
|
||||
|
||||
nsecs = timer.nsecsElapsed();
|
||||
printResults("MainBench::testDecimateFI", nsecs);
|
||||
|
||||
qDebug() << "MainBench::testDecimateFI: cleanup test data";
|
||||
@ -114,24 +117,24 @@ void MainBench::testDecimateFI()
|
||||
void MainBench::testDecimateFF()
|
||||
{
|
||||
QElapsedTimer timer;
|
||||
qint64 nsecs;
|
||||
qint64 nsecs = 0;
|
||||
|
||||
qDebug() << "MainBench::testDecimateFF: create test data";
|
||||
|
||||
float *buf = new float[m_parser.getNbSamples()*2];
|
||||
m_convertBufferF.resize(m_parser.getNbSamples()/(1<<m_parser.getLog2Factor()));
|
||||
auto my_rand = std::bind(m_uniform_distribution, m_generator);
|
||||
auto my_rand = std::bind(m_uniform_distribution_f, m_generator);
|
||||
std::generate(buf, buf + m_parser.getNbSamples()*2 - 1, my_rand); // make sure data is in [-1.0..1.0] range
|
||||
|
||||
qDebug() << "MainBench::testDecimateFF: run test";
|
||||
timer.start();
|
||||
|
||||
for (uint32_t i = 0; i < m_parser.getRepetition(); i++)
|
||||
{
|
||||
timer.start();
|
||||
decimateFF(buf, m_parser.getNbSamples()*2);
|
||||
nsecs += timer.nsecsElapsed();
|
||||
}
|
||||
|
||||
nsecs = timer.nsecsElapsed();
|
||||
printResults("MainBench::testDecimateFF", nsecs);
|
||||
|
||||
qDebug() << "MainBench::testDecimateFF: cleanup test data";
|
||||
|
@ -58,7 +58,8 @@ private:
|
||||
qtwebapp::LoggerWithFile *m_logger;
|
||||
const ParserBench& m_parser;
|
||||
std::mt19937 m_generator;
|
||||
std::uniform_real_distribution<float> m_uniform_distribution;
|
||||
std::uniform_real_distribution<float> m_uniform_distribution_f;
|
||||
std::uniform_int_distribution<qint16> m_uniform_distribution_s16;
|
||||
|
||||
#ifdef SDR_RX_SAMPLE_24BIT
|
||||
Decimators<qint32, qint16, SDR_RX_SAMP_SZ, 12> m_decimatorsII;
|
||||
|
Loading…
Reference in New Issue
Block a user