InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

ENH: Exercise every enabled FFT precision in the 1D FFT tests (not an either/or single pick)

Open
#6,735 0 comments 0 reactions 0 assignees View on GitHub
area:Filtering type:Testing
Dominant language
C++
Stars
1.7k
Forks
748
Avg merge
1d 1h
Merged PRs (30d)
64

Description

The 1D FFT tests pick a single pixel type at compile time (`#if defined(ITK_USE_FFTWD) double #else float`), so the normal dual-precision CI build only ever exercises `double` — the single-precision FFTW paths get no coverage.

Proposal: factor each test body into a precision-templated helper and run it once per enabled precision.

Current pattern and file:line evidence (upstream/main)

```cpp
#if defined(ITK_USE_FFTWD)
using PixelType = double;
#else
using PixelType = float;
#endif
```

| File (`Modules/Filtering/FFT/test/`) | single-pick `#if` / `using PixelType` |
|---|---|
| `itkFFT1DImageFilterTest.cxx` | lines **86-89** |
| `itkComplexToComplex1DFFTImageFilterTest.cxx` | lines **91-94** |
| `itkForward1DFFTImageFilterTest.cxx` | lines **87-90** |
| `itkInverse1DFFTImageFilterTest.cxx` | lines **79-82** |

All four also carry module-level `#if defined(ITK_USE_FFTWD) || defined(ITK_USE_FFTWF)` guards (lines 30, 29, 29, 28 respectively) that already tolerate either precision — only the pixel-type choice is either/or.

Additionally, `itkFFT1DImageFilterTest.cxx` branches its backend-0 (default factory) expectation on `ITK_USE_FFTWF && !ITK_USE_FFTWD` to decide FFTW-vs-Vnl. That logic happens to be correct today only because exactly one precision is exercised; it needs to become per-precision.

Suggested steps

1. Refactor each test body into `template int runForPixelType(...)`.
2. In `main`, invoke it for every configured precision:
```cpp
int status = EXIT_SUCCESS;
#if defined(ITK_USE_FFTWF)
status += runForPixelType(...);
#endif
#if defined(ITK_USE_FFTWD)
status += runForPixelType(...);
#endif
```
so dual-precision builds run both and single-precision builds still run the one.
3. Make the default-backend (backend 0) expectation precision-aware: Vnl when that precision has a Vnl 1D factory and FFTW is not the registered default; FFTW when it is. `itkFFTImageFilterFactory.h`'s `FFTImageFilterEnableFloat` / `FFTImageFilterEnableDouble` traits govern which precisions a backend registers and are the right predicate.
4. Consider the same treatment for the ND FFT tests if they hardcode a precision.
5. Validate: a dual-precision (FFTWD+FFTWF) local build must run both the float and double case of each 1D test; an FFTWF-only build must still pass.

Related

- PR #6330 — single-precision FFTW build fixes; introduced the single-pick `#if`.
- `Modules/Filtering/FFT/include/itkFFTImageFilterFactory.h` — per-precision enable traits.
- Companion: single-precision r2r/DCT path for `itkCurvatureRegistrationFilter` (TODO L135).

---

Contributor guide

Open the contributing guide

Research direction

Start with the four 1D tests in Modules/Filtering/FFT/test/: itkFFT1DImageFilterTest.cxx, itkComplexToComplex1DFFTImageFilterTest.cxx, itkForward1DFFTImageFilterTest.cxx, and itkInverse1DFFTImageFilterTest.cxx, then read itkFFTImageFilterFactory.h for the per-precision enable traits. Refactor each test to run for every enabled precision and make the backend-0 expectation precision-aware. Validate that dual-precision builds execute both float and double cases and that FFTWF-only builds still pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.