JuliaImages / JuliaImages/ImageFiltering.jl

Unstable `imfilter!` execution time with variable FFTW threads

Open
#246 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Julia
Stars
104
Forks
52
PR merge metrics
No merged PRs in 30d

Description

I'm assuming this is due to FFTW's auto planning making different decisions. If so, it would be good to expose the plan settings, if possible.

I'm seeing unexplained significant slowdown in imfilter! on some different data sizes, and I'm wondering whether this is the culpret.

julia> v1 = rand(Float32, 100, 100, 100);

julia> v2 = rand(Float32, 100, 100, 100);

julia> for t in 1:16
              FFTW.set_num_threads(t)
              @info "FFTW: $t"
              @btime imfilter!($v2, $v1, $(centered(Kernel.gaussian((1, 1, 10)))), "symmetric", Algorithm.FFT());
          end
[ Info: FFTW: 1
  31.118 ms (172 allocations: 64.69 MiB)
[ Info: FFTW: 2
  22.252 ms (335 allocations: 64.70 MiB)
[ Info: FFTW: 3
  17.866 ms (380 allocations: 64.70 MiB)
[ Info: FFTW: 4
  16.727 ms (419 allocations: 64.70 MiB)
[ Info: FFTW: 5
  16.070 ms (463 allocations: 64.71 MiB)
[ Info: FFTW: 6
  14.941 ms (505 allocations: 64.71 MiB)
[ Info: FFTW: 7
  212.458 ms (1171542 allocations: 134.28 MiB)
[ Info: FFTW: 8
  215.672 ms (1171782 allocations: 134.29 MiB)
[ Info: FFTW: 9
  214.504 ms (1171885 allocations: 134.29 MiB)
[ Info: FFTW: 10
  213.847 ms (1171566 allocations: 134.29 MiB)
[ Info: FFTW: 11
  213.470 ms (1172045 allocations: 134.30 MiB)
[ Info: FFTW: 12
  213.978 ms (1170869 allocations: 134.27 MiB)
[ Info: FFTW: 13
  17.095 ms (2094 allocations: 64.81 MiB)
[ Info: FFTW: 14
  15.242 ms (848 allocations: 64.74 MiB)
[ Info: FFTW: 15
  15.483 ms (889 allocations: 64.74 MiB)
[ Info: FFTW: 16
  15.473 ms (1182 allocations: 64.76 MiB)

With the mkl backend the bump doesn't occur and performance increases gradually with FFTW.jl threads

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the benchmark around imfilter! with Algorithm.FFT() while varying FFTW.set_num_threads, and compare the behavior with the MKL backend. Trace how FFT planning is selected for these calls; done means explaining the thread-count slowdown and determining whether plan settings can be exposed without regressing the stable cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
performance
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.