Add SIMD optimization and speed up nonsep Wiener - #5362
Conversation
68387fb to
847d9d0
Compare
|
@kslu-aom : pls rebase. |
d8621c4 to
c4db6c4
Compare
|
@jjustiss-apple, since you’re the expert in SIMD, could you please help review the code? |
|
There looks to be a good amount of room to improve the SIMD code here, e.g. switching to integer accumulators, use of FMA3 madd instructions in the matrix and vector inner loops, plus a few other optimization opportunities. libaom av1 is a good reference. Are we looking for optimal SIMD code in this PR or just focus on the algorithm changes? |
I'd suggest merging this PR first and making further improvements to SIMD in later PRs, given the significant speed-up from this PR. Of course, if there are any concrete suggestions to improve SIMD right here, those could be addressed in this PR as well. What do you think @yeqing-wu @yunqingwang1 @leolzhao ? |
@jjustiss-apple, what are your thoughts on this? If we decide to merge this PR, it would be beneficial to create a ticket to track it. This way, we won’t forget to optimize it later. SIMD part in this PR is lossless optimization, so we should maximize the available space. |
I am fine with merging this PR and further improving SIMD in a separate PR. Thanks. |
|
Thanks for the suggestions. I can give it a try to improve the SIMD here later if no one else has plans on doing it. |
…lation Implement algorithmic search pruning methods and SIMD optimizations for nonseparable wiener restoration: - Add SIMD (AVX2, SSE4.1) RTCD dispatch for wienerns correlation matrix accumulation (av2_accumulate_wienerns_correlation) - Add speed >= 1 algorithmic prunings guarded by configurable macros: - prune RU search sizes based on pyramid level - single iteration for frame filter optimization
c4db6c4 to
cfbb2fe
Compare
This patch accelerates the nonseparable Wiener restoration search through search pruning at speed >= 1 and SIMD optimizations for the autocovariance matrix accumulation:
Search Pruning for speed >= 1: Extend speed features reduce_lr_unit_size_by_pyr and reduce_lr_unit_size_by_pyr_drop_low from speed >=4 to speed >= 1 to prune RU unit-size evaluations based on pyramid level (drops the largest RU size for pyr_level >= 3, and the smallest RU size for pyr_level >= 5). Add a speed feature wienerns_fast_frame_filter_opt for speed >= 1 to prune frame-level filter search iterations during optimal class and filter determination.
SIMD Vectorization: Add SSE4.1 and AVX2 implementations to accelerate autocovariance matrix and cross-correlation vector accumulation in WienerNS filter stats collection. Unit tests have been added to verify numerical equivalence between SIMD (SSE4.1, AVX2) and reference C implementations. This change is applied to all speed levels, and is bit-exact. Encoder instruction count savings on A3-A5 with 17 frames:
0.11% at speed 0
0.26% at speed 1
0.95% at speed 2
STATS_CHANGED for speed >= 1
Results with the above changes combined, evaluated on 2128e7e with 33 frames: