Skip to content

Optimized _filt_fir! for DF2TFilter #569

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

Merged
merged 10 commits into from
Dec 2, 2024
Merged

Conversation

wheeheee
Copy link
Member

Also adjusts cutoff, uses LazyString for errors.

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.90%. Comparing base (b3f9da6) to head (32fdfc3).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #569      +/-   ##
==========================================
- Coverage   97.90%   97.90%   -0.01%     
==========================================
  Files          19       19              
  Lines        3252     3249       -3     
==========================================
- Hits         3184     3181       -3     
  Misses         68       68              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wheeheee wheeheee force-pushed the more_ff branch 2 times, most recently from 7fa57a5 to e517c0b Compare October 11, 2024 08:51
@wheeheee wheeheee force-pushed the more_ff branch 4 times, most recently from 88543bb to 7b4b688 Compare November 5, 2024 10:06
@wheeheee wheeheee force-pushed the more_ff branch 3 times, most recently from 19913d2 to 3e4c728 Compare November 11, 2024 10:00
@wheeheee wheeheee force-pushed the more_ff branch 2 times, most recently from c606ad6 to 299a721 Compare November 18, 2024 12:36
Copy link
Member

@martinholters martinholters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the SMALL_FILT_VECT_CUTOFF dance, but apart from that LGTM.

Co-authored-by: Martin Holters <[email protected]>
@wheeheee
Copy link
Member Author

wheeheee commented Dec 2, 2024

I don't understand the SMALL_FILT_VECT_CUTOFF dance, but apart from that LGTM.

I increased it to 19 because (for me, on 1.11.1) it's a small improvement.

julia> x = rand(10_000); out = similar(x);

julia> @btime filt!($out, b, a, $x, si) setup=((a, b, si) = (1., rand(19), zeros(18)));
  20.700 μs (0 allocations: 0 bytes) # SMALL_FILT_VECT_CUTOFF = 18
  18.600 μs (0 allocations: 0 bytes) # SMALL_FILT_VECT_CUTOFF = 19

Or if your question is what it's for, removing inbounds below the cutoff prevents it from vectorizing in some non-optimal way (as it was in 0.7.9).

julia> @btime filt!($out, b, a, $x, si) setup=((a, b, si) = (1., rand(15), zeros(14)));
  12.900 μs (0 allocations: 0 bytes) # SMALL_FILT_VECT_CUTOFF = 19
  17.200 μs (0 allocations: 0 bytes) # SMALL_FILT_VECT_CUTOFF = 12

And if it returns an NTuple, sometimes (I think for x = rand(10_000, 1)) this happens nevertheless, so I specialized it for DF2TFilter

@martinholters
Copy link
Member

Ah, so the @inbounds is semantically correct for any N, but whether it helps or hinders performance depends on N? That's... ugh...

Anyway, from my point of view, this is good to go.

@wheeheee
Copy link
Member Author

wheeheee commented Dec 2, 2024

Ah, so the @inbounds is semantically correct for any N, but whether it helps or hinders performance depends on N?

Yup. And sometimes also on whether a view is passed to _filt_fir!, instead of a Vector...

@wheeheee wheeheee merged commit 1be88b5 into JuliaDSP:master Dec 2, 2024
10 checks passed
@wheeheee wheeheee deleted the more_ff branch December 2, 2024 11:51
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