Skip to content
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

vvc_deblock.asm: reduce stack usage #275

Open
wants to merge 10 commits into
base: deblock_asm
Choose a base branch
from

Conversation

stone-d-chen
Copy link
Collaborator

Since we're storing the lines of the CTU in registers, we can use the CTU as additional storage (it gets overwritten at the very end with the correct values).

Since we're storing the lines of the CTU in registers, we can use the CTU as additional storage (it gets overwritten at the very end with the correct values).
@stone-d-chen
Copy link
Collaborator Author

@nuomi2021, I think something like this can work to reduce the stack usage.

remove [rsp + 32] stack usage
First we rename vertical chroma's parameter r3strideq to src3strideq, what the horizontal calls it. This was we can use src3strideq in the macros. Eliminate [rsp + 16] usage by storing in the deblock unit instead.
Use pixq + stride and pixq + 2 * stride to store the masks. For some reason movh [pix], is causing a mismatch in CodingToolsSets_B_Tencent_2.bit for 8 bit.
Additionally reuses the new freed up pix0q
Instead of storing the tc values in tcptr, just reload it each time.
Since we've removed stack usage and some GPRs, update the function signature

Auto stash before checking out "HEAD"
e.g. pxor m10, m10, when still cleared
@stone-d-chen
Copy link
Collaborator Author

stone-d-chen commented Jan 3, 2025

@nuomi2021, I've eliminated stack use.

Benchmarks

Anything using the weak path does not get too much performance gain unfortunately, too much overhead.

vvc_h_loop_filter_chroma_8_mix_no-shift_c: 289.3
vvc_h_loop_filter_chroma_8_mix_no-shift_avx: 119.3

vvc_h_loop_filter_chroma_8_mix_shift_c: 859.3
vvc_h_loop_filter_chroma_8_mix_shift_avx: 199.3

vvc_h_loop_filter_chroma_8_one-side_no-shift_c: 669.3
vvc_h_loop_filter_chroma_8_one-side_no-shift_avx: 199.3

vvc_h_loop_filter_chroma_8_one-side_shift_c: 869.3
vvc_h_loop_filter_chroma_8_one-side_shift_avx: 159.3

vvc_h_loop_filter_chroma_8_strong_no-shift_c: 639.3
vvc_h_loop_filter_chroma_8_strong_no-shift_avx: 199.3

vvc_h_loop_filter_chroma_8_strong_shift_c: 1109.3
vvc_h_loop_filter_chroma_8_strong_shift_avx: 169.3

vvc_h_loop_filter_chroma_8_weak_no-shift_c: 309.3
vvc_h_loop_filter_chroma_8_weak_no-shift_avx: 129.3

vvc_h_loop_filter_chroma_8_weak_shift_c: 369.3
vvc_h_loop_filter_chroma_8_weak_shift_avx: 109.3

vvc_h_loop_filter_chroma_10_mix_no-shift_c: 439.3
vvc_h_loop_filter_chroma_10_mix_no-shift_avx: 169.3

vvc_h_loop_filter_chroma_10_mix_shift_c: 489.3
vvc_h_loop_filter_chroma_10_mix_shift_avx: 89.3

vvc_h_loop_filter_chroma_10_one-side_no-shift_c: 679.3
vvc_h_loop_filter_chroma_10_one-side_no-shift_avx: 149.3

vvc_h_loop_filter_chroma_10_one-side_shift_c: 909.3
vvc_h_loop_filter_chroma_10_one-side_shift_avx: 149.3

vvc_h_loop_filter_chroma_10_strong_no-shift_c: 909.3
vvc_h_loop_filter_chroma_10_strong_no-shift_avx: 169.3

vvc_h_loop_filter_chroma_10_strong_shift_c: 1129.3
vvc_h_loop_filter_chroma_10_strong_shift_avx: 159.3

vvc_h_loop_filter_chroma_10_weak_no-shift_c: 209.3
vvc_h_loop_filter_chroma_10_weak_no-shift_avx: 99.3

vvc_h_loop_filter_chroma_10_weak_shift_c: 259.3
vvc_h_loop_filter_chroma_10_weak_shift_avx: 89.3

vvc_h_loop_filter_chroma_12_mix_no-shift_c: 559.3
vvc_h_loop_filter_chroma_12_mix_no-shift_avx: 99.3

vvc_h_loop_filter_chroma_12_mix_shift_c: 799.3
vvc_h_loop_filter_chroma_12_mix_shift_avx: 209.3

vvc_h_loop_filter_chroma_12_one-side_no-shift_c: 679.3
vvc_h_loop_filter_chroma_12_one-side_no-shift_avx: 149.3

vvc_h_loop_filter_chroma_12_one-side_shift_c: 919.3
vvc_h_loop_filter_chroma_12_one-side_shift_avx: 139.3

vvc_h_loop_filter_chroma_12_strong_no-shift_c: 919.3
vvc_h_loop_filter_chroma_12_strong_no-shift_avx: 169.3

vvc_h_loop_filter_chroma_12_strong_shift_c: 1119.3
vvc_h_loop_filter_chroma_12_strong_shift_avx: 159.3

vvc_h_loop_filter_chroma_12_weak_no-shift_c: 219.3
vvc_h_loop_filter_chroma_12_weak_no-shift_avx: 99.3

vvc_h_loop_filter_chroma_12_weak_shift_c: 249.3
vvc_h_loop_filter_chroma_12_weak_shift_avx: 89.3

vvc_v_loop_filter_chroma_8_mix_no-shift_c: 439.3
vvc_v_loop_filter_chroma_8_mix_no-shift_avx: 329.3

vvc_v_loop_filter_chroma_8_mix_shift_c: 1799.3
vvc_v_loop_filter_chroma_8_mix_shift_avx: 369.3

vvc_v_loop_filter_chroma_8_one-side_no-shift_c: 709.3
vvc_v_loop_filter_chroma_8_one-side_no-shift_avx: 369.3

vvc_v_loop_filter_chroma_8_one-side_shift_c: 889.3
vvc_v_loop_filter_chroma_8_one-side_shift_avx: 369.3

vvc_v_loop_filter_chroma_8_strong_no-shift_c: 919.3
vvc_v_loop_filter_chroma_8_strong_no-shift_avx: 369.3

vvc_v_loop_filter_chroma_8_strong_shift_c: 1139.3
vvc_v_loop_filter_chroma_8_strong_shift_avx: 369.3

vvc_v_loop_filter_chroma_8_weak_no-shift_c: 429.3
vvc_v_loop_filter_chroma_8_weak_no-shift_avx: 339.3

vvc_v_loop_filter_chroma_8_weak_shift_c: 459.3
vvc_v_loop_filter_chroma_8_weak_shift_avx: 319.3

vvc_v_loop_filter_chroma_10_mix_no-shift_c: 629.3
vvc_v_loop_filter_chroma_10_mix_no-shift_avx: 319.3

vvc_v_loop_filter_chroma_10_mix_shift_c: 399.3
vvc_v_loop_filter_chroma_10_mix_shift_avx: 359.3

vvc_v_loop_filter_chroma_10_one-side_no-shift_c: 749.3
vvc_v_loop_filter_chroma_10_one-side_no-shift_avx: 339.3

vvc_v_loop_filter_chroma_10_one-side_shift_c: 959.3
vvc_v_loop_filter_chroma_10_one-side_shift_avx: 339.3

vvc_v_loop_filter_chroma_10_strong_no-shift_c: 949.3
vvc_v_loop_filter_chroma_10_strong_no-shift_avx: 339.3

vvc_v_loop_filter_chroma_10_strong_shift_c: 1179.3
vvc_v_loop_filter_chroma_10_strong_shift_avx: 329.3

vvc_v_loop_filter_chroma_10_weak_no-shift_c: 339.3
vvc_v_loop_filter_chroma_10_weak_no-shift_avx: 319.3

vvc_v_loop_filter_chroma_10_weak_shift_c: 439.3
vvc_v_loop_filter_chroma_10_weak_shift_avx: 309.3

vvc_v_loop_filter_chroma_12_mix_no-shift_c: 859.3
vvc_v_loop_filter_chroma_12_mix_no-shift_avx: 339.3

vvc_v_loop_filter_chroma_12_mix_shift_c: 729.3
vvc_v_loop_filter_chroma_12_mix_shift_avx: 379.3

vvc_v_loop_filter_chroma_12_one-side_no-shift_c: 739.3
vvc_v_loop_filter_chroma_12_one-side_no-shift_avx: 349.3

vvc_v_loop_filter_chroma_12_one-side_shift_c: 949.3
vvc_v_loop_filter_chroma_12_one-side_shift_avx: 339.3

vvc_v_loop_filter_chroma_12_strong_no-shift_c: 989.3
vvc_v_loop_filter_chroma_12_strong_no-shift_avx: 339.3

vvc_v_loop_filter_chroma_12_strong_shift_c: 1179.3
vvc_v_loop_filter_chroma_12_strong_shift_avx: 329.3

vvc_v_loop_filter_chroma_12_weak_no-shift_c: 359.3
vvc_v_loop_filter_chroma_12_weak_no-shift_avx: 329.3

vvc_v_loop_filter_chroma_12_weak_shift_c: 399.3
vvc_v_loop_filter_chroma_12_weak_shift_avx: 309.3

@stone-d-chen stone-d-chen requested a review from nuomi2021 January 3, 2025 22:09
The deblocking code only uses AVX so it can be initialized for both AVX and AVX2
@stone-d-chen stone-d-chen marked this pull request as ready for review January 4, 2025 20:06
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.

1 participant