mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 05:41:56 -05:00
IntHalfband filters: tuned optimizations and chose the best for x86_64
This commit is contained in:
parent
d2c6791eea
commit
0a6dc5db37
@ -19,7 +19,7 @@
|
||||
|
||||
#include "dsp/dsptypes.h"
|
||||
#ifdef USE_SSE4_1
|
||||
#include "dsp/inthalfbandfilterst.h"
|
||||
#include "dsp/inthalfbandfiltereo1.h"
|
||||
#else
|
||||
#include "dsp/inthalfbandfilterdb.h"
|
||||
#endif
|
||||
@ -125,12 +125,12 @@ public:
|
||||
|
||||
private:
|
||||
#ifdef USE_SSE4_1
|
||||
IntHalfbandFilterST<DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
|
||||
IntHalfbandFilterST<DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
|
||||
IntHalfbandFilterST<DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages
|
||||
IntHalfbandFilterST<DECIMATORS_HB_FILTER_ORDER> m_decimator16; // 4th stages
|
||||
IntHalfbandFilterST<DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages
|
||||
IntHalfbandFilterST<DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages
|
||||
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
|
||||
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
|
||||
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator8; // 3rd stages
|
||||
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator16; // 4th stages
|
||||
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator32; // 5th stages
|
||||
IntHalfbandFilterEO1<DECIMATORS_HB_FILTER_ORDER> m_decimator64; // 6th stages
|
||||
#else
|
||||
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator2; // 1st stages
|
||||
IntHalfbandFilterDB<DECIMATORS_HB_FILTER_ORDER> m_decimator4; // 2nd stages
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
{
|
||||
case 0:
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 1;
|
||||
// tell caller we don't have a new sample
|
||||
@ -51,7 +51,7 @@ public:
|
||||
// save result
|
||||
doFIR(sample);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 0;
|
||||
|
||||
@ -71,7 +71,7 @@ public:
|
||||
// save result
|
||||
doFIR(SampleOut);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 1;
|
||||
// tell caller we didn't consume the sample
|
||||
@ -83,7 +83,7 @@ public:
|
||||
// save result
|
||||
doFIR(SampleOut);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 0;
|
||||
// tell caller we consumed the sample
|
||||
@ -100,7 +100,7 @@ public:
|
||||
{
|
||||
case 0:
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 1;
|
||||
// tell caller we don't have a new sample
|
||||
@ -110,7 +110,7 @@ public:
|
||||
// save result
|
||||
doFIR(x, y);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 0;
|
||||
// tell caller we have a new sample
|
||||
@ -127,7 +127,7 @@ public:
|
||||
// insert sample into ring-buffer
|
||||
storeSample((FixReal) -sample->imag(), (FixReal) sample->real());
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 1;
|
||||
// tell caller we don't have a new sample
|
||||
@ -139,7 +139,7 @@ public:
|
||||
// save result
|
||||
doFIR(sample);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 2;
|
||||
// tell caller we have a new sample
|
||||
@ -149,7 +149,7 @@ public:
|
||||
// insert sample into ring-buffer
|
||||
storeSample((FixReal) sample->imag(), (FixReal) -sample->real());
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 3;
|
||||
// tell caller we don't have a new sample
|
||||
@ -161,7 +161,7 @@ public:
|
||||
// save result
|
||||
doFIR(sample);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 0;
|
||||
// tell caller we have a new sample
|
||||
@ -186,7 +186,7 @@ public:
|
||||
sampleOut->setImag(-s.real());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 1;
|
||||
@ -204,7 +204,7 @@ public:
|
||||
sampleOut->setImag(-s.imag());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 2;
|
||||
@ -222,7 +222,7 @@ public:
|
||||
sampleOut->setImag(s.real());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 3;
|
||||
@ -240,7 +240,7 @@ public:
|
||||
sampleOut->setImag(s.imag());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 0;
|
||||
@ -259,7 +259,7 @@ public:
|
||||
// insert sample into ring-buffer
|
||||
storeSample((FixReal) sample->imag(), (FixReal) -sample->real());
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 1;
|
||||
// tell caller we don't have a new sample
|
||||
@ -271,7 +271,7 @@ public:
|
||||
// save result
|
||||
doFIR(sample);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 2;
|
||||
// tell caller we have a new sample
|
||||
@ -281,7 +281,7 @@ public:
|
||||
// insert sample into ring-buffer
|
||||
storeSample((FixReal) -sample->imag(), (FixReal) sample->real());
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 3;
|
||||
// tell caller we don't have a new sample
|
||||
@ -293,7 +293,7 @@ public:
|
||||
// save result
|
||||
doFIR(sample);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 0;
|
||||
// tell caller we have a new sample
|
||||
@ -318,7 +318,7 @@ public:
|
||||
sampleOut->setImag(s.real());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 1;
|
||||
@ -336,7 +336,7 @@ public:
|
||||
sampleOut->setImag(-s.imag());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 2;
|
||||
@ -354,7 +354,7 @@ public:
|
||||
sampleOut->setImag(-s.real());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 3;
|
||||
@ -372,7 +372,7 @@ public:
|
||||
sampleOut->setImag(s.imag());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 0;
|
||||
@ -385,21 +385,21 @@ public:
|
||||
void myDecimate(const Sample* sample1, Sample* sample2)
|
||||
{
|
||||
storeSample((FixReal) sample1->real(), (FixReal) sample1->imag());
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
storeSample((FixReal) sample2->real(), (FixReal) sample2->imag());
|
||||
doFIR(sample2);
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
}
|
||||
|
||||
void myDecimate(qint32 x1, qint32 y1, qint32 *x2, qint32 *y2)
|
||||
{
|
||||
storeSample(x1, y1);
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
storeSample(*x2, *y2);
|
||||
doFIR(x2, y2);
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -424,6 +424,11 @@ protected:
|
||||
m_samplesDB[m_ptr + m_size][1] = y;
|
||||
}
|
||||
|
||||
void advancePointer()
|
||||
{
|
||||
m_ptr = m_ptr + 1 < m_size ? m_ptr + 1: 0;
|
||||
}
|
||||
|
||||
void doFIR(Sample* sample)
|
||||
{
|
||||
int a = m_ptr + m_size; // tip pointer
|
||||
|
@ -450,7 +450,7 @@ protected:
|
||||
|
||||
void advancePointer()
|
||||
{
|
||||
m_ptr = (m_ptr + 1) % (2*m_size);
|
||||
m_ptr = m_ptr + 1 < 2*m_size ? m_ptr + 1: 0;
|
||||
}
|
||||
|
||||
void doFIR(Sample* sample)
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
{
|
||||
case 0:
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 1;
|
||||
// tell caller we don't have a new sample
|
||||
@ -52,7 +52,7 @@ public:
|
||||
// save result
|
||||
doFIR(sample);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 0;
|
||||
|
||||
@ -72,7 +72,7 @@ public:
|
||||
// save result
|
||||
doFIR(SampleOut);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 1;
|
||||
// tell caller we didn't consume the sample
|
||||
@ -84,7 +84,7 @@ public:
|
||||
// save result
|
||||
doFIR(SampleOut);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 0;
|
||||
// tell caller we consumed the sample
|
||||
@ -101,7 +101,7 @@ public:
|
||||
{
|
||||
case 0:
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 1;
|
||||
// tell caller we don't have a new sample
|
||||
@ -111,7 +111,7 @@ public:
|
||||
// save result
|
||||
doFIR(x, y);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 0;
|
||||
// tell caller we have a new sample
|
||||
@ -128,7 +128,7 @@ public:
|
||||
// insert sample into ring-buffer
|
||||
storeSample((FixReal) -sample->imag(), (FixReal) sample->real());
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 1;
|
||||
// tell caller we don't have a new sample
|
||||
@ -140,7 +140,7 @@ public:
|
||||
// save result
|
||||
doFIR(sample);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 2;
|
||||
// tell caller we have a new sample
|
||||
@ -150,7 +150,7 @@ public:
|
||||
// insert sample into ring-buffer
|
||||
storeSample((FixReal) sample->imag(), (FixReal) -sample->real());
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 3;
|
||||
// tell caller we don't have a new sample
|
||||
@ -162,7 +162,7 @@ public:
|
||||
// save result
|
||||
doFIR(sample);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 0;
|
||||
// tell caller we have a new sample
|
||||
@ -187,7 +187,7 @@ public:
|
||||
sampleOut->setImag(-s.real());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 1;
|
||||
@ -205,7 +205,7 @@ public:
|
||||
sampleOut->setImag(-s.imag());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 2;
|
||||
@ -223,7 +223,7 @@ public:
|
||||
sampleOut->setImag(s.real());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 3;
|
||||
@ -241,7 +241,7 @@ public:
|
||||
sampleOut->setImag(s.imag());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 0;
|
||||
@ -260,7 +260,7 @@ public:
|
||||
// insert sample into ring-buffer
|
||||
storeSample((FixReal) sample->imag(), (FixReal) -sample->real());
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 1;
|
||||
// tell caller we don't have a new sample
|
||||
@ -272,7 +272,7 @@ public:
|
||||
// save result
|
||||
doFIR(sample);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 2;
|
||||
// tell caller we have a new sample
|
||||
@ -282,7 +282,7 @@ public:
|
||||
// insert sample into ring-buffer
|
||||
storeSample((FixReal) -sample->imag(), (FixReal) sample->real());
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 3;
|
||||
// tell caller we don't have a new sample
|
||||
@ -294,7 +294,7 @@ public:
|
||||
// save result
|
||||
doFIR(sample);
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
// next state
|
||||
m_state = 0;
|
||||
// tell caller we have a new sample
|
||||
@ -319,7 +319,7 @@ public:
|
||||
sampleOut->setImag(s.real());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 1;
|
||||
@ -337,7 +337,7 @@ public:
|
||||
sampleOut->setImag(-s.imag());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 2;
|
||||
@ -355,7 +355,7 @@ public:
|
||||
sampleOut->setImag(-s.real());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 3;
|
||||
@ -373,7 +373,7 @@ public:
|
||||
sampleOut->setImag(s.imag());
|
||||
|
||||
// advance write-pointer
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
// next state
|
||||
m_state = 0;
|
||||
@ -386,21 +386,21 @@ public:
|
||||
void myDecimate(const Sample* sample1, Sample* sample2)
|
||||
{
|
||||
storeSample((FixReal) sample1->real(), (FixReal) sample1->imag());
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
storeSample((FixReal) sample2->real(), (FixReal) sample2->imag());
|
||||
doFIR(sample2);
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
}
|
||||
|
||||
void myDecimate(qint32 x1, qint32 y1, qint32 *x2, qint32 *y2)
|
||||
{
|
||||
storeSample(x1, y1);
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
|
||||
storeSample(*x2, *y2);
|
||||
doFIR(x2, y2);
|
||||
m_ptr = (m_ptr + 1) % m_size;
|
||||
advancePointer();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -431,6 +431,11 @@ protected:
|
||||
m_samplesDB[m_ptr + m_size][1] = y;
|
||||
}
|
||||
|
||||
void advancePointer()
|
||||
{
|
||||
m_ptr = m_ptr + 1 < m_size ? m_ptr + 1: 0;
|
||||
}
|
||||
|
||||
void doFIR(Sample* sample)
|
||||
{
|
||||
// calculate on odd values
|
||||
@ -442,9 +447,10 @@ protected:
|
||||
m_iOddAcc = 0;
|
||||
m_qOddAcc = 0;
|
||||
#ifdef USE_SSE4_1
|
||||
memcpy((void *) m_samplesAligned, (const void *) &(m_samplesDB[ m_ptr + 1][0]), HBFilterOrder*2*sizeof(qint32));
|
||||
IntHalfbandFilterSTIntrinsics<HBFilterOrder>::work(
|
||||
m_samplesAligned,
|
||||
// memcpy((void *) m_samplesAligned, (const void *) &(m_samplesDB[ m_ptr + 1][0]), HBFilterOrder*2*sizeof(qint32));
|
||||
IntHalfbandFilterSTIntrinsics<HBFilterOrder>::workNA(
|
||||
m_ptr + 1,
|
||||
m_samplesDB,
|
||||
m_iEvenAcc,
|
||||
m_qEvenAcc,
|
||||
m_iOddAcc,
|
||||
@ -490,9 +496,10 @@ protected:
|
||||
m_qOddAcc = 0;
|
||||
|
||||
#ifdef USE_SSE4_1
|
||||
memcpy((void *) m_samplesAligned, (const void *) &(m_samplesDB[ m_ptr + 1][0]), HBFilterOrder*2*sizeof(qint32));
|
||||
IntHalfbandFilterSTIntrinsics<HBFilterOrder>::work(
|
||||
m_samplesAligned,
|
||||
// memcpy((void *) m_samplesAligned, (const void *) &(m_samplesDB[ m_ptr + 1][0]), HBFilterOrder*2*sizeof(qint32));
|
||||
IntHalfbandFilterSTIntrinsics<HBFilterOrder>::workNA(
|
||||
m_ptr + 1,
|
||||
m_samplesDB,
|
||||
m_iEvenAcc,
|
||||
m_qEvenAcc,
|
||||
m_iOddAcc,
|
||||
|
@ -1,92 +1,144 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// Integer half-band FIR based interpolator and decimator //
|
||||
// This is the even/odd and I/Q stride with double buffering variant //
|
||||
// This is the SIMD intrinsics code //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRBASE_DSP_INTHALFBANDFILTERSTI_H_
|
||||
#define SDRBASE_DSP_INTHALFBANDFILTERSTI_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(USE_SSE4_1)
|
||||
#include <smmintrin.h>
|
||||
#endif
|
||||
|
||||
#include "hbfiltertraits.h"
|
||||
|
||||
template<uint32_t HBFilterOrder>
|
||||
class IntHalfbandFilterSTIntrinsics
|
||||
{
|
||||
public:
|
||||
static void work(
|
||||
int32_t samples[HBFilterOrder][2],
|
||||
int32_t& iEvenAcc, int32_t& qEvenAcc,
|
||||
int32_t& iOddAcc, int32_t& qOddAcc)
|
||||
{
|
||||
#if defined(USE_SSE4_1)
|
||||
int a = HBFIRFilterTraits<HBFilterOrder>::hbOrder - 2; // tip
|
||||
int b = 0; // tail
|
||||
const __m128i* h = (const __m128i*) HBFIRFilterTraits<HBFilterOrder>::hbCoeffs;
|
||||
__m128i sum = _mm_setzero_si128();
|
||||
__m128i sh, shh, sa, sb;
|
||||
int32_t sums[4] __attribute__ ((aligned (16)));
|
||||
|
||||
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 16; i++)
|
||||
{
|
||||
sh = _mm_load_si128(h);
|
||||
shh = _mm_shuffle_epi32(sh, _MM_SHUFFLE(0,0,0,0));
|
||||
sa = _mm_load_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_load_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
shh = _mm_shuffle_epi32(sh, _MM_SHUFFLE(1,1,1,1));
|
||||
sa = _mm_load_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_load_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
shh = _mm_shuffle_epi32(sh, _MM_SHUFFLE(2,2,2,2));
|
||||
sa = _mm_load_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_load_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
shh = _mm_shuffle_epi32(sh, _MM_SHUFFLE(3,3,3,3));
|
||||
sa = _mm_load_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_load_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
++h;
|
||||
}
|
||||
|
||||
// Extract values from sum vector
|
||||
_mm_store_si128((__m128i*) sums, sum);
|
||||
iEvenAcc = sums[0];
|
||||
qEvenAcc = sums[1];
|
||||
iOddAcc = sums[2];
|
||||
qOddAcc = sums[3];
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* SDRBASE_DSP_INTHALFBANDFILTERSTI_H_ */
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2016 F4EXB //
|
||||
// written by Edouard Griffiths //
|
||||
// //
|
||||
// Integer half-band FIR based interpolator and decimator //
|
||||
// This is the even/odd and I/Q stride with double buffering variant //
|
||||
// This is the SIMD intrinsics code //
|
||||
// //
|
||||
// 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/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef SDRBASE_DSP_INTHALFBANDFILTERSTI_H_
|
||||
#define SDRBASE_DSP_INTHALFBANDFILTERSTI_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(USE_SSE4_1)
|
||||
#include <smmintrin.h>
|
||||
#endif
|
||||
|
||||
#include "hbfiltertraits.h"
|
||||
|
||||
template<uint32_t HBFilterOrder>
|
||||
class IntHalfbandFilterSTIntrinsics
|
||||
{
|
||||
public:
|
||||
static void work(
|
||||
int32_t samples[HBFilterOrder][2],
|
||||
int32_t& iEvenAcc, int32_t& qEvenAcc,
|
||||
int32_t& iOddAcc, int32_t& qOddAcc)
|
||||
{
|
||||
#if defined(USE_SSE4_1)
|
||||
int a = HBFIRFilterTraits<HBFilterOrder>::hbOrder - 2; // tip
|
||||
int b = 0; // tail
|
||||
const __m128i* h = (const __m128i*) HBFIRFilterTraits<HBFilterOrder>::hbCoeffs;
|
||||
__m128i sum = _mm_setzero_si128();
|
||||
__m128i shh, sa, sb;
|
||||
int32_t sums[4] __attribute__ ((aligned (16)));
|
||||
|
||||
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 16; i++)
|
||||
{
|
||||
shh = _mm_shuffle_epi32(*h, _MM_SHUFFLE(0,0,0,0));
|
||||
sa = _mm_load_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_load_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
shh = _mm_shuffle_epi32(*h, _MM_SHUFFLE(1,1,1,1));
|
||||
sa = _mm_load_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_load_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
shh = _mm_shuffle_epi32(*h, _MM_SHUFFLE(2,2,2,2));
|
||||
sa = _mm_load_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_load_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
shh = _mm_shuffle_epi32(*h, _MM_SHUFFLE(3,3,3,3));
|
||||
sa = _mm_load_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_load_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
++h;
|
||||
}
|
||||
|
||||
// Extract values from sum vector
|
||||
_mm_store_si128((__m128i*) sums, sum);
|
||||
iEvenAcc = sums[0];
|
||||
qEvenAcc = sums[1];
|
||||
iOddAcc = sums[2];
|
||||
qOddAcc = sums[3];
|
||||
#endif
|
||||
}
|
||||
|
||||
// not aligned version
|
||||
static void workNA(
|
||||
int ptr,
|
||||
int32_t samples[HBFilterOrder*2][2],
|
||||
int32_t& iEvenAcc, int32_t& qEvenAcc,
|
||||
int32_t& iOddAcc, int32_t& qOddAcc)
|
||||
{
|
||||
#if defined(USE_SSE4_1)
|
||||
int a = ptr + HBFIRFilterTraits<HBFilterOrder>::hbOrder - 2; // tip
|
||||
int b = ptr + 0; // tail
|
||||
const __m128i* h = (const __m128i*) HBFIRFilterTraits<HBFilterOrder>::hbCoeffs;
|
||||
__m128i sum = _mm_setzero_si128();
|
||||
__m128i shh, sa, sb;
|
||||
int32_t sums[4] __attribute__ ((aligned (16)));
|
||||
|
||||
for (int i = 0; i < HBFIRFilterTraits<HBFilterOrder>::hbOrder / 16; i++)
|
||||
{
|
||||
shh = _mm_shuffle_epi32(*h, _MM_SHUFFLE(0,0,0,0));
|
||||
sa = _mm_loadu_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_loadu_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
shh = _mm_shuffle_epi32(*h, _MM_SHUFFLE(1,1,1,1));
|
||||
sa = _mm_loadu_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_loadu_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
shh = _mm_shuffle_epi32(*h, _MM_SHUFFLE(2,2,2,2));
|
||||
sa = _mm_loadu_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_loadu_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
shh = _mm_shuffle_epi32(*h, _MM_SHUFFLE(3,3,3,3));
|
||||
sa = _mm_loadu_si128((__m128i*) &(samples[a][0])); // Ei,Eq,Oi,Oq
|
||||
sb = _mm_loadu_si128((__m128i*) &(samples[b][0]));
|
||||
sum = _mm_add_epi32(sum, _mm_mullo_epi32(_mm_add_epi32(sa, sb), shh));
|
||||
a -= 2;
|
||||
b += 2;
|
||||
++h;
|
||||
}
|
||||
|
||||
// Extract values from sum vector
|
||||
_mm_store_si128((__m128i*) sums, sum);
|
||||
iEvenAcc = sums[0];
|
||||
qEvenAcc = sums[1];
|
||||
iOddAcc = sums[2];
|
||||
qOddAcc = sums[3];
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* SDRBASE_DSP_INTHALFBANDFILTERSTI_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user