[PATCH 0/3] sbrdsp: SSE2 functions
Drop SSE-only functions as much as possible to avoid any clutter. pre_shuffle and apply_noise were therefore affected. Christophe Gisquet (3): x86: sbrdsp: implement SSE2 qmf_pre_shuffle x86: sbrdsp: implement SSE qmf_deint_neg x86: sbrdsp: implement SSE2 hf_apply_noise libavcodec/aacsbrdata.h | 6 +- libavcodec/x86/sbrdsp.asm | 150 +++++++++++++++++++++++++++++++++++++++++++ libavcodec/x86/sbrdsp_init.c | 20 ++++++ 3 files changed, 175 insertions(+), 1 deletion(-) -- 1.8.0.msysgit.0
From 253 to 51 cycles on Arrandale and Win64. 44 cycles on SandyBridge.
libavcodec/x86/sbrdsp.asm | 30 ++++++++++++++++++++++++++++++ libavcodec/x86/sbrdsp_init.c | 2 ++ 2 files changed, 32 insertions(+) diff --git a/libavcodec/x86/sbrdsp.asm b/libavcodec/x86/sbrdsp.asm index 273e950..ecc9c71 100644 --- a/libavcodec/x86/sbrdsp.asm +++ b/libavcodec/x86/sbrdsp.asm @@ -284,3 +284,33 @@ SBR_QMF_DEINT_BFLY INIT_XMM sse2 SBR_QMF_DEINT_BFLY + +INIT_XMM sse2 +cglobal sbr_qmf_pre_shuffle, 1,4,7,z +%define OFFSET (32*4-2*mmsize) + mov r3q, OFFSET + lea r1q, [zq + (32+1)*4] + lea r2q, [zq + 64*4] + mova m6, [ps_neg] +.loop: + movu m0, [r1q] + movu m2, [r1q + mmsize] + movu m1, [zq + r3q + 4 + mmsize] + movu m3, [zq + r3q + 4] + + pxor m2, m6 + pxor m0, m6 + pshufd m2, m2, q0123 + pshufd m0, m0, q0123 + SBUTTERFLY dq, 2, 3, 5 + SBUTTERFLY dq, 0, 1, 4 + mova [r2q + 2*r3q + 0*mmsize], m2 + mova [r2q + 2*r3q + 1*mmsize], m3 + mova [r2q + 2*r3q + 2*mmsize], m0 + mova [r2q + 2*r3q + 3*mmsize], m1 + add r1q, 2*mmsize + sub r3q, 2*mmsize + jge .loop + mova m2, [zq] + movq [r2q], m2 + REP_RET diff --git a/libavcodec/x86/sbrdsp_init.c b/libavcodec/x86/sbrdsp_init.c index 8cc37dd..f97479e 100644 --- a/libavcodec/x86/sbrdsp_init.c +++ b/libavcodec/x86/sbrdsp_init.c @@ -36,6 +36,7 @@ void ff_sbr_neg_odd_64_sse(float *z); void ff_sbr_qmf_post_shuffle_sse(float W[32][2], const float *z); void ff_sbr_qmf_deint_bfly_sse(float *v, const float *src0, const float *src1); void ff_sbr_qmf_deint_bfly_sse2(float *v, const float *src0, const float *src1); +void ff_sbr_qmf_pre_shuffle_sse2(float *z); av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s) { @@ -53,5 +54,6 @@ av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s) if (EXTERNAL_SSE2(mm_flags)) { s->qmf_deint_bfly = ff_sbr_qmf_deint_bfly_sse2; + s->qmf_pre_shuffle = ff_sbr_qmf_pre_shuffle_sse2; } } -- 1.8.0.msysgit.0
On Tue, Apr 09, 2013 at 10:54:25PM +0000, Christophe Gisquet wrote:
From 253 to 51 cycles on Arrandale and Win64. 44 cycles on SandyBridge.
applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Into a blind darkness they enter who follow after the Ignorance, they as if into a greater darkness enter who devote themselves to the Knowledge alone. -- Isha Upanishad
No vector tests it. --- libavcodec/x86/sbrdsp.asm | 20 ++++++++++++++++++++ libavcodec/x86/sbrdsp_init.c | 2 ++ 2 files changed, 22 insertions(+) diff --git a/libavcodec/x86/sbrdsp.asm b/libavcodec/x86/sbrdsp.asm index ecc9c71..099382a 100644 --- a/libavcodec/x86/sbrdsp.asm +++ b/libavcodec/x86/sbrdsp.asm @@ -314,3 +314,23 @@ cglobal sbr_qmf_pre_shuffle, 1,4,7,z mova m2, [zq] movq [r2q], m2 REP_RET + +INIT_XMM sse +cglobal sbr_qmf_deint_neg, 2,3,3,v,src,vrev + lea vrevq, [vq + (64-4)*4] + add srcq, (64-8)*4 + mova m2, [ps_neg] +.loop: + mova m0, [srcq + 0] + mova m1, [srcq + 16] + shufps m0, m1, q3131 + shufps m1, m1, q2020 + xorps m0, m2 + mova [vq], m1 + mova [vrevq], m0 + add vq, 16 + sub vrevq, 16 + sub srcq, 32 + cmp vq, vrevq + jl .loop + REP_RET diff --git a/libavcodec/x86/sbrdsp_init.c b/libavcodec/x86/sbrdsp_init.c index f97479e..aade701 100644 --- a/libavcodec/x86/sbrdsp_init.c +++ b/libavcodec/x86/sbrdsp_init.c @@ -37,6 +37,7 @@ void ff_sbr_qmf_post_shuffle_sse(float W[32][2], const float *z); void ff_sbr_qmf_deint_bfly_sse(float *v, const float *src0, const float *src1); void ff_sbr_qmf_deint_bfly_sse2(float *v, const float *src0, const float *src1); void ff_sbr_qmf_pre_shuffle_sse2(float *z); +void ff_sbr_qmf_deint_neg_sse(float *v, const float *src); av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s) { @@ -50,6 +51,7 @@ av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s) s->hf_gen = ff_sbr_hf_gen_sse; s->qmf_post_shuffle = ff_sbr_qmf_post_shuffle_sse; s->qmf_deint_bfly = ff_sbr_qmf_deint_bfly_sse; + s->qmf_deint_neg = ff_sbr_qmf_deint_neg_sse; } if (EXTERNAL_SSE2(mm_flags)) { -- 1.8.0.msysgit.0
Hi, 2013-04-10 0:54 GMT+02:00 Christophe Gisquet <christophe.gisquet@gmail.com>:
No vector tests it.
But now at least al_sbr_hq_sr_48_2_fsaac48 tests it. Passes fate on win32 and win64. Guaranteed to be 100% SSE2-free. -- Christophe
On Thu, May 15, 2014 at 10:02:14PM +0200, Christophe Gisquet wrote:
Hi,
2013-04-10 0:54 GMT+02:00 Christophe Gisquet <christophe.gisquet@gmail.com>:
No vector tests it.
But now at least al_sbr_hq_sr_48_2_fsaac48 tests it. Passes fate on win32 and win64. Guaranteed to be 100% SSE2-free.
-- Christophe
sbrdsp.asm | 22 ++++++++++++++++++++++ sbrdsp_init.c | 3 +++ 2 files changed, 25 insertions(+) e018c4add0cf4178138b09346f4ca8ab4df5e814 0001-x86-sbrdsp-implement-SSE-qmf_deint_neg.patch From 9054c21c3fa57fd0e18410f179ab789f11ec8cf4 Mon Sep 17 00:00:00 2001 From: Christophe Gisquet <christophe.gisquet@gmail.com> Date: Fri, 7 Dec 2012 18:26:30 +0100 Subject: [PATCH 1/2] x86: sbrdsp: implement SSE qmf_deint_neg
From 133 (unrolled av_intfloat32 C) to 59 cycles on Arrandale/Win64.
applied thanks [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope
233 to 107 cycles on Arrandale and Win64. Replacing the multiplication by s_m[m] by a pand and a pxor with appropriate vectors is slower. Unrolling is a 15 cycles win. A SSE version was 4 cycles slower. --- libavcodec/aacsbrdata.h | 6 ++- libavcodec/x86/sbrdsp.asm | 100 +++++++++++++++++++++++++++++++++++++++++++ libavcodec/x86/sbrdsp_init.c | 16 +++++++ 3 files changed, 121 insertions(+), 1 deletion(-) diff --git a/libavcodec/aacsbrdata.h b/libavcodec/aacsbrdata.h index dd7a827..12575ee 100644 --- a/libavcodec/aacsbrdata.h +++ b/libavcodec/aacsbrdata.h @@ -352,7 +352,7 @@ static DECLARE_ALIGNED(32, float, sbr_qmf_window_us)[640] = { 0.8537385600, }; -/* First two entries repeated at end to simplify SIMD implementations. */ +/* First eight entries repeated at end to simplify SIMD implementations. */ const DECLARE_ALIGNED(16, float, ff_sbr_noise_table)[][2] = { {-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647}, { 0.14130051758487, -0.95090983575689}, {-0.47005496701697, -0.37340549728647}, @@ -610,7 +610,11 @@ const DECLARE_ALIGNED(16, float, ff_sbr_noise_table)[][2] = { {-0.93412041758744, 0.41374052024363}, { 0.96063943315511, 0.93116709541280}, { 0.97534253457837, 0.86150930812689}, { 0.99642466504163, 0.70190043427512}, {-0.94705089665984, -0.29580042814306}, { 0.91599807087376, -0.98147830385781}, +// Start of duplicated table {-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647}, +{ 0.14130051758487, -0.95090983575689}, {-0.47005496701697, -0.37340549728647}, +{ 0.80705063769351, 0.29653668284408}, {-0.38981478896926, 0.89572605717087}, +{-0.01053049862020, -0.66959058036166}, {-0.91266367957293, -0.11522938140034}, }; #endif /* AVCODEC_AACSBRDATA_H */ diff --git a/libavcodec/x86/sbrdsp.asm b/libavcodec/x86/sbrdsp.asm index 099382a..c60e540 100644 --- a/libavcodec/x86/sbrdsp.asm +++ b/libavcodec/x86/sbrdsp.asm @@ -26,6 +26,12 @@ SECTION_RODATA ps_mask times 2 dd 1<<31, 0 ps_mask2 times 2 dd 0, 1<<31 ps_neg times 4 dd 1<<31 +ps_noise0 times 2 dd 1.0, 0.0, +ps_noise2 times 2 dd -1.0, 0.0 +ps_noise13 dd 0.0, 1.0, 0.0, -1.0 + dd 0.0, -1.0, 0.0, 1.0 + dd 0.0, 1.0, 0.0, -1.0 +cextern sbr_noise_table SECTION_TEXT @@ -334,3 +340,97 @@ cglobal sbr_qmf_deint_neg, 2,3,3,v,src,vrev cmp vq, vrevq jl .loop REP_RET + +%macro LOAD_NST 1 +%if NREGS + lea r5q, [%1] + mova m0, [kxq + r5q] +%else + mova m0, [kxq + %1] +%endif +%endmacro + +INIT_XMM sse2 +; sbr_hf_apply_noise_0(float (*Y)[2], const float *s_m, +; const float *q_filt, int noise, +; int kx, int m_max) +cglobal sbr_hf_apply_noise_0, 5,5+NREGS,8, Y,s_m,q_filt,noise,kx,m_max + mova m0, [ps_noise0] + jmp apply_noise_main + +; sbr_hf_apply_noise_1(float (*Y)[2], const float *s_m, +; const float *q_filt, int noise, +; int kx, int m_max) +cglobal sbr_hf_apply_noise_1, 5,5+NREGS,8, Y,s_m,q_filt,noise,kx,m_max + and kxq, 1 + shl kxq, 4 + LOAD_NST ps_noise13 + jmp apply_noise_main + +; sbr_hf_apply_noise_2(float (*Y)[2], const float *s_m, +; const float *q_filt, int noise, +; int kx, int m_max) +cglobal sbr_hf_apply_noise_2, 5,5+NREGS,8, Y,s_m,q_filt,noise,kx,m_max + mova m0, [ps_noise2] + jmp apply_noise_main + +; sbr_hf_apply_noise_3(float (*Y)[2], const float *s_m, +; const float *q_filt, int noise, +; int kx, int m_max) +cglobal sbr_hf_apply_noise_3, 5,5+NREGS,8, Y,s_m,q_filt,noise,kx,m_max + and kxq, 1 + shl kxq, 4 + LOAD_NST ps_noise13+16 + +apply_noise_main: +%if ARCH_X86_64 == 0 || WIN64 + mov kxd, m_maxm +%define count kxq +%else +%define count m_maxq +%endif + dec noiseq + shl count, 2 +%if NREGS + lea r5q, [sbr_noise_table] +%define NOISE_TABLE r5q +%else +%define NOISE_TABLE sbr_noise_table +%endif + lea Yq, [Yq + 2*count] + add s_mq, count + add q_filtq, count + shl noiseq, 3 + pxor m5, m5 + neg count +.loop: + mova m1, [q_filtq + count] + movu m3, [noiseq + NOISE_TABLE + 1*mmsize] + movu m4, [noiseq + NOISE_TABLE + 2*mmsize] + add noiseq, 2*mmsize + and noiseq, 0x1ff<<3 + punpckhdq m2, m1, m1 + punpckldq m1, m1 + mulps m1, m3 ; m2 = q_filt[m] * ff_sbr_noise_table[noise] + mulps m2, m4 ; m2 = q_filt[m] * ff_sbr_noise_table[noise] + mova m3, [s_mq + count] + ; TODO: replace by a vpermd in AVX2 + punpckhdq m4, m3, m3 + punpckldq m3, m3 + cmpps m6, m3, m5, 0 ; m6 == 0 + cmpps m7, m4, m5, 0 ; m7 == 0 + mulps m3, m0 ; s_m[m] * phi_sign + mulps m4, m0 ; s_m[m] * phi_sign + pand m1, m6 + pand m2, m7 + movu m6, [Yq + 2*count] + movu m7, [Yq + 2*count + mmsize] + addps m3, m1 + addps m4, m2 + addps m6, m3 + addps m7, m4 + movu [Yq + 2*count], m6 + movu [Yq + 2*count + mmsize], m7 + add count, mmsize + jl .loop + RET diff --git a/libavcodec/x86/sbrdsp_init.c b/libavcodec/x86/sbrdsp_init.c index aade701..99ef545 100644 --- a/libavcodec/x86/sbrdsp_init.c +++ b/libavcodec/x86/sbrdsp_init.c @@ -38,6 +38,18 @@ void ff_sbr_qmf_deint_bfly_sse(float *v, const float *src0, const float *src1); void ff_sbr_qmf_deint_bfly_sse2(float *v, const float *src0, const float *src1); void ff_sbr_qmf_pre_shuffle_sse2(float *z); void ff_sbr_qmf_deint_neg_sse(float *v, const float *src); +void ff_sbr_hf_apply_noise_0_sse2(float (*Y)[2], const float *s_m, + const float *q_filt, int noise, + int kx, int m_max); +void ff_sbr_hf_apply_noise_1_sse2(float (*Y)[2], const float *s_m, + const float *q_filt, int noise, + int kx, int m_max); +void ff_sbr_hf_apply_noise_2_sse2(float (*Y)[2], const float *s_m, + const float *q_filt, int noise, + int kx, int m_max); +void ff_sbr_hf_apply_noise_3_sse2(float (*Y)[2], const float *s_m, + const float *q_filt, int noise, + int kx, int m_max); av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s) { @@ -57,5 +69,9 @@ av_cold void ff_sbrdsp_init_x86(SBRDSPContext *s) if (EXTERNAL_SSE2(mm_flags)) { s->qmf_deint_bfly = ff_sbr_qmf_deint_bfly_sse2; s->qmf_pre_shuffle = ff_sbr_qmf_pre_shuffle_sse2; + s->hf_apply_noise[0] = ff_sbr_hf_apply_noise_0_sse2; + s->hf_apply_noise[1] = ff_sbr_hf_apply_noise_1_sse2; + s->hf_apply_noise[2] = ff_sbr_hf_apply_noise_2_sse2; + s->hf_apply_noise[3] = ff_sbr_hf_apply_noise_3_sse2; } } -- 1.8.0.msysgit.0
On Tue, Apr 09, 2013 at 10:54:27PM +0000, Christophe Gisquet wrote:
233 to 107 cycles on Arrandale and Win64. Replacing the multiplication by s_m[m] by a pand and a pxor with appropriate vectors is slower. Unrolling is a 15 cycles win. A SSE version was 4 cycles slower. --- libavcodec/aacsbrdata.h | 6 ++- libavcodec/x86/sbrdsp.asm | 100 +++++++++++++++++++++++++++++++++++++++++++ libavcodec/x86/sbrdsp_init.c | 16 +++++++ 3 files changed, 121 insertions(+), 1 deletion(-)
Applying this or 2/3 and this i get libavcodec/x86/sbrdsp.asm:357: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:364: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:367: error: (LOAD_NST:1) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:373: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:380: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:383: error: (LOAD_NST:1) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:394: error: cannot reference symbol `NREGS' in preprocessor [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB When you are offended at any man's fault, turn to yourself and study your own failings. Then you will forget your anger. -- Epictetus
Hi, 2013/4/12 Michael Niedermayer <michaelni@gmx.at>:
Applying this or 2/3 and this i get libavcodec/x86/sbrdsp.asm:357: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:364: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:367: error: (LOAD_NST:1) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:373: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:380: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:383: error: (LOAD_NST:1) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:394: error: cannot reference symbol `NREGS' in preprocessor
Indeed, bad conflict resolution after rebasing I guess. Here's a fixed version, for which fate-aac runs fine on win32 and win64. -- Christophe
On Fri, Apr 12, 2013 at 07:14:58PM +0200, Christophe Gisquet wrote:
Hi,
2013/4/12 Michael Niedermayer <michaelni@gmx.at>:
Applying this or 2/3 and this i get libavcodec/x86/sbrdsp.asm:357: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:364: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:367: error: (LOAD_NST:1) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:373: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:380: error: (PROLOGUE:2) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:383: error: (LOAD_NST:1) cannot reference symbol `NREGS' in preprocessor libavcodec/x86/sbrdsp.asm:394: error: cannot reference symbol `NREGS' in preprocessor
Indeed, bad conflict resolution after rebasing I guess.
Here's a fixed version, for which fate-aac runs fine on win32 and win64.
-- Christophe
aacsbrdata.h | 6 ++- x86/sbrdsp.asm | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ x86/sbrdsp_init.c | 16 ++++++++ 3 files changed, 129 insertions(+), 1 deletion(-) e69ce59238c11ae266ec0794bdca182af62d0b73 0002-x86-sbrdsp-implement-SSE2-hf_apply_noise.patch From bf49837b8cfef2652c6dfe46031b8685ed9af217 Mon Sep 17 00:00:00 2001 From: Christophe Gisquet <christophe.gisquet@gmail.com> Date: Wed, 10 Apr 2013 00:42:38 +0200 Subject: [PATCH 2/2] x86: sbrdsp: implement SSE2 hf_apply_noise
233 to 107 cycles on Arrandale and Win64. Replacing the multiplication by s_m[m] by a pand and a pxor with appropriate vectors is slower. Unrolling is a 15 cycles win. A SSE version was 4 cycles slower. --- libavcodec/aacsbrdata.h | 6 ++- libavcodec/x86/sbrdsp.asm | 108 +++++++++++++++++++++++++++++++++++++++++++ libavcodec/x86/sbrdsp_init.c | 16 +++++++ 3 files changed, 129 insertions(+), 1 deletion(-)
diff --git a/libavcodec/aacsbrdata.h b/libavcodec/aacsbrdata.h index dd7a827..12575ee 100644 --- a/libavcodec/aacsbrdata.h +++ b/libavcodec/aacsbrdata.h @@ -352,7 +352,7 @@ static DECLARE_ALIGNED(32, float, sbr_qmf_window_us)[640] = { 0.8537385600, };
-/* First two entries repeated at end to simplify SIMD implementations. */ +/* First eight entries repeated at end to simplify SIMD implementations. */ const DECLARE_ALIGNED(16, float, ff_sbr_noise_table)[][2] = { {-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647}, { 0.14130051758487, -0.95090983575689}, {-0.47005496701697, -0.37340549728647}, @@ -610,7 +610,11 @@ const DECLARE_ALIGNED(16, float, ff_sbr_noise_table)[][2] = { {-0.93412041758744, 0.41374052024363}, { 0.96063943315511, 0.93116709541280}, { 0.97534253457837, 0.86150930812689}, { 0.99642466504163, 0.70190043427512}, {-0.94705089665984, -0.29580042814306}, { 0.91599807087376, -0.98147830385781}, +// Start of duplicated table {-0.99948153278296, -0.59483417516607}, { 0.97113454393991, -0.67528515225647}, +{ 0.14130051758487, -0.95090983575689}, {-0.47005496701697, -0.37340549728647}, +{ 0.80705063769351, 0.29653668284408}, {-0.38981478896926, 0.89572605717087}, +{-0.01053049862020, -0.66959058036166}, {-0.91266367957293, -0.11522938140034}, };
#endif /* AVCODEC_AACSBRDATA_H */ diff --git a/libavcodec/x86/sbrdsp.asm b/libavcodec/x86/sbrdsp.asm index 099382a..e0c2088 100644 --- a/libavcodec/x86/sbrdsp.asm +++ b/libavcodec/x86/sbrdsp.asm @@ -26,6 +26,12 @@ SECTION_RODATA ps_mask times 2 dd 1<<31, 0 ps_mask2 times 2 dd 0, 1<<31 ps_neg times 4 dd 1<<31 +ps_noise0 times 2 dd 1.0, 0.0, +ps_noise2 times 2 dd -1.0, 0.0 +ps_noise13 dd 0.0, 1.0, 0.0, -1.0 + dd 0.0, -1.0, 0.0, 1.0 + dd 0.0, 1.0, 0.0, -1.0 +cextern sbr_noise_table
SECTION_TEXT
@@ -334,3 +340,105 @@ cglobal sbr_qmf_deint_neg, 2,3,3,v,src,vrev cmp vq, vrevq jl .loop REP_RET + +%if WIN64 +%define NREGS 0 +%elifdef PIC +%define NREGS 1 +%else +%define NREGS 0 +%endif + +%macro LOAD_NST 1 +%if NREGS + lea r5q, [%1] + mova m0, [kxq + r5q] +%else + mova m0, [kxq + %1] +%endif +%endmacro + +INIT_XMM sse2 +; sbr_hf_apply_noise_0(float (*Y)[2], const float *s_m, +; const float *q_filt, int noise, +; int kx, int m_max) +cglobal sbr_hf_apply_noise_0, 5,5+NREGS,8, Y,s_m,q_filt,noise,kx,m_max + mova m0, [ps_noise0] + jmp apply_noise_main + +; sbr_hf_apply_noise_1(float (*Y)[2], const float *s_m, +; const float *q_filt, int noise, +; int kx, int m_max) +cglobal sbr_hf_apply_noise_1, 5,5+NREGS,8, Y,s_m,q_filt,noise,kx,m_max + and kxq, 1 + shl kxq, 4 + LOAD_NST ps_noise13 + jmp apply_noise_main + +; sbr_hf_apply_noise_2(float (*Y)[2], const float *s_m, +; const float *q_filt, int noise, +; int kx, int m_max) +cglobal sbr_hf_apply_noise_2, 5,5+NREGS,8, Y,s_m,q_filt,noise,kx,m_max + mova m0, [ps_noise2] + jmp apply_noise_main + +; sbr_hf_apply_noise_3(float (*Y)[2], const float *s_m, +; const float *q_filt, int noise, +; int kx, int m_max) +cglobal sbr_hf_apply_noise_3, 5,5+NREGS,8, Y,s_m,q_filt,noise,kx,m_max + and kxq, 1 + shl kxq, 4 + LOAD_NST ps_noise13+16 + +apply_noise_main: +%if ARCH_X86_64 == 0 || WIN64 + mov kxd, m_maxm +%define count kxq +%else +%define count m_maxq +%endif + dec noiseq + shl count, 2 +%if NREGS + lea r5q, [sbr_noise_table]
count and r5q end being the same register here on x86_64 linux shared -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB While the State exists there can be no freedom; when there is freedom there will be no State. -- Vladimir Lenin
2013/4/13 Michael Niedermayer <michaelni@gmx.at>:
+%define count kxq +%else +%define count m_maxq +%endif + dec noiseq + shl count, 2 +%if NREGS + lea r5q, [sbr_noise_table]
count and r5q end being the same register here on x86_64 linux shared
Fixed that in the fashion we discussed. Also replaced the cmpeqps by pcmpeqd for a 2 cycles gain. -- Christophe
On Sat, Apr 13, 2013 at 06:02:43PM +0200, Christophe Gisquet wrote:
2013/4/13 Michael Niedermayer <michaelni@gmx.at>:
+%define count kxq +%else +%define count m_maxq +%endif + dec noiseq + shl count, 2 +%if NREGS + lea r5q, [sbr_noise_table]
count and r5q end being the same register here on x86_64 linux shared
Fixed that in the fashion we discussed. Also replaced the cmpeqps by pcmpeqd for a 2 cycles gain.
Seems to crash on linux x86_64 shared 0x00007ffff722d0f5 <apply_noise_main+0>: dec %rcx 0x00007ffff722d0f8 <apply_noise_main+3>: shl $0x2,%r9 0x00007ffff722d0fc <apply_noise_main+7>: lea 0x1a95d(%rip),%rax # 0x7ffff7247a60 <ff_sbr_noise_table> 0x00007ffff722d103 <apply_noise_main+14>: lea (%rdi,%r9,2),%rdi 0x00007ffff722d107 <apply_noise_main+18>: add %r9,%rsi 0x00007ffff722d10a <apply_noise_main+21>: add %r9,%rdx 0x00007ffff722d10d <apply_noise_main+24>: shl $0x3,%rcx 0x00007ffff722d111 <apply_noise_main+28>: pxor %xmm5,%xmm5 0x00007ffff722d115 <apply_noise_main+32>: neg %r9 0x00007ffff722d118 <apply_noise_main.loop+0>: movdqa (%rdx,%r9,1),%xmm1 0x00007ffff722d11e <apply_noise_main.loop+6>: movdqu 0x10(%rcx,%rax,1),%xmm3 0x00007ffff722d124 <apply_noise_main.loop+12>: movdqu 0x20(%rcx,%rax,1),%xmm4 0x00007ffff722d12a <apply_noise_main.loop+18>: add $0x20,%rcx 0x00007ffff722d12e <apply_noise_main.loop+22>: and $0xff8,%rcx 0x00007ffff722d135 <apply_noise_main.loop+29>: movdqa %xmm1,%xmm2 0x00007ffff722d139 <apply_noise_main.loop+33>: punpckhdq %xmm1,%xmm2 0x00007ffff722d13d <apply_noise_main.loop+37>: punpckldq %xmm1,%xmm1 0x00007ffff722d141 <apply_noise_main.loop+41>: mulps %xmm3,%xmm1 0x00007ffff722d144 <apply_noise_main.loop+44>: mulps %xmm4,%xmm2 => 0x00007ffff722d147 <apply_noise_main.loop+47>: movdqa (%rsi,%r9,1),%xmm3 0x00007ffff722d14d <apply_noise_main.loop+53>: movdqa %xmm3,%xmm4 0x00007ffff722d151 <apply_noise_main.loop+57>: punpckhdq %xmm3,%xmm4 0x00007ffff722d155 <apply_noise_main.loop+61>: punpckldq %xmm3,%xmm3 0x00007ffff722d159 <apply_noise_main.loop+65>: movdqa %xmm3,%xmm6 0x00007ffff722d15d <apply_noise_main.loop+69>: pcmpeqd %xmm5,%xmm6 0x00007ffff722d161 <apply_noise_main.loop+73>: movdqa %xmm4,%xmm7 0x00007ffff722d165 <apply_noise_main.loop+77>: pcmpeqd %xmm5,%xmm7 rax 0x7ffff7247a60 140737339751008 rbx 0x23 35 rcx 0x590 1424 rdx 0x27fffd4d61650 703686717609552 rsi 0x27fffd4da1350 703686717870928 rdi 0x47fffb1b4d9d0 1266636081650128 rbp 0x7fffffffd5b0 0x7fffffffd5b0 rsp 0x7fffffffd368 0x7fffffffd368 r8 0x0 0 r9 0xfffe000023227cb0 -562949363958608 r10 0x2b 43 r11 0x23 35 r12 0x7ffff7f5b720 140737353463584 r13 0x7ffff7f5b780 140737353463680 r14 0x1 1 r15 0x23 35 rip 0x7ffff722d147 0x7ffff722d147 <apply_noise_main.loop+47> [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf
2013/4/14 Michael Niedermayer <michaelni@gmx.at>:
Seems to crash on linux x86_64 shared
Indeed, noise vector was loaded (not shown in that stack trace) through r9 and thus r9 was overwritten. -- Christophe
2013/4/16 Christophe Gisquet <christophe.gisquet@gmail.com>:
2013/4/14 Michael Niedermayer <michaelni@gmx.at>:
Seems to crash on linux x86_64 shared
Indeed, noise vector was loaded (not shown in that stack trace) through r9 and thus r9 was overwritten.
Ping? Don't hurry replying though, I won't be able to do reply requests till the end of month. -- Christophe
On Mon, Apr 15, 2013 at 08:54:32PM +0200, Christophe Gisquet wrote:
2013/4/14 Michael Niedermayer <michaelni@gmx.at>:
Seems to crash on linux x86_64 shared
Indeed, noise vector was loaded (not shown in that stack trace) through r9 and thus r9 was overwritten.
The patch you attached is identical to the last, heres more complete disassmbly of the code that crashes 0x00007ffff6cd9c80 <ff_sbr_hf_apply_noise_0_sse2+0>: movdqa 0x14fcf8(%rip),%xmm0 # 0x7ffff6e29980 <ps_noise0> 0x00007ffff6cd9c88 <ff_sbr_hf_apply_noise_0_sse2+8>: jmp 0x7ffff6cd9cd5 <apply_noise_main> 0x00007ffff6cd9c8a <ff_sbr_hf_apply_noise_0_sse2+10>: nopw 0x0(%rax,%rax,1) 0x00007ffff6cd9c90 <ff_sbr_hf_apply_noise_1_sse2+0>: and $0x1,%r8 0x00007ffff6cd9c94 <ff_sbr_hf_apply_noise_1_sse2+4>: shl $0x4,%r8 0x00007ffff6cd9c98 <ff_sbr_hf_apply_noise_1_sse2+8>: lea 0x14fd01(%rip),%r9 # 0x7ffff6e299a0 <ps_noise13> 0x00007ffff6cd9c9f <ff_sbr_hf_apply_noise_1_sse2+15>: movdqa (%r8,%r9,1),%xmm0 0x00007ffff6cd9ca5 <ff_sbr_hf_apply_noise_1_sse2+21>: jmp 0x7ffff6cd9cd5 <apply_noise_main> 0x00007ffff6cd9ca7 <ff_sbr_hf_apply_noise_1_sse2+23>: nopw 0x0(%rax,%rax,1) 0x00007ffff6cd9cb0 <ff_sbr_hf_apply_noise_2_sse2+0>: movdqa 0x14fcd8(%rip),%xmm0 # 0x7ffff6e29990 <ps_noise2> 0x00007ffff6cd9cb8 <ff_sbr_hf_apply_noise_2_sse2+8>: jmp 0x7ffff6cd9cd5 <apply_noise_main> 0x00007ffff6cd9cba <ff_sbr_hf_apply_noise_2_sse2+10>: nopw 0x0(%rax,%rax,1) 0x00007ffff6cd9cc0 <ff_sbr_hf_apply_noise_3_sse2+0>: and $0x1,%r8 0x00007ffff6cd9cc4 <ff_sbr_hf_apply_noise_3_sse2+4>: shl $0x4,%r8 0x00007ffff6cd9cc8 <ff_sbr_hf_apply_noise_3_sse2+8>: lea 0x14fce1(%rip),%r9 # 0x7ffff6e299b0 <ps_noise13+16> 0x00007ffff6cd9ccf <ff_sbr_hf_apply_noise_3_sse2+15>: movdqa (%r8,%r9,1),%xmm0 0x00007ffff6cd9cd5 <apply_noise_main+0>: dec %rcx 0x00007ffff6cd9cd8 <apply_noise_main+3>: shl $0x2,%r9 0x00007ffff6cd9cdc <apply_noise_main+7>: lea 0x1a9bd(%rip),%rax # 0x7ffff6cf46a0 <ff_sbr_noise_table> 0x00007ffff6cd9ce3 <apply_noise_main+14>: lea (%rdi,%r9,2),%rdi 0x00007ffff6cd9ce7 <apply_noise_main+18>: add %r9,%rsi 0x00007ffff6cd9cea <apply_noise_main+21>: add %r9,%rdx 0x00007ffff6cd9ced <apply_noise_main+24>: shl $0x3,%rcx 0x00007ffff6cd9cf1 <apply_noise_main+28>: pxor %xmm5,%xmm5 0x00007ffff6cd9cf5 <apply_noise_main+32>: neg %r9 0x00007ffff6cd9cf8 <apply_noise_main.loop+0>: movdqa (%rdx,%r9,1),%xmm1 0x00007ffff6cd9cfe <apply_noise_main.loop+6>: movdqu 0x10(%rcx,%rax,1),%xmm3 0x00007ffff6cd9d04 <apply_noise_main.loop+12>: movdqu 0x20(%rcx,%rax,1),%xmm4 0x00007ffff6cd9d0a <apply_noise_main.loop+18>: add $0x20,%rcx 0x00007ffff6cd9d0e <apply_noise_main.loop+22>: and $0xff8,%rcx 0x00007ffff6cd9d15 <apply_noise_main.loop+29>: movdqa %xmm1,%xmm2 0x00007ffff6cd9d19 <apply_noise_main.loop+33>: punpckhdq %xmm1,%xmm2 0x00007ffff6cd9d1d <apply_noise_main.loop+37>: punpckldq %xmm1,%xmm1 0x00007ffff6cd9d21 <apply_noise_main.loop+41>: mulps %xmm3,%xmm1 0x00007ffff6cd9d24 <apply_noise_main.loop+44>: mulps %xmm4,%xmm2 => 0x00007ffff6cd9d27 <apply_noise_main.loop+47>: movdqa (%rsi,%r9,1),%xmm3 0x00007ffff6cd9d2d <apply_noise_main.loop+53>: movdqa %xmm3,%xmm4 0x00007ffff6cd9d31 <apply_noise_main.loop+57>: punpckhdq %xmm3,%xmm4 0x00007ffff6cd9d35 <apply_noise_main.loop+61>: punpckldq %xmm3,%xmm3 0x00007ffff6cd9d39 <apply_noise_main.loop+65>: movdqa %xmm3,%xmm6 0x00007ffff6cd9d3d <apply_noise_main.loop+69>: pcmpeqd %xmm5,%xmm6 0x00007ffff6cd9d41 <apply_noise_main.loop+73>: movdqa %xmm4,%xmm7 0x00007ffff6cd9d45 <apply_noise_main.loop+77>: pcmpeqd %xmm5,%xmm7 0x00007ffff6cd9d49 <apply_noise_main.loop+81>: mulps %xmm0,%xmm3 0x00007ffff6cd9d4c <apply_noise_main.loop+84>: mulps %xmm0,%xmm4 0x00007ffff6cd9d4f <apply_noise_main.loop+87>: pand %xmm6,%xmm1 0x00007ffff6cd9d53 <apply_noise_main.loop+91>: pand %xmm7,%xmm2 0x00007ffff6cd9d57 <apply_noise_main.loop+95>: movdqu (%rdi,%r9,2),%xmm6 0x00007ffff6cd9d5d <apply_noise_main.loop+101>: movdqu 0x10(%rdi,%r9,2),%xmm7 0x00007ffff6cd9d64 <apply_noise_main.loop+108>: addps %xmm1,%xmm3 0x00007ffff6cd9d67 <apply_noise_main.loop+111>: addps %xmm2,%xmm4 0x00007ffff6cd9d6a <apply_noise_main.loop+114>: addps %xmm3,%xmm6 0x00007ffff6cd9d6d <apply_noise_main.loop+117>: addps %xmm4,%xmm7 0x00007ffff6cd9d70 <apply_noise_main.loop+120>: movdqu %xmm6,(%rdi,%r9,2) 0x00007ffff6cd9d76 <apply_noise_main.loop+126>: movdqu %xmm7,0x10(%rdi,%r9,2) 0x00007ffff6cd9d7d <apply_noise_main.loop+133>: add $0x10,%r9 0x00007ffff6cd9d81 <apply_noise_main.loop+137>: jl 0x7ffff6cd9cf8 <apply_noise_main.loop> 0x00007ffff6cd9d87 <apply_noise_main.loop+143>: retq rax 0x7ffff6cf46a0 140737334167200 rbx 0x23 35 rcx 0x590 1424 rdx 0x27fffd3814f50 703686695276368 rsi 0x27fffd3854c50 703686695537744 rdi 0x47fffaf0b4bd0 1266636036983760 rbp 0x7fffffffd640 0x7fffffffd640 rsp 0x7fffffffd3f8 0x7fffffffd3f8 r8 0x0 0 r9 0xfffe0000247743b0 -562949341625424 r10 0x2b 43 r11 0x23 35 r12 0x7ffff7f5b720 140737353463584 r13 0x7ffff7f5b780 140737353463680 r14 0x1 1 r15 0x23 35 rip 0x7ffff6cd9d27 0x7ffff6cd9d27 <apply_noise_main.loop+47> [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB In a rich man's house there is no place to spit but his face. -- Diogenes of Sinope
participants (2)
-
Christophe Gisquet -
Michael Niedermayer