-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: enable reusing fft plans #271
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Ok, I think this seems reasonable now. @timholy would you mind reviewing for general design and I can add tests & docs if you agree |
I confess I haven't thought about these plans in ages (the code I linked earlier was probably written in the Julia 0.1 days), but nothing bad jumps out about this. Thanks for doing it!! |
9183fb7
to
17e9b0a
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Comparing buffered vs standard I get different values here ImageFiltering.jl/src/imfilter.jl Lines 875 to 877 in 78044e7
My trial and error phase of debugging isn't being very fruitful, so I think I'll wait for review. @timholy if you happen to have time |
Commeting to remind myself to take a look |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing jumps out as a serious problem just from a read through the code, but it's probably been a decade since I put the serious work into writing RFFT.jl (it used to be part of a more monolithic repository so the git history may not reflect that). Do the disagreements only arise when you use multiple threads?
This comment was marked as outdated.
This comment was marked as outdated.
a79e807
to
faa2fb6
Compare
5087d8f
to
25dbbbe
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #271 +/- ##
==========================================
- Coverage 94.25% 89.78% -4.48%
==========================================
Files 13 13
Lines 1706 1742 +36
==========================================
- Hits 1608 1564 -44
- Misses 98 178 +80 ☔ View full report in Codecov by Sentry. |
Ok. Tests are passing here. Note that However,
|
e32b32f
to
a948fae
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! Not only is the new functionality appreciated, but the various cleanups are too.
I haven't played with this myself, but does demo
pass now? If so, it seems like you're almost over the hump. I don't see anything objectionable here (assuming you'll get to a point of full test coverage for the new functionality), so feel free to run with this.
return function (arr::AbstractArray{T}) where {T} | ||
copy!(buf, OffsetArrays.no_offset_view(arr)) | ||
return plan(buf) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No test coverage here and below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I hadn't noticed this. Sadly it turns out the new functionality isn't passing yet..
function filtfft(A::AbstractArray{C}, krn, planned_rfft1::Function, planned_rfft2::Function, planned_irfft::Function) where {C<:Colorant} | ||
Av, dims = channelview_dims(A) | ||
kernrs = kreshape(C, krn) | ||
B = complex(planned_rfft1(Av, dims)) # TODO: dims is not supported by planned_rfft1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think dims
can be a point of flexibility: these plans are specific to the memory layout of the array. (The planning explores various implementations and picks the fastest discovered; performance is strongly dependent on memory layout, so the choice for one layout may not be the same as another.) You'd have to create a plan specifically to the colorant array-type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this comment to the TODO. I think I'd prefer to fix this in a follow on PR, if that sounds ok
Requires
region
->dims
. Remove deprecation. HolyLab/RFFT.jl#17TODO:
region
->dims
. Remove deprecation. HolyLab/RFFT.jl#17Algorithm.FFT(img, kernel, border)
?Because they are not threadsafe FFTW FFT plans are behind a lock. They should be reusable for same-sized images and kernels, so this is WIP towards exposing a way to provide plans, so that
imfilter!
can be run concurrently on julia threads without lock conflict.Note that this is using JuliaLang/julia#52883 to count conflicts.
There's a demo temporarily in this PR.
Before it hits 34255 lock conflicts
This PR removes all but the lock conflicts from the singlular plans, which could be moved out of the for loop