Skip to content

feat: add batched real-FFT plans in float and double precision - #4

Draft
galenlynch wants to merge 4 commits into
package-fftw-dependenciesfrom
float-batched-r2c
Draft

galenlynch wants to merge 4 commits into
package-fftw-dependenciesfrom
float-batched-r2c

Conversation

@galenlynch

Copy link
Copy Markdown
Collaborator

This PR adds four reusable, RAII-managed transform types:

  • BatchedRealToComplexPlanF
  • BatchedComplexToRealPlanF
  • BatchedRealToComplexPlanD
  • BatchedComplexToRealPlanD

They support workloads such as spectrum estimation, where each channel and taper produces an independent transform of the same length. One persistent fftw_plan_many_dft_* plan handles the complete batch and avoids per-frame planning or allocation.

API contract

Each object owns aligned input and output storage plus its FFTW plan. Construction validates the transform length and batch count; row accessors expose contiguous transform-major storage. execute() performs no allocation.

Inverse transforms preserve FFTW's normal unnormalized convention. Callers must divide by the transform length when they require a normalized inverse.

FFTW plan creation and destruction are protected by the wrapper's existing planning mutex. Separate plan objects may execute concurrently, but concurrent access to the same object is unsupported because its buffers are mutable and owned by the plan.

Compatibility

The change is additive. Existing classes and function signatures remain unchanged. The new classes are concrete, non-polymorphic types, so this PR does not alter any existing object layout or vtable.

The public header remains independent of JUCE. The library links both the double-precision and single-precision FFTW libraries supplied by the dependency bundles.

Scope

FFTW-managed worker threads are intentionally excluded. The consuming plugin can first assign independent plans to its own workers, preserving one clear scheduling policy. Threaded FFTW can be evaluated separately if end-to-end profiling shows a need.

Verification

Tests should cover float and double forward transforms, inverse reconstruction, batch isolation, invalid dimensions, move semantics, and repeated allocation-free execution. CI must run these tests on Linux, Windows, and macOS after the two dependency-packaging PRs have landed.

@galenlynch
galenlynch force-pushed the float-batched-r2c branch 2 times, most recently from 287f9c5 to 8f15852 Compare September 8, 2026 23:47
@galenlynch
galenlynch changed the base branch from consume-fftw-dependency-bundles to package-fftw-dependencies September 8, 2026 23:50
The packaging change does not require every OpenEphysFFTW build to use a
newer CMake release. Keep the top-level project at its existing 3.5
minimum and apply newer requirements only to the isolated tools that need
them.

Automatic staging now requires CMake 3.19 for archive extraction and fatal
subprocess errors. The dependency smoke project requires CMake 3.22 for
its test-environment modification.
Callers currently manage one FFT at a time, which prevents
channel-by-taper workloads from sharing plans and aligned storage.

Add move-only float and double real-to-complex plans with transform-major
buffers. Reuse FFTW plan-many objects so execution requires no allocation.
Forward-only batches cannot reconstruct real signals with the same reusable
storage and planning model.

Add move-only float and double complex-to-real plans with transform-major
buffers. Preserve FFTW's unnormalized inverse convention so callers control
normalization.
@galenlynch

Copy link
Copy Markdown
Collaborator Author

Depends on #2

@anjaldoshi
anjaldoshi added this pull request to stack #5 September 11, 2026 20:28
Remove the redundant OEP_FFTW_API macro and use COMMON_LIB, which already provides the required export/import behavior.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants