Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for running FFT on GPU using the VkFFT library, with either Vulkan or CUDA backend, as per #1166
To allow easier performance comparisons, I have updated the FFTEngine and FFTFactory class to support multiple simultaneous FFTEngines, so a user can switch between FFTW, Kiss and VkFFT at run-time via a GUI option (Preferences > FFT). Also, different bits of SDRangel can request different FFTEngines. So FFTW could be used generally, but a specific plugin could request VkFFT if it thinks it will benefit from it.
I have also added a simple profiler, that displays average execution time in a dialog (View > Profile Data...). Profiling is enabled via the cmake -DENABLE_PROFILER=ON option. It is disabled by default, and when disabled, there should be no performance impact as the profiling code is not included in the executable. It can also be used to easily profile other parts of SDRangel - here showing GL spectrum draw time, as well as FFT. To profille some code, you just need to stick the PROFILE_START() and PROFILE_STOP("name") macros around the code.
Whether VkFFT uses Vulkan or CUDA is a cmake option, -DVKFFT_BACKEND=0 for Vulkan and -DVKFFT_BACKEND=1 for CUDA. The code should compile without VkFFT if neither the Vulkan or CUDA SDKs are available.
On Windows, VkFFT is automatically downloaded as an external project. If external project is off, then it can be downloaded with:
It's a header only library, so doesn't need to be built.
Either the Vulkan or CUDA SDKs need to be installed to compile it:
Linux Vulkan Setup
Linux CUDA setup
Windows Vulkan Setup
Windows CUDA Setup
Unfortunately, on my PCs, using the GPU (via either Vulkan or CUDA) is much slower than using FFTW, due to the overhead of getting the data from the CPU to the GPU. It may be more beneficial on embedded SoCs that have unified memory and relatively slower CPUs, but haven't tried. To get better performance, we'd probably need to submit FFTs in batches, rather than one at a time (or do additional processing on the GPU). So there's no reason to try to enable this in the release builds now, but it's the first step towards GPU support.