Skip to content

Optimize FFT logic for complex strided input to avoid oversized memory allocation#2939

Open
vlad-perevezentsev wants to merge 3 commits into
masterfrom
fix_fft_logic
Open

Optimize FFT logic for complex strided input to avoid oversized memory allocation#2939
vlad-perevezentsev wants to merge 3 commits into
masterfrom
fix_fft_logic

Conversation

@vlad-perevezentsev
Copy link
Copy Markdown
Contributor

This PR fixes an issue discovered while implementing #2927 where several FFT tests started failing after adding validation for stride configurations with oversized memory footprints.

The problem was that FFT could allocate output arrays using the same strided layout as a non-contiguous input. For inputs such as a[::2, this resulted in oversized allocations followed by an additional copy to a contiguous array.

This fix checks whether the memory footprint implied by the input strides exceeds the number of elements in the array. If so, the input is copied to a contiguous layout before configuring the FFT descriptor allowing oneMKL FFT to produce a contiguous output directly

By avoiding oversized allocations and the extra copy this significantly improves the performance of all FFT operations in dpnp with complex strided inputs

fft_perf
  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

@vlad-perevezentsev vlad-perevezentsev added this to the 0.21.0 release milestone Jun 1, 2026
@vlad-perevezentsev vlad-perevezentsev self-assigned this Jun 1, 2026
@vlad-perevezentsev vlad-perevezentsev changed the title Optimize FFT logic for strided input to avoid oversized memory allocation Optimize FFT logic for complex strided input to avoid oversized memory allocation Jun 1, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

View rendered docs @ https://intelpython.github.io/dpnp/pull/2939/index.html

@coveralls
Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.255% (+0.004%) from 78.251% — fix_fft_logic into master

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