#2571 Use jAirspy library instead of legacy custom driver code (#2573)

Co-authored-by: sheirerd <sheirerd@ainfosec.com>
This commit is contained in:
Denny Sheirer
2026-11-04 07:00:44 -05:00
committed by GitHub
parent e8e813142b
commit 69d49d9dd0
28 changed files with 493 additions and 3450 deletions

View File

@@ -39,9 +39,6 @@ import io.github.dsheirer.vector.calibrate.magnitude.MagnitudeCalibration;
import io.github.dsheirer.vector.calibrate.mixer.ComplexMixerCalibration;
import io.github.dsheirer.vector.calibrate.oscillator.ComplexOscillatorCalibration;
import io.github.dsheirer.vector.calibrate.oscillator.RealOscillatorCalibration;
import io.github.dsheirer.vector.calibrate.sample.PackedSampleConverterCalibration;
import io.github.dsheirer.vector.calibrate.sample.UnpackedInterleavedSampleConverterCalibration;
import io.github.dsheirer.vector.calibrate.sample.UnpackedSampleConverterCalibration;
import io.github.dsheirer.vector.calibrate.sync.DMRSoftSyncCalibration;
import io.github.dsheirer.vector.calibrate.sync.NXDNSoftSyncCalibration;
import io.github.dsheirer.vector.calibrate.sync.P25P1SoftSyncCalibration;
@@ -103,9 +100,6 @@ public class CalibrationManager
sInstance = new CalibrationManager();
sInstance.add(new PackedSampleConverterCalibration());
sInstance.add(new UnpackedSampleConverterCalibration());
sInstance.add(new UnpackedInterleavedSampleConverterCalibration());
sInstance.add(new AmDemodulatorCalibration());
sInstance.add(new ChannelDFTCalibration());
sInstance.add(new ComplexGainCalibration());

View File

@@ -53,9 +53,6 @@ public enum CalibrationType
OSCILLATOR_REAL("Real Oscillator", 1),
P25P1_SOFT_SYNC_DETECTOR("P25 Phase 1 Soft Sync Detector", 2),
P25P2_SOFT_SYNC_DETECTOR("P25 Phase 2 Soft Sync Detector", 1),
SAMPLE_PACKED_CONVERTER("Packed Sample Converter", 2),
SAMPLE_UNPACKED_INTERLEAVED_ITERATOR("Unpacked Interleaved Sample Iterator", 2),
SAMPLE_UNPACKED_ITERATOR("Unpacked Sample Iterator", 2),
SQUELCHING_FM_DEMODULATOR("Squelching FM Demodulator", 1),
WINDOW("Window", 1);

View File

@@ -1,137 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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 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/>
* ****************************************************************************
*/
package io.github.dsheirer.vector.calibrate.sample;
import io.github.dsheirer.buffer.sample.ScalarUnpackedSampleConverter;
import io.github.dsheirer.buffer.sample.VectorUnpackedSampleConverter;
import io.github.dsheirer.vector.calibrate.Calibration;
import io.github.dsheirer.vector.calibrate.CalibrationException;
import io.github.dsheirer.vector.calibrate.CalibrationType;
import io.github.dsheirer.vector.calibrate.Implementation;
import java.nio.ByteBuffer;
import org.apache.commons.math3.stat.descriptive.moment.Mean;
public class PackedSampleConverterCalibration extends Calibration
{
private static final int BUFFER_SIZE = 262144;
private static final int ITERATION_DURATION_MS = 1000;
private static final int WARM_UP_ITERATIONS = 5;
private static final int TEST_ITERATIONS = 5;
/**
* Constructs an instance
*/
public PackedSampleConverterCalibration()
{
super(CalibrationType.SAMPLE_PACKED_CONVERTER);
}
@Override
public void calibrate() throws CalibrationException
{
Mean scalarMean = new Mean();
Mean vectorMean = new Mean();
byte[] samples = new byte[BUFFER_SIZE];
ByteBuffer buffer = ByteBuffer.wrap(samples);
for(int scalarTest = 0; scalarTest < WARM_UP_ITERATIONS; scalarTest++)
{
long score = testScalar(buffer);
scalarMean.increment(score);
}
mLog.info("PACKED SAMPLE CONVERTER WARMUP - SCALAR: " + DECIMAL_FORMAT.format(scalarMean.getResult()));
for(int vectorTest = 0; vectorTest < WARM_UP_ITERATIONS; vectorTest++)
{
long score = testVector(buffer);
vectorMean.increment(score);
}
mLog.info("PACKED SAMPLE CONVERTER WARMUP - VECTOR: " + DECIMAL_FORMAT.format(vectorMean.getResult()));
scalarMean.clear();
vectorMean.clear();
for(int scalarTest = 0; scalarTest < TEST_ITERATIONS; scalarTest++)
{
long score = testScalar(buffer);
scalarMean.increment(score);
}
mLog.info("PACKED SAMPLE CONVERTER - SCALAR: " + DECIMAL_FORMAT.format(scalarMean.getResult()));
for(int vectorTest = 0; vectorTest < TEST_ITERATIONS; vectorTest++)
{
long score = testVector(buffer);
vectorMean.increment(score);
}
mLog.info("PACKED SAMPLE CONVERTER - VECTOR: " + DECIMAL_FORMAT.format(vectorMean.getResult()));
if(scalarMean.getResult() > vectorMean.getResult())
{
setImplementation(Implementation.SCALAR);
}
else
{
setImplementation(Implementation.VECTOR_SIMD_PREFERRED);
}
mLog.info("PACKED SAMPLE CONVERTER - SETTING OPTIMAL IMPLEMENTATION TO: " + getImplementation());
}
private long testScalar(ByteBuffer buffer)
{
long start = System.currentTimeMillis();
ScalarUnpackedSampleConverter scalor = new ScalarUnpackedSampleConverter();
long count = 0;
double accumulator = 0.0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
short[] converted = scalor.convert(buffer);
accumulator += converted[2];
count++;
}
return count + (long)(accumulator * 0);
}
private long testVector(ByteBuffer buffer)
{
VectorUnpackedSampleConverter vector = new VectorUnpackedSampleConverter();
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
short[] converted = vector.convert(buffer);
accumulator += converted[2];
count++;
}
return count + (long)(accumulator * 0);
}
}

View File

@@ -1,324 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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 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/>
* ****************************************************************************
*/
package io.github.dsheirer.vector.calibrate.sample;
import io.github.dsheirer.buffer.sample.SampleBufferIterator;
import io.github.dsheirer.buffer.sample.SampleInterleavedBufferIteratorScalar;
import io.github.dsheirer.buffer.sample.SampleInterleavedBufferIteratorVector128Bits;
import io.github.dsheirer.buffer.sample.SampleInterleavedBufferIteratorVector256Bits;
import io.github.dsheirer.buffer.sample.SampleInterleavedBufferIteratorVector512Bits;
import io.github.dsheirer.buffer.sample.SampleInterleavedBufferIteratorVector64Bits;
import io.github.dsheirer.vector.calibrate.Calibration;
import io.github.dsheirer.vector.calibrate.CalibrationException;
import io.github.dsheirer.vector.calibrate.CalibrationType;
import io.github.dsheirer.vector.calibrate.Implementation;
import jdk.incubator.vector.FloatVector;
import org.apache.commons.math3.stat.descriptive.moment.Mean;
/**
* Calculates optimal implementation (SCALAR vs VECTOR) for interleaved sample native buffers.
*/
public class UnpackedInterleavedSampleConverterCalibration extends Calibration
{
private static final int BUFFER_SIZE = 131072;
private static final int ITERATION_DURATION_MS = 1000;
private static final int WARMUP_ITERATIONS = 5;
private static final int TEST_ITERATIONS = 5;
/**
* Constructs an instance
*/
public UnpackedInterleavedSampleConverterCalibration()
{
super(CalibrationType.SAMPLE_UNPACKED_INTERLEAVED_ITERATOR);
}
@Override
public void calibrate() throws CalibrationException
{
short[] samples = getShortSamples(BUFFER_SIZE);
short[] residualI = getShortSamples(SampleBufferIterator.I_OVERLAP);
short[] residualQ = getShortSamples(SampleBufferIterator.Q_OVERLAP);
//Warm-Up Phase ....
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER - VECTOR SIMD LANES PREFERRED: " + FloatVector.SPECIES_PREFERRED.length());
Mean scalarMean = new Mean();
for(int x = 0; x < WARMUP_ITERATIONS; x++)
{
long score = calibrateScalar(samples, residualI, residualQ);
scalarMean.increment(score);
}
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER WARMUP - SCALAR: " + DECIMAL_FORMAT.format(scalarMean.getResult()));
switch(FloatVector.SPECIES_PREFERRED.length())
{
//Deliberate fall-through of each case statement so that we can test the largest
//SIMD lane width supported by hardware down to the smallest SIMD lane width.
case 16:
{
Mean vectorMean = new Mean();
for(int x = 0; x < WARMUP_ITERATIONS; x++)
{
long score = calibrateVector512(samples, residualI, residualQ);
vectorMean.increment(score);
}
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER WARMUP - VECTOR 512: " + DECIMAL_FORMAT.format(vectorMean.getResult()));
}
case 8:
{
Mean vectorMean = new Mean();
for(int x = 0; x < WARMUP_ITERATIONS; x++)
{
long score = calibrateVector256(samples, residualI, residualQ);
vectorMean.increment(score);
}
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER WARMUP - VECTOR 256: " + DECIMAL_FORMAT.format(vectorMean.getResult()));
}
case 4:
{
Mean vectorMean = new Mean();
for(int x = 0; x < WARMUP_ITERATIONS; x++)
{
long score = calibrateVector128(samples, residualI, residualQ);
vectorMean.increment(score);
}
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER WARMUP - VECTOR 128: " + DECIMAL_FORMAT.format(vectorMean.getResult()));
}
case 2:
{
Mean vectorMean = new Mean();
for(int x = 0; x < WARMUP_ITERATIONS; x++)
{
long score = calibrateVector64(samples, residualI, residualQ);
vectorMean.increment(score);
}
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER WARMUP - VECTOR 64: " + DECIMAL_FORMAT.format(vectorMean.getResult()));
}
//Test Phase ....
scalarMean.clear();
for(int x = 0; x < TEST_ITERATIONS; x++)
{
long score = calibrateScalar(samples, residualI, residualQ);
scalarMean.increment(score);
}
double bestScore = scalarMean.getResult();
setImplementation(Implementation.SCALAR);
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER - SCALAR: " + DECIMAL_FORMAT.format(scalarMean.getResult()));
switch(FloatVector.SPECIES_PREFERRED.length())
{
//Deliberate fall-through of each case statement so that we can test the largest
//SIMD lane width supported by hardware down to the smallest SIMD lane width.
case 16:
{
Mean vectorMean = new Mean();
for(int x = 0; x < TEST_ITERATIONS; x++)
{
long score = calibrateVector512(samples, residualI, residualQ);
vectorMean.increment(score);
}
if(vectorMean.getResult() > bestScore)
{
bestScore = vectorMean.getResult();
setImplementation(Implementation.VECTOR_SIMD_512);
}
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER - VECTOR 512: " + DECIMAL_FORMAT.format(vectorMean.getResult()));
}
case 8:
{
Mean vectorMean = new Mean();
for(int x = 0; x < TEST_ITERATIONS; x++)
{
long score = calibrateVector256(samples, residualI, residualQ);
vectorMean.increment(score);
}
if(vectorMean.getResult() > bestScore)
{
bestScore = vectorMean.getResult();
setImplementation(Implementation.VECTOR_SIMD_256);
}
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER - VECTOR 256: " + DECIMAL_FORMAT.format(vectorMean.getResult()));
}
case 4:
{
Mean vectorMean = new Mean();
for(int x = 0; x < TEST_ITERATIONS; x++)
{
long score = calibrateVector128(samples, residualI, residualQ);
vectorMean.increment(score);
}
if(vectorMean.getResult() > bestScore)
{
bestScore = vectorMean.getResult();
setImplementation(Implementation.VECTOR_SIMD_128);
}
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER - VECTOR 128: " + DECIMAL_FORMAT.format(vectorMean.getResult()));
}
case 2:
{
Mean vectorMean = new Mean();
for(int x = 0; x < TEST_ITERATIONS; x++)
{
long score = calibrateVector64(samples, residualI, residualQ);
vectorMean.increment(score);
}
if(vectorMean.getResult() > bestScore)
{
setImplementation(Implementation.VECTOR_SIMD_64);
}
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER - VECTOR 64: " + DECIMAL_FORMAT.format(vectorMean.getResult()));
}
}
}
mLog.info("UNPACKED INTERLEAVED SAMPLE CONVERTER - SET OPTIMAL IMPLEMENTATION TO: " + getImplementation());
}
private long calibrateScalar(short[] samples, short[] residualI, short[] residualQ)
{
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
SampleInterleavedBufferIteratorScalar iterator = new SampleInterleavedBufferIteratorScalar(samples, residualI,
residualQ, 0.0f, System.currentTimeMillis(), 0.0f);
while(iterator.hasNext() && ((System.currentTimeMillis() - start) < ITERATION_DURATION_MS))
{
accumulator += iterator.next().samples()[2];
count++;
}
}
return count + (long)(accumulator * 0);
}
private long calibrateVector64(short[] samples, short[] residualI, short[] residualQ)
{
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
SampleInterleavedBufferIteratorVector64Bits iterator = new SampleInterleavedBufferIteratorVector64Bits(samples, residualI,
residualQ, 0.0f, System.currentTimeMillis(), 0.0f);
while(iterator.hasNext() && ((System.currentTimeMillis() - start) < ITERATION_DURATION_MS))
{
accumulator += iterator.next().samples()[2];
count++;
}
}
return count + (long)(accumulator * 0);
}
private long calibrateVector128(short[] samples, short[] residualI, short[] residualQ)
{
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
for(int x = 0; x < ITERATION_DURATION_MS; x++)
{
SampleInterleavedBufferIteratorVector128Bits iterator = new SampleInterleavedBufferIteratorVector128Bits(samples, residualI,
residualQ, 0.0f, System.currentTimeMillis(), 0.0f);
while(iterator.hasNext() && ((System.currentTimeMillis() - start) < ITERATION_DURATION_MS))
{
accumulator += iterator.next().samples()[2];
count++;
}
}
return count + (long)(accumulator * 0);
}
private long calibrateVector256(short[] samples, short[] residualI, short[] residualQ)
{
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
SampleInterleavedBufferIteratorVector256Bits iterator =
new SampleInterleavedBufferIteratorVector256Bits(samples, residualI, residualQ, 0.0f, System.currentTimeMillis(), 0.0f);
while(iterator.hasNext() && ((System.currentTimeMillis() - start) < ITERATION_DURATION_MS))
{
accumulator += iterator.next().samples()[2];
count++;
}
}
return count + (long)(accumulator * 0);
}
private long calibrateVector512(short[] samples, short[] residualI, short[] residualQ)
{
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
SampleInterleavedBufferIteratorVector512Bits iterator =
new SampleInterleavedBufferIteratorVector512Bits(samples, residualI, residualQ, 0.0f,
System.currentTimeMillis(), 0.0f);
while(iterator.hasNext() && ((System.currentTimeMillis() - start) < ITERATION_DURATION_MS))
{
accumulator += iterator.next().samples()[2];
count++;
}
}
return count + (long)(accumulator * 0);
}
}

View File

@@ -1,313 +0,0 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2026 Dennis Sheirer
*
* 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, either version 3 of the License, or
* (at your option) any later version.
*
* 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 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/>
* ****************************************************************************
*/
package io.github.dsheirer.vector.calibrate.sample;
import io.github.dsheirer.buffer.sample.SampleBufferIterator;
import io.github.dsheirer.buffer.sample.SampleBufferIteratorScalar;
import io.github.dsheirer.buffer.sample.SampleBufferIteratorVector128Bits;
import io.github.dsheirer.buffer.sample.SampleBufferIteratorVector256Bits;
import io.github.dsheirer.buffer.sample.SampleBufferIteratorVector512Bits;
import io.github.dsheirer.buffer.sample.SampleBufferIteratorVector64Bits;
import io.github.dsheirer.vector.calibrate.Calibration;
import io.github.dsheirer.vector.calibrate.CalibrationException;
import io.github.dsheirer.vector.calibrate.CalibrationType;
import io.github.dsheirer.vector.calibrate.Implementation;
import jdk.incubator.vector.FloatVector;
import org.apache.commons.math3.stat.descriptive.moment.Mean;
/**
* Calculates optimal implementation (SCALAR vs VECTOR) for non-interleaved sample native buffers.
*/
public class UnpackedSampleConverterCalibration extends Calibration
{
private static final int BUFFER_SIZE = 131072;
private static final int ITERATION_DURATION_MS = 1000;
private static final int WARMUP_ITERATIONS = 5;
private static final int TEST_ITERATIONS = 5;
/**
* Constructs an instance
*/
public UnpackedSampleConverterCalibration()
{
super(CalibrationType.SAMPLE_UNPACKED_ITERATOR);
}
@Override
public void calibrate() throws CalibrationException
{
short[] samples = getShortSamples(BUFFER_SIZE);
short[] residualI = getShortSamples(SampleBufferIterator.I_OVERLAP);
short[] residualQ = getShortSamples(SampleBufferIterator.Q_OVERLAP);
mLog.info("UNPACKED SAMPLE CONVERTER - VECTOR SIMD LANES PREFERRED: " + FloatVector.SPECIES_PREFERRED.length());
//Warm-Up Phase ....
Mean scalarMean = new Mean();
for(int warmup = 0; warmup < WARMUP_ITERATIONS; warmup++)
{
long score = testScalar(samples, residualI, residualQ);
scalarMean.increment(score);
}
mLog.info("UNPACKED SAMPLE CONVERTER WARMUP - SCALAR: " + DECIMAL_FORMAT.format(scalarMean.getResult()));
switch(FloatVector.SPECIES_PREFERRED.length())
{
//Deliberate fall-through of each case statement so that we can test the largest
//SIMD lane width supported by hardware down to the smallest SIMD lane width.
case 16:
{
Mean vector512Mean = new Mean();
for(int warmup = 0; warmup < WARMUP_ITERATIONS; warmup++)
{
long score = testVector512(samples, residualI, residualQ);
vector512Mean.increment(score);
}
mLog.info("UNPACKED SAMPLE CONVERTER WARMUP - VECTOR 512: " + DECIMAL_FORMAT.format(vector512Mean.getResult()));
}
case 8:
{
Mean vector256Mean = new Mean();
for(int warmup = 0; warmup < WARMUP_ITERATIONS; warmup++)
{
long score = testVector256(samples, residualI, residualQ);
vector256Mean.increment(score);
}
mLog.info("UNPACKED SAMPLE CONVERTER WARMUP - VECTOR 256: " + DECIMAL_FORMAT.format(vector256Mean.getResult()));
}
case 4:
{
Mean vector128Mean = new Mean();
for(int warmup = 0; warmup < WARMUP_ITERATIONS; warmup++)
{
long score = testVector128(samples, residualI, residualQ);
vector128Mean.increment(score);
}
mLog.info("UNPACKED SAMPLE CONVERTER WARMUP - VECTOR 128: " + DECIMAL_FORMAT.format(vector128Mean.getResult()));
}
case 2:
{
Mean vector64Mean = new Mean();
for(int warmup = 0; warmup < WARMUP_ITERATIONS; warmup++)
{
long score = testVector64(samples, residualI, residualQ);
vector64Mean.increment(score);
}
mLog.info("UNPACKED SAMPLE CONVERTER WARMUP - VECTOR 64: " + DECIMAL_FORMAT.format(vector64Mean.getResult()));
}
}
//Test Phase ....
scalarMean.clear();
for(int test = 0; test < TEST_ITERATIONS; test++)
{
long score = testScalar(samples, residualI, residualQ);
scalarMean.increment(score);
}
double bestScore = scalarMean.getResult();
setImplementation(Implementation.SCALAR);
mLog.info("UNPACKED SAMPLE CONVERTER - SCALAR: " + DECIMAL_FORMAT.format(scalarMean.getResult()));
switch(FloatVector.SPECIES_PREFERRED.length())
{
//Deliberate fall-through of each case statement so that we can test the largest
//SIMD lane width supported by hardware down to the smallest SIMD lane width.
case 16:
{
Mean vector512Mean = new Mean();
for(int test = 0; test < TEST_ITERATIONS; test++)
{
long score = testVector512(samples, residualI, residualQ);
vector512Mean.increment(score);
}
mLog.info("UNPACKED SAMPLE CONVERTER - VECTOR 512: " + DECIMAL_FORMAT.format(vector512Mean.getResult()));
if(vector512Mean.getResult() > bestScore)
{
bestScore = vector512Mean.getResult();
setImplementation(Implementation.VECTOR_SIMD_512);
}
}
case 8:
{
Mean vector256Mean = new Mean();
for(int test = 0; test < TEST_ITERATIONS; test++)
{
long score = testVector256(samples, residualI, residualQ);
vector256Mean.increment(score);
}
mLog.info("UNPACKED SAMPLE CONVERTER - VECTOR 256: " + DECIMAL_FORMAT.format(vector256Mean.getResult()));
if(vector256Mean.getResult() > bestScore)
{
bestScore = vector256Mean.getResult();
setImplementation(Implementation.VECTOR_SIMD_256);
}
}
case 4:
{
Mean vector128Mean = new Mean();
for(int test = 0; test < TEST_ITERATIONS; test++)
{
long score = testVector128(samples, residualI, residualQ);
vector128Mean.increment(score);
}
mLog.info("UNPACKED SAMPLE CONVERTER - VECTOR 128: " + DECIMAL_FORMAT.format(vector128Mean.getResult()));
if(vector128Mean.getResult() > bestScore)
{
bestScore = vector128Mean.getResult();
setImplementation(Implementation.VECTOR_SIMD_128);
}
}
case 2:
{
Mean vector64Mean = new Mean();
for(int test = 0; test < TEST_ITERATIONS; test++)
{
long score = testVector64(samples, residualI, residualQ);
vector64Mean.increment(score);
}
mLog.info("UNPACKED SAMPLE CONVERTER - VECTOR 64: " + DECIMAL_FORMAT.format(vector64Mean.getResult()));
if(vector64Mean.getResult() > bestScore)
{
setImplementation(Implementation.VECTOR_SIMD_64);
}
}
}
mLog.info("UNPACKED SAMPLE CONVERTER - SET OPTIMAL IMPLEMENTATION TO: " + getImplementation());
}
private long testScalar(short[] samples, short[] residualI, short[] residualQ)
{
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
SampleBufferIteratorScalar iterator = new SampleBufferIteratorScalar(samples, residualI,
residualQ, 0.0f, System.currentTimeMillis(), 0.0f);
while(iterator.hasNext() && ((System.currentTimeMillis() - start) < ITERATION_DURATION_MS))
{
accumulator += iterator.next().i()[2];
count++;
}
}
return count + (long)(accumulator * 0);
}
private long testVector64(short[] samples, short[] residualI, short[] residualQ)
{
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
SampleBufferIteratorVector64Bits iterator = new SampleBufferIteratorVector64Bits(samples, residualI,
residualQ, 0.0f, System.currentTimeMillis(), 0.0f);
while(iterator.hasNext() && ((System.currentTimeMillis() - start) < ITERATION_DURATION_MS))
{
accumulator += iterator.next().i()[2];
count++;
}
}
return count + (long)(accumulator * 0);
}
private long testVector128(short[] samples, short[] residualI, short[] residualQ)
{
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
SampleBufferIteratorVector128Bits iterator = new SampleBufferIteratorVector128Bits(samples, residualI,
residualQ, 0.0f, System.currentTimeMillis(), 0.0f);
while(iterator.hasNext() && ((System.currentTimeMillis() - start) < ITERATION_DURATION_MS))
{
accumulator += iterator.next().i()[2];
count++;
}
}
return count + (long)(accumulator * 0);
}
private long testVector256(short[] samples, short[] residualI, short[] residualQ)
{
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
SampleBufferIteratorVector256Bits iterator =
new SampleBufferIteratorVector256Bits(samples, residualI, residualQ, 0.0f,
System.currentTimeMillis(), 0.0f);
while(iterator.hasNext() && ((System.currentTimeMillis() - start) < ITERATION_DURATION_MS))
{
accumulator += iterator.next().i()[2];
count++;
}
}
return count + (long)(accumulator * 0);
}
private long testVector512(short[] samples, short[] residualI, short[] residualQ)
{
long start = System.currentTimeMillis();
double accumulator = 0.0;
long count = 0;
while((System.currentTimeMillis() - start) < ITERATION_DURATION_MS)
{
SampleBufferIteratorVector512Bits iterator =
new SampleBufferIteratorVector512Bits(samples, residualI, residualQ, 0.0f,
System.currentTimeMillis(), 0.0f);
while(iterator.hasNext() && ((System.currentTimeMillis() - start) < ITERATION_DURATION_MS))
{
accumulator += iterator.next().i()[2];
count++;
}
}
return count + (long)(accumulator * 0);
}
}