Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] checkasm: add sample argument to adjust during bench
@ 2024-05-16 13:09 J. Dekker
  2024-05-16 13:59 ` Rémi Denis-Courmont
  0 siblings, 1 reply; 8+ messages in thread
From: J. Dekker @ 2024-05-16 13:09 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: J. Dekker

Some timers on certain device and test combinations can produce noisy
results, affecting the reliability of performance measurements. One
notable example of this is the Canaan K230 RISC-V development board.

An option to adjust the number of samples (--samples) has been added,
allowing developers to increase or adjust the sample count for more
reliable results.

Signed-off-by: J. Dekker <jdek@itanimul.li>
---

 This could also be implemented as a compile time define or a configure
 argument.

 tests/checkasm/checkasm.c | 12 +++++++++++-
 tests/checkasm/checkasm.h |  4 ++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index ffc89882b1..c31adc3690 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -72,6 +72,9 @@
 void (*checkasm_checked_call)(void *func, int dummy, ...) = checkasm_checked_call_novfp;
 #endif
 
+/* Trade-off between speed and accuracy */
+uint64_t bench_runs = 1000;
+
 /* List of tests to invoke */
 static const struct {
     const char *name;
@@ -819,7 +822,7 @@ static void bench_uninit(void)
 static int usage(const char *path)
 {
     fprintf(stderr,
-            "Usage: %s [--bench] [--test=<pattern>] [--verbose] [seed]\n",
+            "Usage: %s [--bench] [--samples=<count>] [--test=<pattern>] [--verbose] [seed]\n",
             path);
     return 1;
 }
@@ -866,6 +869,13 @@ int main(int argc, char *argv[])
             state.test_name = arg + 7;
         } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
             state.verbose = 1;
+        } else if (!strncmp(arg, "--samples=", 10)) {
+            l = strtoul(arg + 10, &end, 10);
+            if (*end == '\0') {
+                bench_runs = l;
+            } else {
+                return usage(argv[0]);
+            }
         } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX &&
                    *end == '\0') {
             seed = l;
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 07fcc751ff..11f07a919f 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -167,7 +167,7 @@ extern AVLFG checkasm_lfg;
 
 static av_unused void *func_ref, *func_new;
 
-#define BENCH_RUNS 1000 /* Trade-off between accuracy and speed */
+extern uint64_t bench_runs;
 
 /* Decide whether or not the specified function needs to be tested */
 #define check_func(func, ...) (checkasm_save_context(), func_ref = checkasm_check_func((func_new = func), __VA_ARGS__))
@@ -339,7 +339,7 @@ typedef struct CheckasmPerf {
             int ti, tcount = 0;\
             uint64_t t = 0; \
             checkasm_set_signal_handler_state(1);\
-            for (ti = 0; ti < BENCH_RUNS; ti++) {\
+            for (ti = 0; ti < bench_runs; ti++) {\
                 PERF_START(t);\
                 tfunc(__VA_ARGS__);\
                 tfunc(__VA_ARGS__);\
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH] checkasm: add sample argument to adjust during bench
  2024-05-16 13:09 [FFmpeg-devel] [PATCH] checkasm: add sample argument to adjust during bench J. Dekker
@ 2024-05-16 13:59 ` Rémi Denis-Courmont
  2024-05-21 12:32   ` [FFmpeg-devel] [PATCH v2] " J. Dekker
  0 siblings, 1 reply; 8+ messages in thread
From: Rémi Denis-Courmont @ 2024-05-16 13:59 UTC (permalink / raw)
  To: ffmpeg-devel

Le torstaina 16. toukokuuta 2024, 16.09.49 EEST J. Dekker a écrit :
> Some timers on certain device and test combinations can produce noisy
> results, affecting the reliability of performance measurements. One
> notable example of this is the Canaan K230 RISC-V development board.
> 
> An option to adjust the number of samples (--samples) has been added,
> allowing developers to increase or adjust the sample count for more
> reliable results.

IMO, this should pick a reasonable estimate rather than rely on the tester to 
guess.

> 
> Signed-off-by: J. Dekker <jdek@itanimul.li>
> ---
> 
>  This could also be implemented as a compile time define or a configure
>  argument.
> 
>  tests/checkasm/checkasm.c | 12 +++++++++++-
>  tests/checkasm/checkasm.h |  4 ++--
>  2 files changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
> index ffc89882b1..c31adc3690 100644
> --- a/tests/checkasm/checkasm.c
> +++ b/tests/checkasm/checkasm.c
> @@ -72,6 +72,9 @@
>  void (*checkasm_checked_call)(void *func, int dummy, ...) =
> checkasm_checked_call_novfp; #endif
> 
> +/* Trade-off between speed and accuracy */
> +uint64_t bench_runs = 1000;
> +
>  /* List of tests to invoke */
>  static const struct {
>      const char *name;
> @@ -819,7 +822,7 @@ static void bench_uninit(void)
>  static int usage(const char *path)
>  {
>      fprintf(stderr,
> -            "Usage: %s [--bench] [--test=<pattern>] [--verbose] [seed]\n",
> +            "Usage: %s [--bench] [--samples=<count>] [--test=<pattern>]
> [--verbose] [seed]\n", path);
>      return 1;
>  }
> @@ -866,6 +869,13 @@ int main(int argc, char *argv[])
>              state.test_name = arg + 7;
>          } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
>              state.verbose = 1;
> +        } else if (!strncmp(arg, "--samples=", 10)) {
> +            l = strtoul(arg + 10, &end, 10);
> +            if (*end == '\0') {
> +                bench_runs = l;
> +            } else {
> +                return usage(argv[0]);
> +            }
>          } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX &&
>                     *end == '\0') {
>              seed = l;
> diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
> index 07fcc751ff..11f07a919f 100644
> --- a/tests/checkasm/checkasm.h
> +++ b/tests/checkasm/checkasm.h
> @@ -167,7 +167,7 @@ extern AVLFG checkasm_lfg;
> 
>  static av_unused void *func_ref, *func_new;
> 
> -#define BENCH_RUNS 1000 /* Trade-off between accuracy and speed */
> +extern uint64_t bench_runs;
> 
>  /* Decide whether or not the specified function needs to be tested */
>  #define check_func(func, ...) (checkasm_save_context(), func_ref =
> checkasm_check_func((func_new = func), __VA_ARGS__)) @@ -339,7 +339,7 @@
> typedef struct CheckasmPerf {
>              int ti, tcount = 0;\
>              uint64_t t = 0; \
>              checkasm_set_signal_handler_state(1);\
> -            for (ti = 0; ti < BENCH_RUNS; ti++) {\
> +            for (ti = 0; ti < bench_runs; ti++) {\

The C compiler cannot prove that the global bench_runs is not modified by the 
tested code. This needs to be cached in an automatic variable.

>                  PERF_START(t);\
>                  tfunc(__VA_ARGS__);\
>                  tfunc(__VA_ARGS__);\


-- 
レミ・デニ-クールモン
http://www.remlab.net/



_______________________________________________
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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH v2] checkasm: add sample argument to adjust during bench
  2024-05-16 13:59 ` Rémi Denis-Courmont
@ 2024-05-21 12:32   ` J. Dekker
  2024-05-21 12:48     ` Henrik Gramner via ffmpeg-devel
  2024-05-21 13:00     ` Lynne via ffmpeg-devel
  0 siblings, 2 replies; 8+ messages in thread
From: J. Dekker @ 2024-05-21 12:32 UTC (permalink / raw)
  To: ffmpeg-devel

Some timers on certain device and test combinations can produce noisy
results, affecting the reliability of performance measurements. One
notable example of this is the Canaan K230 RISC-V development board.

An option to adjust the number of samples (--samples) has been added,
allowing developers to increase or adjust the sample count for more
reliable results.

Signed-off-by: J. Dekker <jdek@itanimul.li>
---

 Auto-detection can be added later when either a count is omitted or a specific
 value or term such as '0' or 'auto' is provided. This is a development tool,
 the users will be developers primarily working on master who follow checkasm
 changes and/ or add their own tests and functionality; there's no need to
 support a feature like this or deprecate it for years if a better solution
 is submitted.

 tests/checkasm/checkasm.c | 12 +++++++++++-
 tests/checkasm/checkasm.h |  5 +++--
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 31ca9f6e2b..b8e5cfb9dd 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -72,6 +72,9 @@
 void (*checkasm_checked_call)(void *func, int dummy, ...) = checkasm_checked_call_novfp;
 #endif
 
+/* Trade-off between speed and accuracy */
+uint64_t bench_runs = 1000;
+
 /* List of tests to invoke */
 static const struct {
     const char *name;
@@ -820,7 +823,7 @@ static void bench_uninit(void)
 static int usage(const char *path)
 {
     fprintf(stderr,
-            "Usage: %s [--bench] [--test=<pattern>] [--verbose] [seed]\n",
+            "Usage: %s [--bench] [--samples=<count>] [--test=<pattern>] [--verbose] [seed]\n",
             path);
     return 1;
 }
@@ -867,6 +870,13 @@ int main(int argc, char *argv[])
             state.test_name = arg + 7;
         } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
             state.verbose = 1;
+        } else if (!strncmp(arg, "--samples=", 10)) {
+            l = strtoul(arg + 10, &end, 10);
+            if (*end == '\0') {
+                bench_runs = l;
+            } else {
+                return usage(argv[0]);
+            }
         } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX &&
                    *end == '\0') {
             seed = l;
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 07fcc751ff..d6921cc50c 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -167,7 +167,7 @@ extern AVLFG checkasm_lfg;
 
 static av_unused void *func_ref, *func_new;
 
-#define BENCH_RUNS 1000 /* Trade-off between accuracy and speed */
+extern uint64_t bench_runs;
 
 /* Decide whether or not the specified function needs to be tested */
 #define check_func(func, ...) (checkasm_save_context(), func_ref = checkasm_check_func((func_new = func), __VA_ARGS__))
@@ -338,8 +338,9 @@ typedef struct CheckasmPerf {
             uint64_t tsum = 0;\
             int ti, tcount = 0;\
             uint64_t t = 0; \
+            const uint64_t truns = bench_runs;\
             checkasm_set_signal_handler_state(1);\
-            for (ti = 0; ti < BENCH_RUNS; ti++) {\
+            for (ti = 0; ti < truns; ti++) {\
                 PERF_START(t);\
                 tfunc(__VA_ARGS__);\
                 tfunc(__VA_ARGS__);\
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2] checkasm: add sample argument to adjust during bench
  2024-05-21 12:32   ` [FFmpeg-devel] [PATCH v2] " J. Dekker
@ 2024-05-21 12:48     ` Henrik Gramner via ffmpeg-devel
  2024-05-21 13:00     ` Lynne via ffmpeg-devel
  1 sibling, 0 replies; 8+ messages in thread
From: Henrik Gramner via ffmpeg-devel @ 2024-05-21 12:48 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Henrik Gramner

On Tue, May 21, 2024 at 2:33 PM J. Dekker <jdek@itanimul.li> wrote:
> @@ -338,8 +338,9 @@ typedef struct CheckasmPerf {
>              uint64_t tsum = 0;\
>              int ti, tcount = 0;\
>              uint64_t t = 0; \
> +            const uint64_t truns = bench_runs;\
>              checkasm_set_signal_handler_state(1);\
> -            for (ti = 0; ti < BENCH_RUNS; ti++) {\
> +            for (ti = 0; ti < truns; ti++) {\

This is comparing int with uint64_t. We should probably just use int
for the sample count too.
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH v2] checkasm: add sample argument to adjust during bench
  2024-05-21 12:32   ` [FFmpeg-devel] [PATCH v2] " J. Dekker
  2024-05-21 12:48     ` Henrik Gramner via ffmpeg-devel
@ 2024-05-21 13:00     ` Lynne via ffmpeg-devel
  2024-05-21 13:51       ` [FFmpeg-devel] [PATCH v3] " J. Dekker
  1 sibling, 1 reply; 8+ messages in thread
From: Lynne via ffmpeg-devel @ 2024-05-21 13:00 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne


[-- Attachment #1.1.1.1: Type: text/plain, Size: 4147 bytes --]

On 21/05/2024 14:32, J. Dekker wrote:
> Some timers on certain device and test combinations can produce noisy
> results, affecting the reliability of performance measurements. One
> notable example of this is the Canaan K230 RISC-V development board.
> 
> An option to adjust the number of samples (--samples) has been added,
> allowing developers to increase or adjust the sample count for more
> reliable results.
> 
> Signed-off-by: J. Dekker <jdek@itanimul.li>
> ---
> 
>   Auto-detection can be added later when either a count is omitted or a specific
>   value or term such as '0' or 'auto' is provided. This is a development tool,
>   the users will be developers primarily working on master who follow checkasm
>   changes and/ or add their own tests and functionality; there's no need to
>   support a feature like this or deprecate it for years if a better solution
>   is submitted.
> 
>   tests/checkasm/checkasm.c | 12 +++++++++++-
>   tests/checkasm/checkasm.h |  5 +++--
>   2 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
> index 31ca9f6e2b..b8e5cfb9dd 100644
> --- a/tests/checkasm/checkasm.c
> +++ b/tests/checkasm/checkasm.c
> @@ -72,6 +72,9 @@
>   void (*checkasm_checked_call)(void *func, int dummy, ...) = checkasm_checked_call_novfp;
>   #endif
>   
> +/* Trade-off between speed and accuracy */
> +uint64_t bench_runs = 1000;
> +
>   /* List of tests to invoke */
>   static const struct {
>       const char *name;
> @@ -820,7 +823,7 @@ static void bench_uninit(void)
>   static int usage(const char *path)
>   {
>       fprintf(stderr,
> -            "Usage: %s [--bench] [--test=<pattern>] [--verbose] [seed]\n",
> +            "Usage: %s [--bench] [--samples=<count>] [--test=<pattern>] [--verbose] [seed]\n",
>               path);
>       return 1;
>   }
> @@ -867,6 +870,13 @@ int main(int argc, char *argv[])
>               state.test_name = arg + 7;
>           } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
>               state.verbose = 1;
> +        } else if (!strncmp(arg, "--samples=", 10)) {
> +            l = strtoul(arg + 10, &end, 10);
> +            if (*end == '\0') {
> +                bench_runs = l;
> +            } else {
> +                return usage(argv[0]);
> +            }
>           } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX &&
>                      *end == '\0') {
>               seed = l;
> diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
> index 07fcc751ff..d6921cc50c 100644
> --- a/tests/checkasm/checkasm.h
> +++ b/tests/checkasm/checkasm.h
> @@ -167,7 +167,7 @@ extern AVLFG checkasm_lfg;
>   
>   static av_unused void *func_ref, *func_new;
>   
> -#define BENCH_RUNS 1000 /* Trade-off between accuracy and speed */
> +extern uint64_t bench_runs;
>   
>   /* Decide whether or not the specified function needs to be tested */
>   #define check_func(func, ...) (checkasm_save_context(), func_ref = checkasm_check_func((func_new = func), __VA_ARGS__))
> @@ -338,8 +338,9 @@ typedef struct CheckasmPerf {
>               uint64_t tsum = 0;\
>               int ti, tcount = 0;\
>               uint64_t t = 0; \
> +            const uint64_t truns = bench_runs;\
>               checkasm_set_signal_handler_state(1);\
> -            for (ti = 0; ti < BENCH_RUNS; ti++) {\
> +            for (ti = 0; ti < truns; ti++) {\
>                   PERF_START(t);\
>                   tfunc(__VA_ARGS__);\
>                   tfunc(__VA_ARGS__);\

While working on the FFT asm with
https://github.com/cyanreg/lavu_fft_test which has a built-in benchmark, 
I've found that exponentiation works best, as adding more and more 
digits at the end is prone to under/overshoot. For large functions, 1 << 
16 is a good starting point, while for very small functions, 1 << 23 
becomes more optimal.

I suggest replacing --samples with --runs (or --bench-runs, but we're 
all lazy for that), and documenting it as "--runs=<ptwo>" and rejecting 
anything large enough to overflow.

[-- Attachment #1.1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 637 bytes --]

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [FFmpeg-devel] [PATCH v3] checkasm: add sample argument to adjust during bench
  2024-05-21 13:00     ` Lynne via ffmpeg-devel
@ 2024-05-21 13:51       ` J. Dekker
  2024-05-21 14:04         ` Lynne via ffmpeg-devel
  0 siblings, 1 reply; 8+ messages in thread
From: J. Dekker @ 2024-05-21 13:51 UTC (permalink / raw)
  To: ffmpeg-devel

Some timers on certain device and test combinations can produce noisy
results, affecting the reliability of performance measurements. One
notable example of this is the Canaan K230 RISC-V development board.

An option to adjust the number of samples by an exponent (--runs) has
been added, allowing developers to increase the sample count for more
reliable results.

Signed-off-by: J. Dekker <jdek@itanimul.li>
---
 tests/checkasm/checkasm.c | 16 +++++++++++++++-
 tests/checkasm/checkasm.h |  7 ++++---
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 31ca9f6e2b..669f2be9c1 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -72,6 +72,9 @@
 void (*checkasm_checked_call)(void *func, int dummy, ...) = checkasm_checked_call_novfp;
 #endif
 
+/* Trade-off between speed and accuracy */
+uint64_t bench_runs = 1U << 10;
+
 /* List of tests to invoke */
 static const struct {
     const char *name;
@@ -820,7 +823,7 @@ static void bench_uninit(void)
 static int usage(const char *path)
 {
     fprintf(stderr,
-            "Usage: %s [--bench] [--test=<pattern>] [--verbose] [seed]\n",
+            "Usage: %s [--bench] [--runs=<ptwo>] [--test=<pattern>] [--verbose] [seed]\n",
             path);
     return 1;
 }
@@ -867,6 +870,17 @@ int main(int argc, char *argv[])
             state.test_name = arg + 7;
         } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
             state.verbose = 1;
+        } else if (!strncmp(arg, "--runs=", 7)) {
+            l = strtoul(arg + 7, &end, 10);
+            if (*end == '\0') {
+                if (l > 30) {
+                    fprintf(stderr, "checkasm: error: runs exponent must be within the range 0 <= 30\n");
+                    usage(argv[0]);
+                }
+                bench_runs = 1U << l;
+            } else {
+                return usage(argv[0]);
+            }
         } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX &&
                    *end == '\0') {
             seed = l;
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 07fcc751ff..e05053cbf6 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -167,7 +167,7 @@ extern AVLFG checkasm_lfg;
 
 static av_unused void *func_ref, *func_new;
 
-#define BENCH_RUNS 1000 /* Trade-off between accuracy and speed */
+extern uint64_t bench_runs;
 
 /* Decide whether or not the specified function needs to be tested */
 #define check_func(func, ...) (checkasm_save_context(), func_ref = checkasm_check_func((func_new = func), __VA_ARGS__))
@@ -336,10 +336,11 @@ typedef struct CheckasmPerf {
             av_unused const int sysfd = perf->sysfd;\
             func_type *tfunc = func_new;\
             uint64_t tsum = 0;\
-            int ti, tcount = 0;\
+            uint64_t ti, tcount = 0;\
             uint64_t t = 0; \
+            const uint64_t truns = bench_runs;\
             checkasm_set_signal_handler_state(1);\
-            for (ti = 0; ti < BENCH_RUNS; ti++) {\
+            for (ti = 0; ti < truns; ti++) {\
                 PERF_START(t);\
                 tfunc(__VA_ARGS__);\
                 tfunc(__VA_ARGS__);\
-- 
2.42.0

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3] checkasm: add sample argument to adjust during bench
  2024-05-21 13:51       ` [FFmpeg-devel] [PATCH v3] " J. Dekker
@ 2024-05-21 14:04         ` Lynne via ffmpeg-devel
  2024-05-21 14:49           ` J. Dekker
  0 siblings, 1 reply; 8+ messages in thread
From: Lynne via ffmpeg-devel @ 2024-05-21 14:04 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Lynne


[-- Attachment #1.1.1.1: Type: text/plain, Size: 3586 bytes --]

On 21/05/2024 15:51, J. Dekker wrote:
> Some timers on certain device and test combinations can produce noisy
> results, affecting the reliability of performance measurements. One
> notable example of this is the Canaan K230 RISC-V development board.
> 
> An option to adjust the number of samples by an exponent (--runs) has
> been added, allowing developers to increase the sample count for more
> reliable results.
> 
> Signed-off-by: J. Dekker <jdek@itanimul.li>
> ---
>   tests/checkasm/checkasm.c | 16 +++++++++++++++-
>   tests/checkasm/checkasm.h |  7 ++++---
>   2 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
> index 31ca9f6e2b..669f2be9c1 100644
> --- a/tests/checkasm/checkasm.c
> +++ b/tests/checkasm/checkasm.c
> @@ -72,6 +72,9 @@
>   void (*checkasm_checked_call)(void *func, int dummy, ...) = checkasm_checked_call_novfp;
>   #endif
>   
> +/* Trade-off between speed and accuracy */
> +uint64_t bench_runs = 1U << 10;
> +
>   /* List of tests to invoke */
>   static const struct {
>       const char *name;
> @@ -820,7 +823,7 @@ static void bench_uninit(void)
>   static int usage(const char *path)
>   {
>       fprintf(stderr,
> -            "Usage: %s [--bench] [--test=<pattern>] [--verbose] [seed]\n",
> +            "Usage: %s [--bench] [--runs=<ptwo>] [--test=<pattern>] [--verbose] [seed]\n",
>               path);
>       return 1;
>   }
> @@ -867,6 +870,17 @@ int main(int argc, char *argv[])
>               state.test_name = arg + 7;
>           } else if (!strcmp(arg, "--verbose") || !strcmp(arg, "-v")) {
>               state.verbose = 1;
> +        } else if (!strncmp(arg, "--runs=", 7)) {
> +            l = strtoul(arg + 7, &end, 10);
> +            if (*end == '\0') {
> +                if (l > 30) {
> +                    fprintf(stderr, "checkasm: error: runs exponent must be within the range 0 <= 30\n");
> +                    usage(argv[0]);
> +                }
> +                bench_runs = 1U << l;
> +            } else {
> +                return usage(argv[0]);
> +            }
>           } else if ((l = strtoul(arg, &end, 10)) <= UINT_MAX &&
>                      *end == '\0') {
>               seed = l;
> diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
> index 07fcc751ff..e05053cbf6 100644
> --- a/tests/checkasm/checkasm.h
> +++ b/tests/checkasm/checkasm.h
> @@ -167,7 +167,7 @@ extern AVLFG checkasm_lfg;
>   
>   static av_unused void *func_ref, *func_new;
>   
> -#define BENCH_RUNS 1000 /* Trade-off between accuracy and speed */
> +extern uint64_t bench_runs;
>   
>   /* Decide whether or not the specified function needs to be tested */
>   #define check_func(func, ...) (checkasm_save_context(), func_ref = checkasm_check_func((func_new = func), __VA_ARGS__))
> @@ -336,10 +336,11 @@ typedef struct CheckasmPerf {
>               av_unused const int sysfd = perf->sysfd;\
>               func_type *tfunc = func_new;\
>               uint64_t tsum = 0;\
> -            int ti, tcount = 0;\
> +            uint64_t ti, tcount = 0;\
>               uint64_t t = 0; \
> +            const uint64_t truns = bench_runs;\
>               checkasm_set_signal_handler_state(1);\
> -            for (ti = 0; ti < BENCH_RUNS; ti++) {\
> +            for (ti = 0; ti < truns; ti++) {\
>                   PERF_START(t);\
>                   tfunc(__VA_ARGS__);\
>                   tfunc(__VA_ARGS__);\

Tested, works as intended
LGTM, thanks

[-- Attachment #1.1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 637 bytes --]

[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3] checkasm: add sample argument to adjust during bench
  2024-05-21 14:04         ` Lynne via ffmpeg-devel
@ 2024-05-21 14:49           ` J. Dekker
  0 siblings, 0 replies; 8+ messages in thread
From: J. Dekker @ 2024-05-21 14:49 UTC (permalink / raw)
  To: ffmpeg-devel


Lynne via ffmpeg-devel <ffmpeg-devel@ffmpeg.org> writes:

> [[PGP Signed Part:Undecided]]
> On 21/05/2024 15:51, J. Dekker wrote:
>> Some timers on certain device and test combinations can produce noisy
>> results, affecting the reliability of performance measurements. One
>> notable example of this is the Canaan K230 RISC-V development board.
>> An option to adjust the number of samples by an exponent (--runs) has
>> been added, allowing developers to increase the sample count for more
>> reliable results.
>> Signed-off-by: J. Dekker <jdek@itanimul.li>
>> ---
>>   tests/checkasm/checkasm.c | 16 +++++++++++++++-
>>   tests/checkasm/checkasm.h |  7 ++++---
>>   2 files changed, 19 insertions(+), 4 deletions(-)>
> Tested, works as intended
> LGTM, thanks

Thanks pushed with fixed commit message.

-- 
jd
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-05-21 14:50 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-16 13:09 [FFmpeg-devel] [PATCH] checkasm: add sample argument to adjust during bench J. Dekker
2024-05-16 13:59 ` Rémi Denis-Courmont
2024-05-21 12:32   ` [FFmpeg-devel] [PATCH v2] " J. Dekker
2024-05-21 12:48     ` Henrik Gramner via ffmpeg-devel
2024-05-21 13:00     ` Lynne via ffmpeg-devel
2024-05-21 13:51       ` [FFmpeg-devel] [PATCH v3] " J. Dekker
2024-05-21 14:04         ` Lynne via ffmpeg-devel
2024-05-21 14:49           ` J. Dekker

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git