From 42d11342a12eb2437e901e2581006f6d67d9645a Mon Sep 17 00:00:00 2001 From: Owen Green Date: Fri, 11 Oct 2024 19:09:00 +0100 Subject: [PATCH 1/3] fix max fft size fiasco fix max fft size fiasco2 --- include/algorithms/util/FFT.hpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/include/algorithms/util/FFT.hpp b/include/algorithms/util/FFT.hpp index dd80f700d..3bbf4c678 100644 --- a/include/algorithms/util/FFT.hpp +++ b/include/algorithms/util/FFT.hpp @@ -14,6 +14,7 @@ under the European Union’s Horizon 2020 research and innovation programme #include "../../data/FluidMemory.hpp" #include #include +#include namespace fluid { namespace algorithm { @@ -62,13 +63,15 @@ class FFT public: using MapXcd = Eigen::Map; - static void setup() { getFFTSetup(); } + //TODO: why is this here? + static void setup() { getFFTSetup(); } FFT() = delete; FFT(index size, Allocator& alloc = FluidDefaultAllocator()) noexcept : mMaxSize(size), mSize(size), mFrameSize(size / 2 + 1), - mLog2Size(static_cast(std::log2(size))), mSetup(getFFTSetup()), + mLog2Size(static_cast(std::log2(size))), + mSetup(getFFTSetup(*this, size)), mRealBuffer(asUnsigned(mFrameSize), alloc), mImagBuffer(asUnsigned(mFrameSize), alloc), mOutputBuffer(asUnsigned(mFrameSize), alloc) @@ -106,11 +109,18 @@ class FFT return {mOutputBuffer.data(), mFrameSize}; } +private: + std::optional mLocalSetup; protected: - static htl::setup_type getFFTSetup() - { - static const impl::FFTSetup static_setup(65536); - return static_setup(); + static constexpr index default_max = 65536; + static htl::setup_type getFFTSetup(FFT& _this, index size) + { + static const impl::FFTSetup static_setup(default_max); + if(size <= default_max) return static_setup(); + else { + _this.mLocalSetup = std::optional(size); + return _this.mLocalSetup->operator()(); + } } index mMaxSize{16384}; @@ -127,6 +137,7 @@ class FFT rt::vector> mOutputBuffer; }; + class IFFT : public FFT { From 6b9dbe723a10b0f3abc0cadfae89350a3e259476 Mon Sep 17 00:00:00 2001 From: Owen Green Date: Fri, 11 Oct 2024 19:52:41 +0100 Subject: [PATCH 2/3] Remove redundant(?) function --- include/algorithms/util/FFT.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/algorithms/util/FFT.hpp b/include/algorithms/util/FFT.hpp index 3bbf4c678..1a0fab47a 100644 --- a/include/algorithms/util/FFT.hpp +++ b/include/algorithms/util/FFT.hpp @@ -63,8 +63,6 @@ class FFT public: using MapXcd = Eigen::Map; - //TODO: why is this here? - static void setup() { getFFTSetup(); } FFT() = delete; From e1177d57329125adbb12921804544ebdbb8d0ea8 Mon Sep 17 00:00:00 2001 From: Owen Green Date: Sat, 12 Oct 2024 00:57:53 +0100 Subject: [PATCH 3/3] FFT: Consistent noexcept in move Maybe this is why gcc is sad --- include/algorithms/util/FFT.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/algorithms/util/FFT.hpp b/include/algorithms/util/FFT.hpp index 1a0fab47a..e6865865d 100644 --- a/include/algorithms/util/FFT.hpp +++ b/include/algorithms/util/FFT.hpp @@ -39,8 +39,8 @@ class FFTSetup FFTSetup(FFTSetup const&) = delete; FFTSetup& operator=(FFTSetup const&) = delete; - FFTSetup(FFTSetup&& other) { *this = std::move(other); }; - FFTSetup& operator=(FFTSetup&& other) + FFTSetup(FFTSetup&& other) noexcept { *this = std::move(other); }; + FFTSetup& operator=(FFTSetup&& other) noexcept { using std::swap; swap(mMaxSize, other.mMaxSize);