Skip to content

Commit

Permalink
Updates complex decimation filters to use either scalar or vector opt…
Browse files Browse the repository at this point in the history
…imal implementation. (#1148)

Updates HackRF native byte buffers with automatic DC removal.
Creates new half-band channel source to replace the cic-based channel source in the heterodyne channelizer.  Resolves issue in RTL native buffer processing.  Creates a CACHED thread pool and reduces the number of threads for the SCHEDULED thread pool to 2.  Changes each of the channel source implementations to use a dedicated thread (Dispatcher class) instead of the scheduled thread pool, to reduce the amount of buffered/retained samples objects in memory. Lots of other small changes and tweaks.
Removes last of Reusable buffer code.  Updates DFTProcessor to use a single thread scheduled executor.  Updates Polyphase channelizer to use threads instead of an executor.  Removes a number of unused classes.
Commenting out window calibration.  Scalar is faster in both implementations.
Adds vector and scalar implementations for windows.  Repackages window and window type classes.
WIP adds vector implementations for Airspy non-interleaved buffer iterator and calibration plugins for both interleaved and non-interleaved buffer iterators.
WIP adds vector implementations for Airspy interleaved buffer iterator.
Work on developing scalar and vector implementations of airspy sample conversion and airspy native buffer processing.
Introduces new INativeBuffer framework where tuner raw samples are retained in their native (compressed) format until when they're needed and they are converted on-demand into smaller complex sample buffers to aid garbage collection.
Removes all usage of ReusableComplexBuffers and ReusableChannelREsultsBuffers.  Updates polyphase channelizer to be more efficient in output channel processing.
Updates ViterbiDecoder to change Map usage to array for memory efficiency.
Updates channel processors to used scalar implementation for gain and mixer, until the polyphase channel results can be fixed to be a multiple of the SIMD lane width.
Resolves final changes for the conversion from interleaved sample arrays to complexsamples buffers for distributing baseband samples to channels and processing chains.
Updates tuner channel sources and all decoders to receive new complex samples buffers, removing the previous reusable complex buffers as the default baseband samples buffer object.
Still to resolve is the ComplexMixer implementations.  Needs validation and a calibration implementation with an update to the complex mixer factory.
Updates the DMR decoder to use optimal (scalar vs vector) implementations of filter and AGC controls.
Updates the AM demodulator for separated I&Q float sample processing.
Code review and testing changes.
updates build script for runtime configuration.
Integrates calibration manager with main sdrtrunk application.  Updates NBFMDecoder to use new optimized FIR and Decimation filter options.
Updates real half-band decimation filters to select the optimal (scalar vs vector) implementation.
Adds calibration manager plugins.
Adds calibration manager and plugins to determine the optimal (scalar vs vector) implementation type to use for various classes of dsp components.
Adds vector squelching FM demodulator and cleans up the IIR filter and power squelch to use all floats.
Adds vector implementation of FM demodulator.  This introduces a new interface that accepts i/q samples as two separate float arrays, versus an interleaved array, which enables more efficient processing.  This new complex sample interface will be used across the codebase eventually.
Adds ComplexOscillator and a SIMD version VectorComplexOscillator.  Deprecates the LowPhaseNoiseOscillator because the ComplexOscillator is about 35% faster.  The vectorized version is about 43% faster when SIMD lane width is 8x.
Adds new vector complex filters and new real oscillators.  Note: the RealOscillator using straight Java math sin() function is 3x slower than the existing legacy implementation.  Will replace this with a complex oscillator that only uses the real part.
Updates ComplexFIRFilter to be 50% more efficient.
Adds 23 tap filter implementations.  Will not add 63-tap implementations because they are slower than the default vector implementation.
Adds 15-tap customized vector half band filters.
Adds initial custom complex vector half-band decimation filters for 11-tap and 15-tap decimation filters..
Adds vector complex half band filter implementations.  Note: performance of the generic 64-bit 2-lane filter is horrible and is not included.
Optimizes complex half-band filter to be 27% more efficient.
Implements vectorized real half-band filter implementations.
Implements a new FIR filter class that processes sample buffers instead of single sample at a time.
Refactored all of the calibratons to be time-duration based.  Testing on windows i7 gen 3 CPU showed that it took 1000x longer for one of the calibrations to run, versus my AMD 5800x.
Changed gradle jvm args so that the windows plaf export is always applied.
Updates gradle build script to ensure incubator module is included and to cleanup javafx library management for building runtime images.
Testing tweaks and changes.
Adds logging limiter to dispatcher for buffer overflows
Adds User Preferences editor for performing Vector/SIMD calibrations and new startup dialog prompting the user to perform calibrations.
Updates calibration manager and all calibration implementations to add warm-up and test phases and to reduce the overall time it takes to calibrate a system.

Co-authored-by: Dennis Sheirer <dsheirer@github.com>
  • Loading branch information
DSheirer and Dennis Sheirer committed Mar 4, 2022
1 parent 5e9c239 commit 0eec2e7
Show file tree
Hide file tree
Showing 403 changed files with 22,890 additions and 15,062 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/denny.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

138 changes: 16 additions & 122 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2021 Dennis Sheirer
* Copyright (C) 2014-2022 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
Expand All @@ -20,7 +20,6 @@ plugins {
id 'application'
id 'java'
id 'idea'
id 'org.openjfx.javafxplugin' version '0.0.10'
id 'org.beryx.runtime' version '1.12.7'
}

Expand All @@ -32,12 +31,6 @@ repositories {
version = '0.5.0-alpha7'
sourceCompatibility = '17'

javafx {
version = "17.0.1"
modules = ['javafx.base', 'javafx.controls', 'javafx.graphics', 'javafx.swing']
configuration = "implementation"
}

sourceSets {
main.java.srcDirs 'src/main'
test.java.srcDirs 'src/test'
Expand All @@ -47,12 +40,6 @@ test {
useJUnitPlatform()
}

configurations {
javafx_libs_linux
javafx_libs_osx
javafx_libs_win
}

dependencies {

// JUnit Tests
Expand Down Expand Up @@ -100,53 +87,21 @@ dependencies {
implementation 'org.usb4java:usb4java:1.3.0'
implementation 'org.usb4java:usb4java-javax:1.3.0'
implementation 'pl.edu.icm:JLargeArrays:1.6'

//JavaFX libraries for Linux
javafx_libs_linux "org.openjfx:javafx-base:$javafx.version:linux"
javafx_libs_linux "org.openjfx:javafx-controls:$javafx.version:linux"
javafx_libs_linux "org.openjfx:javafx-graphics:$javafx.version:linux"
javafx_libs_linux "org.openjfx:javafx-swing:$javafx.version:linux"

//JavaFX libraries for OSX
javafx_libs_osx "org.openjfx:javafx-base:$javafx.version:mac"
javafx_libs_osx "org.openjfx:javafx-controls:$javafx.version:mac"
javafx_libs_osx "org.openjfx:javafx-graphics:$javafx.version:mac"
javafx_libs_osx "org.openjfx:javafx-swing:$javafx.version:mac"

//JavaFX libraries for Windows
javafx_libs_win "org.openjfx:javafx-base:$javafx.version:win"
javafx_libs_win "org.openjfx:javafx-controls:$javafx.version:win"
javafx_libs_win "org.openjfx:javafx-graphics:$javafx.version:win"
javafx_libs_win "org.openjfx:javafx-swing:$javafx.version:win"
}

application {
mainClass.set("io.github.dsheirer.gui.SDRTrunk")

//Note: jide-oss.jar requires access to hidden windows look & feel
//Note: controlsfx.jar requires access to hidden javaFX classes
applicationDefaultJvmArgs = ['--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED',
'--add-exports=javafx.base/com.sun.javafx.event=org.controlsfx.controls']
}

/**
* Runtime JVM arguments. JDK 17 has hidden a number of classes that are no longer exported from the
* modules. Some legacy support libraries still require access to these classes, so we explicitly
* add them to be exported from those modules here.
* This is needed for the JDK17 vector API ... until it moves out of incubation
*/
import org.gradle.internal.os.OperatingSystem;
tasks.withType(JavaCompile) {
options.compilerArgs.add("--add-modules=jdk.incubator.vector")
}

run {
if(OperatingSystem.current().isWindows()) {
//Note: jide-oss.jar requires access to hidden windows look & feel
//Note: controlsfx.jar requires access to hidden javaFX classes
jvmArgs = ['--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED',
'--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED']
}
else {
//Note: controlsfx.jar requires access to hidden javaFX classes
jvmArgs = ['--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED']
}
application {
mainClassName = "io.github.dsheirer.gui.SDRTrunk"
applicationDefaultJvmArgs =
['--add-exports=javafx.base/com.sun.javafx.event=ALL-UNNAMED', //Needed for controls-fx.jar
'--add-modules=jdk.incubator.vector', //Needed while Panama Vector API remains in incubator
'--add-exports=java.desktop/com.sun.java.swing.plaf.windows=ALL-UNNAMED'] //Windows Swing - jide-oss library
}

jar {
Expand Down Expand Up @@ -177,13 +132,13 @@ idea {
*/
def jdk_base = '/home/denny/java_jdks/'

def jdk_linux_arm64 = jdk_base + 'linux-arm64/jdk-17.0.1-full'
def jdk_linux_x86_64 = jdk_base + 'linux-x64/jdk-17.0.1-full'
def jdk_osx_x86_64 = jdk_base + 'osx-x64/jdk-17.0.1-full.jdk'
def jdk_windows_x86_64 = jdk_base + 'windows-x64/jdk-17.0.1-full'
def jdk_linux_arm64 = jdk_base + 'linux-arm64/jdk-17.0.2-full'
def jdk_linux_x86_64 = jdk_base + 'linux-x64/jdk-17.0.2-full'
def jdk_osx_x86_64 = jdk_base + 'osx-x64/jdk-17.0.2-full.jdk'
def jdk_windows_x86_64 = jdk_base + 'windows-x64/jdk-17.0.2-full'

def hasTargetJdk = file(jdk_linux_x86_64).exists() ||
file(jdk_linux_arm64) ||
file(jdk_linux_arm64).exists() ||
file(jdk_osx_x86_64).exists() ||
file(jdk_windows_x86_64).exists()

Expand Down Expand Up @@ -230,66 +185,5 @@ runtime {
}

options = ['--strip-debug', '--compress', '2', '--no-header-files', '--no-man-pages']
modules = ['java.desktop', 'java.naming', 'jdk.unsupported', 'jdk.unsupported.desktop', 'java.net.http',
'java.sql', 'jdk.crypto.ec']
imageZip = hasTargetJdk ? file("$buildDir/image/sdr-trunk.zip") : file("$buildDir/image/sdr-trunk-" + version + ".zip")
}

def image_lib_linux_arm64 = file("$buildDir/image/sdr-trunk-linux-arm64-v" + version + "/lib")
def image_lib_linux_x86_64 = file("$buildDir/image/sdr-trunk-linux-x86_64-v" + version + "/lib")
def image_lib_osx_x86_64 = file("$buildDir/image/sdr-trunk-osx-x86_64-v" + version + "/lib")
def image_lib_win_x86_64 = file("$buildDir/image/sdr-trunk-windows-x86_64-v" + version + "/lib")

/**
* Copy JavaFX OS-specific libraries for each JDK to each platform target directory
*/
tasks.runtime.doLast
{
if(file(jdk_linux_arm64).exists())
{
//Delete any host system OS-specific JavaFX JDK modules that were inserted as part of default build
delete(fileTree(image_lib_linux_arm64).include { it.name ==~ /javafx.*-(win|mac|linux)\.jar/ })

//Copy OS-specific JavaFX libraries
copy {
from configurations.javafx_libs_linux
into image_lib_linux_arm64
}
}

if(file(jdk_linux_x86_64).exists())
{
//Delete any host system OS-specific JavaFX JDK modules that were inserted as part of default build
delete(fileTree(image_lib_linux_x86_64).include { it.name ==~ /javafx.*-(win|mac|linux)\.jar/ })

//Copy OS-specific JavaFX libraries
copy {
from configurations.javafx_libs_linux
into image_lib_linux_x86_64
}
}

if(file(jdk_osx_x86_64).exists())
{
//Delete any host system OS-specific JavaFX JDK modules that were inserted as part of default build
delete(fileTree(image_lib_osx_x86_64).include { it.name ==~ /javafx.*-(win|mac|linux)\.jar/ })

//Copy OS-specific JavaFX libraries
copy {
from configurations.javafx_libs_osx
into image_lib_osx_x86_64
}
}

if(file(jdk_windows_x86_64).exists())
{
//Delete any host system OS-specific JavaFX JDK modules that were inserted as part of default build
delete(fileTree(image_lib_win_x86_64).include { it.name ==~ /javafx.*-(win|mac|linux)\.jar/ })

//Copy OS-specific JavaFX libraries
copy {
from configurations.javafx_libs_win
into image_lib_win_x86_64
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* ******************************************************************************
* sdrtrunk
* Copyright (C) 2014-2018 Dennis Sheirer
* *****************************************************************************
* Copyright (C) 2014-2022 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
Expand All @@ -15,7 +14,7 @@
*
* 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.alias.action;
Expand All @@ -26,8 +25,8 @@
import io.github.dsheirer.message.IMessage;
import io.github.dsheirer.util.ThreadPool;

import javax.swing.JOptionPane;
import java.awt.EventQueue;
import javax.swing.*;
import java.awt.*;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -92,7 +91,7 @@ public void execute(Alias alias, IMessage message)
*/
private void performThreadedAction(final Alias alias, final IMessage message)
{
ThreadPool.SCHEDULED.schedule(() -> performAction(alias, message), 0, TimeUnit.SECONDS);
ThreadPool.CACHED.execute(() -> performAction(alias, message));
}

@Override
Expand Down
54 changes: 23 additions & 31 deletions src/main/java/io/github/dsheirer/audio/AudioModule.java
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2022 Dennis Sheirer
*
* * ******************************************************************************
* * Copyright (C) 2014-2019 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/>
* * *****************************************************************************
* 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.audio;

import io.github.dsheirer.alias.AliasList;
import io.github.dsheirer.audio.squelch.ISquelchStateListener;
import io.github.dsheirer.audio.squelch.SquelchState;
import io.github.dsheirer.audio.squelch.SquelchStateEvent;
import io.github.dsheirer.dsp.filter.FilterFactory;
import io.github.dsheirer.dsp.filter.design.FilterDesignException;
import io.github.dsheirer.dsp.filter.fir.FIRFilterSpecification;
import io.github.dsheirer.dsp.filter.fir.real.RealFIRFilter2;
import io.github.dsheirer.dsp.filter.fir.real.IRealFilter;
import io.github.dsheirer.dsp.filter.fir.remez.RemezFIRFilterDesigner;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.sample.buffer.IReusableBufferListener;
import io.github.dsheirer.sample.buffer.ReusableFloatBuffer;
import io.github.dsheirer.sample.real.IRealBufferListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -41,8 +38,8 @@
*
* Incorporates audio squelch state listener to control if audio packets are broadcast or ignored.
*/
public class AudioModule extends AbstractAudioModule implements ISquelchStateListener, IReusableBufferListener,
Listener<ReusableFloatBuffer>
public class AudioModule extends AbstractAudioModule implements ISquelchStateListener, IRealBufferListener,
Listener<float[]>
{
private static final Logger mLog = LoggerFactory.getLogger(AudioModule.class);
private static float[] sHighPassFilterCoefficients;
Expand Down Expand Up @@ -73,7 +70,7 @@ public class AudioModule extends AbstractAudioModule implements ISquelchStateLis
}
}

private RealFIRFilter2 mHighPassFilter = new RealFIRFilter2(sHighPassFilterCoefficients);
private IRealFilter mHighPassFilter = FilterFactory.getRealFilter(sHighPassFilterCoefficients);
private SquelchStateListener mSquelchStateListener = new SquelchStateListener();
private SquelchState mSquelchState = SquelchState.SQUELCH;

Expand Down Expand Up @@ -120,22 +117,17 @@ public Listener<SquelchStateEvent> getSquelchStateListener()
}

@Override
public void receive(ReusableFloatBuffer audioBuffer)
public void receive(float[] audioBuffer)
{
if(mSquelchState == SquelchState.UNSQUELCH)
{
ReusableFloatBuffer highPassFilteredAudio = mHighPassFilter.filter(audioBuffer);
addAudio(highPassFilteredAudio.getSamplesCopy());
highPassFilteredAudio.decrementUserCount();
}
else
{
audioBuffer.decrementUserCount();
audioBuffer = mHighPassFilter.filter(audioBuffer);
addAudio(audioBuffer);
}
}

@Override
public Listener<ReusableFloatBuffer> getReusableBufferListener()
public Listener<float[]> getBufferListener()
{
//Redirect received reusable buffers to the receive(buffer) method
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* *****************************************************************************
* Copyright (C) 2014-2020 Dennis Sheirer
* Copyright (C) 2014-2022 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
Expand All @@ -20,7 +20,6 @@

import io.github.dsheirer.sample.Broadcaster;
import io.github.dsheirer.sample.Listener;
import io.github.dsheirer.sample.buffer.AbstractReusableBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down

0 comments on commit 0eec2e7

Please sign in to comment.