diff mbox series

[FFmpeg-devel,1/2] checkasm/flacdsp: add LPC test

Message ID 20231115180220.47256-1-remi@remlab.net
State New
Headers show
Series [FFmpeg-devel,1/2] checkasm/flacdsp: add LPC test | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Rémi Denis-Courmont Nov. 15, 2023, 6:02 p.m. UTC
---
 tests/checkasm/flacdsp.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

Comments

James Almer Nov. 15, 2023, 7:14 p.m. UTC | #1
On 11/15/2023 3:02 PM, Rémi Denis-Courmont wrote:
> ---
>   tests/checkasm/flacdsp.c | 32 ++++++++++++++++++++++++++++++++
>   1 file changed, 32 insertions(+)
> 
> diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
> index 51a0e0060b..4d69cbe507 100644
> --- a/tests/checkasm/flacdsp.c
> +++ b/tests/checkasm/flacdsp.c
> @@ -54,6 +54,28 @@ static void check_decorrelate(uint8_t **ref_dst, uint8_t **ref_src, uint8_t **ne
>       bench_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE / sizeof(int32_t), 8);
>   }
>   
> +static void check_lpc(FLACDSPContext *c, int pred_order)

c is unused.

> +{
> +    int qlevel = rnd() % 16;
> +    LOCAL_ALIGNED_16(int32_t, coeffs, [32]);
> +    LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]);
> +    LOCAL_ALIGNED_16(int32_t, dst1, [BUF_SIZE]);
> +
> +    declare_func(void, int32_t *, const int[32], int, int, int);
> +
> +    for (int i = 0; i < 32; i++)
> +        coeffs[i] = rnd();
> +    for (int i = 0; i < BUF_SIZE; i++)
> +        dst0[i] = rnd();
> +
> +    memcpy(dst1, dst0, BUF_SIZE * sizeof (int32_t));
> +    call_ref(dst0, coeffs, pred_order, qlevel, BUF_SIZE);
> +    call_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);
> +    if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int32_t)) != 0)
> +       fail();
> +    bench_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);

Not sure if it matters, but dst1 is already trashed by call_new().

> +}
> +
>   void checkasm_check_flacdsp(void)
>   {
>       LOCAL_ALIGNED_16(uint8_t, ref_dst, [BUF_SIZE*MAX_CHANNELS]);
> @@ -72,6 +94,7 @@ void checkasm_check_flacdsp(void)
>           { AV_SAMPLE_FMT_S16, 16 },
>           { AV_SAMPLE_FMT_S32, 32 },
>       };
> +    static const signed char pred_orders[] = { 13, 16, 29, 32 };
>       FLACDSPContext h;
>       int i, j;
>   
> @@ -88,4 +111,13 @@ void checkasm_check_flacdsp(void)
>       }
>   
>       report("decorrelate");
> +
> +    for (int i = 0; i < sizeof (pred_orders); i++) {

i is already defined. Also, use FF_ARRAY_ELEMS(pred_orders), so it 
doesn't depend on char being 1 byte.

> +        if (check_func(h.lpc16, "flac_lpc_16_%d", pred_orders[i]))
> +            check_lpc(&h, pred_orders[i]);
> +        if (check_func(h.lpc32, "flac_lpc_32_%d", pred_orders[i]))
> +            check_lpc(&h, pred_orders[i]);
> +    }
> +
> +    report("lpc");
>   }

LGTM otherwise.
Rémi Denis-Courmont Nov. 15, 2023, 7:19 p.m. UTC | #2
Le keskiviikkona 15. marraskuuta 2023, 21.14.26 EET James Almer a écrit :
> On 11/15/2023 3:02 PM, Rémi Denis-Courmont wrote:
> > ---
> > 
> >   tests/checkasm/flacdsp.c | 32 ++++++++++++++++++++++++++++++++
> >   1 file changed, 32 insertions(+)
> > 
> > diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
> > index 51a0e0060b..4d69cbe507 100644
> > --- a/tests/checkasm/flacdsp.c
> > +++ b/tests/checkasm/flacdsp.c
> > @@ -54,6 +54,28 @@ static void check_decorrelate(uint8_t **ref_dst,
> > uint8_t **ref_src, uint8_t **ne> 
> >       bench_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE /
> >       sizeof(int32_t), 8);>   
> >   }
> > 
> > +static void check_lpc(FLACDSPContext *c, int pred_order)
> 
> c is unused.
> 
> > +{
> > +    int qlevel = rnd() % 16;
> > +    LOCAL_ALIGNED_16(int32_t, coeffs, [32]);
> > +    LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]);
> > +    LOCAL_ALIGNED_16(int32_t, dst1, [BUF_SIZE]);
> > +
> > +    declare_func(void, int32_t *, const int[32], int, int, int);
> > +
> > +    for (int i = 0; i < 32; i++)
> > +        coeffs[i] = rnd();
> > +    for (int i = 0; i < BUF_SIZE; i++)
> > +        dst0[i] = rnd();
> > +
> > +    memcpy(dst1, dst0, BUF_SIZE * sizeof (int32_t));
> > +    call_ref(dst0, coeffs, pred_order, qlevel, BUF_SIZE);
> > +    call_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);
> > +    if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int32_t)) != 0)
> > +       fail();
> > +    bench_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);
> 
> Not sure if it matters, but dst1 is already trashed by call_new().

Yeah I know. I could allocate a third buffer. AFAICT, the only parameter that 
should affect the benchmarks is pred-order (which indeed affects the result on 
both x86 and RVV). So that the extra code to preserve dst seemed pointless?

> 
> > +}
> > +
> > 
> >   void checkasm_check_flacdsp(void)
> >   {
> >   
> >       LOCAL_ALIGNED_16(uint8_t, ref_dst, [BUF_SIZE*MAX_CHANNELS]);
> > 
> > @@ -72,6 +94,7 @@ void checkasm_check_flacdsp(void)
> > 
> >           { AV_SAMPLE_FMT_S16, 16 },
> >           { AV_SAMPLE_FMT_S32, 32 },
> >       
> >       };
> > 
> > +    static const signed char pred_orders[] = { 13, 16, 29, 32 };
> > 
> >       FLACDSPContext h;
> >       int i, j;
> > 
> > @@ -88,4 +111,13 @@ void checkasm_check_flacdsp(void)
> > 
> >       }
> >       
> >       report("decorrelate");
> > 
> > +
> > +    for (int i = 0; i < sizeof (pred_orders); i++) {
> 
> i is already defined. Also, use FF_ARRAY_ELEMS(pred_orders), so it
> doesn't depend on char being 1 byte.
> 
> > +        if (check_func(h.lpc16, "flac_lpc_16_%d", pred_orders[i]))
> > +            check_lpc(&h, pred_orders[i]);
> > +        if (check_func(h.lpc32, "flac_lpc_32_%d", pred_orders[i]))
> > +            check_lpc(&h, pred_orders[i]);
> > +    }
> > +
> > +    report("lpc");
> > 
> >   }
> 
> LGTM otherwise.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
James Almer Nov. 15, 2023, 7:23 p.m. UTC | #3
On 11/15/2023 4:19 PM, Rémi Denis-Courmont wrote:
> Le keskiviikkona 15. marraskuuta 2023, 21.14.26 EET James Almer a écrit :
>> On 11/15/2023 3:02 PM, Rémi Denis-Courmont wrote:
>>> ---
>>>
>>>    tests/checkasm/flacdsp.c | 32 ++++++++++++++++++++++++++++++++
>>>    1 file changed, 32 insertions(+)
>>>
>>> diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
>>> index 51a0e0060b..4d69cbe507 100644
>>> --- a/tests/checkasm/flacdsp.c
>>> +++ b/tests/checkasm/flacdsp.c
>>> @@ -54,6 +54,28 @@ static void check_decorrelate(uint8_t **ref_dst,
>>> uint8_t **ref_src, uint8_t **ne>
>>>        bench_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE /
>>>        sizeof(int32_t), 8);>
>>>    }
>>>
>>> +static void check_lpc(FLACDSPContext *c, int pred_order)
>>
>> c is unused.
>>
>>> +{
>>> +    int qlevel = rnd() % 16;
>>> +    LOCAL_ALIGNED_16(int32_t, coeffs, [32]);
>>> +    LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]);
>>> +    LOCAL_ALIGNED_16(int32_t, dst1, [BUF_SIZE]);
>>> +
>>> +    declare_func(void, int32_t *, const int[32], int, int, int);
>>> +
>>> +    for (int i = 0; i < 32; i++)
>>> +        coeffs[i] = rnd();
>>> +    for (int i = 0; i < BUF_SIZE; i++)
>>> +        dst0[i] = rnd();
>>> +
>>> +    memcpy(dst1, dst0, BUF_SIZE * sizeof (int32_t));
>>> +    call_ref(dst0, coeffs, pred_order, qlevel, BUF_SIZE);
>>> +    call_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);
>>> +    if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int32_t)) != 0)
>>> +       fail();
>>> +    bench_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);
>>
>> Not sure if it matters, but dst1 is already trashed by call_new().
> 
> Yeah I know. I could allocate a third buffer. AFAICT, the only parameter that
> should affect the benchmarks is pred-order (which indeed affects the result on
> both x86 and RVV). So that the extra code to preserve dst seemed pointless?

I guess it's pointless in this case, yeah, but I know that some other 
dsp functions ended up with different benchmark results if the contents 
of a buffer were bogus (Which afaik is why when being filled with rnd() 
they are also clipped with a mask).

> 
>>
>>> +}
>>> +
>>>
>>>    void checkasm_check_flacdsp(void)
>>>    {
>>>    
>>>        LOCAL_ALIGNED_16(uint8_t, ref_dst, [BUF_SIZE*MAX_CHANNELS]);
>>>
>>> @@ -72,6 +94,7 @@ void checkasm_check_flacdsp(void)
>>>
>>>            { AV_SAMPLE_FMT_S16, 16 },
>>>            { AV_SAMPLE_FMT_S32, 32 },
>>>        
>>>        };
>>>
>>> +    static const signed char pred_orders[] = { 13, 16, 29, 32 };
>>>
>>>        FLACDSPContext h;
>>>        int i, j;
>>>
>>> @@ -88,4 +111,13 @@ void checkasm_check_flacdsp(void)
>>>
>>>        }
>>>        
>>>        report("decorrelate");
>>>
>>> +
>>> +    for (int i = 0; i < sizeof (pred_orders); i++) {
>>
>> i is already defined. Also, use FF_ARRAY_ELEMS(pred_orders), so it
>> doesn't depend on char being 1 byte.
>>
>>> +        if (check_func(h.lpc16, "flac_lpc_16_%d", pred_orders[i]))
>>> +            check_lpc(&h, pred_orders[i]);
>>> +        if (check_func(h.lpc32, "flac_lpc_32_%d", pred_orders[i]))
>>> +            check_lpc(&h, pred_orders[i]);
>>> +    }
>>> +
>>> +    report("lpc");
>>>
>>>    }
>>
>> LGTM otherwise.
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> 
>
diff mbox series

Patch

diff --git a/tests/checkasm/flacdsp.c b/tests/checkasm/flacdsp.c
index 51a0e0060b..4d69cbe507 100644
--- a/tests/checkasm/flacdsp.c
+++ b/tests/checkasm/flacdsp.c
@@ -54,6 +54,28 @@  static void check_decorrelate(uint8_t **ref_dst, uint8_t **ref_src, uint8_t **ne
     bench_new(new_dst, (int32_t **)new_src, channels, BUF_SIZE / sizeof(int32_t), 8);
 }
 
+static void check_lpc(FLACDSPContext *c, int pred_order)
+{
+    int qlevel = rnd() % 16;
+    LOCAL_ALIGNED_16(int32_t, coeffs, [32]);
+    LOCAL_ALIGNED_16(int32_t, dst0, [BUF_SIZE]);
+    LOCAL_ALIGNED_16(int32_t, dst1, [BUF_SIZE]);
+
+    declare_func(void, int32_t *, const int[32], int, int, int);
+
+    for (int i = 0; i < 32; i++)
+        coeffs[i] = rnd();
+    for (int i = 0; i < BUF_SIZE; i++)
+        dst0[i] = rnd();
+
+    memcpy(dst1, dst0, BUF_SIZE * sizeof (int32_t));
+    call_ref(dst0, coeffs, pred_order, qlevel, BUF_SIZE);
+    call_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);
+    if (memcmp(dst0, dst1, BUF_SIZE * sizeof (int32_t)) != 0)
+       fail();
+    bench_new(dst1, coeffs, pred_order, qlevel, BUF_SIZE);
+}
+
 void checkasm_check_flacdsp(void)
 {
     LOCAL_ALIGNED_16(uint8_t, ref_dst, [BUF_SIZE*MAX_CHANNELS]);
@@ -72,6 +94,7 @@  void checkasm_check_flacdsp(void)
         { AV_SAMPLE_FMT_S16, 16 },
         { AV_SAMPLE_FMT_S32, 32 },
     };
+    static const signed char pred_orders[] = { 13, 16, 29, 32 };
     FLACDSPContext h;
     int i, j;
 
@@ -88,4 +111,13 @@  void checkasm_check_flacdsp(void)
     }
 
     report("decorrelate");
+
+    for (int i = 0; i < sizeof (pred_orders); i++) {
+        if (check_func(h.lpc16, "flac_lpc_16_%d", pred_orders[i]))
+            check_lpc(&h, pred_orders[i]);
+        if (check_func(h.lpc32, "flac_lpc_32_%d", pred_orders[i]))
+            check_lpc(&h, pred_orders[i]);
+    }
+
+    report("lpc");
 }