# Batched CUDA FFT Plans

**URL:** <https://discourse.julialang.org/t/batched-cuda-fft-plans/105187>\
**Category:** GPU\
**Tags:** cuda, cudajl, fft\
**Created:** [October 19, 2023, 1:57pm UTC](https://discourse.julialang.org/t/batched-cuda-fft-plans/105187 "2023-10-19T13:57:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaximilianGelbrecht](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MaximilianGelbrecht](https://discourse.julialang.org/u/MaximilianGelbrecht)\
**Post date:** [October 19, 2023, 1:57pm UTC](https://discourse.julialang.org/t/batched-cuda-fft-plans/105187/1 "2023-10-19T13:57:30Z")

</div>

CUDA.jl [PR1903](https://github.com/JuliaGPU/CUDA.jl/pull/1903) added support for FFTs along more directions with CUDA.jl v5. I am a bit confused how this works in practice, as I can’t find it documented. The PR states

> This is achieved by allowing fft-plans to have fewer dimensions than the data they are applied to. The trailing dimensions are treated as non-transform directions and transforms are executed sequentially.

So, in practice I’d like to have one plan that applies both to single samples and batched ones, but this doesn’t work as I expected:

```julia
using CUDA 
A = CUDA.rand(100); B = CUDA.rand(100,10); 
plan = CUDA.CUFFT.plan_fft(A) 
plan * A # works 
plan * B # doesn't work

```

Am I misunderstanding what the PR added, or using it wrong? (I am on CUDA.jl v5)

Maybe @RainerHeintzmann could help out?

---

<div class="post-metadata">

**Author:** ![RainerHeintzmann](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rainerheintzmann/32/19726_2.png) [@RainerHeintzmann](https://discourse.julialang.org/u/RainerHeintzmann)\
**Post date:** [October 20, 2023, 6:02am UTC](https://discourse.julialang.org/t/batched-cuda-fft-plans/105187/2 "2023-10-20T06:02:20Z")

</div>

Thanks for this question. Yes, this was initially allowed. However, there was some critics and I wanted the pull request to go through, so I made sure that the user interface stayed the same as before. See this comment:

> <https://github.com/JuliaGPU/CUDA.jl/pull/1903#issuecomment-1560054420>
>
> The code is changed now such that plans have to always agree in dimensions and s…izes to the data they are applied to. This should be in agreement with the Abstract FFT interface. The support for transform directions has not been changed and almost all directions should be working now. @stevengj Is this OK now?

The new version therefore now only supports more (almost all) FFT transform directions, but you still have to use the appropriate plan. For your use case you can tell the plan to only transform the first dimension. I would also have preferred the changed interface, as originally planned, but this is democracy 😉

---

<div class="post-metadata">

**Author:** ![MaximilianGelbrecht](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MaximilianGelbrecht](https://discourse.julialang.org/u/MaximilianGelbrecht)\
**Post date:** [October 20, 2023, 6:50am UTC](https://discourse.julialang.org/t/batched-cuda-fft-plans/105187/3 "2023-10-20T06:50:21Z")

</div>

> [@RainerHeintzmann](#):
>
> [https://github.com/JuliaGPU/CUDA.jl/pull/1903#issuecomment-1560054420](https://github.com/JuliaGPU/CUDA.jl/pull/1903#issuecomment-1560054420)

Thanks for the reply!

Ah, I see. I’ll suggest that change at AbstractFFTs.
