Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Zhao Zhili via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Zhao Zhili <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PR] tests/checkasm: add a fake cpu flag for benchmarking two C functions (PR #21421)
Date: Fri, 09 Jan 2026 18:09:38 -0000
Message-ID: <176798217890.25.17828040842867030168@4457048688e7> (raw)

PR #21421 opened by Zhao Zhili (quink)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21421
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21421.patch

For example, check the flag and set a function for test:

    if (ff_is_cpu_flags_test)
        c->bswap_buf = bswap_buf_2;

Run the test:
./tests/checkasm/checkasm --test=bswapdsp --bench=bswap_buf

bswap_buf_c:                          0.5 ( 1.00x)
bswap_buf_test:                       0.3 ( 2.04x)

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>


>From 91e1ac15a456f3a2b2a28984c57ad366df28d611 Mon Sep 17 00:00:00 2001
From: Zhao Zhili <zhilizhao@tencent.com>
Date: Sat, 10 Jan 2026 01:03:37 +0800
Subject: [PATCH] tests/checkasm: add a fake cpu flag for benchmarking two C
 functions

For example, check the flag and set a function for test:

    if (ff_is_cpu_flags_test)
        c->bswap_buf = bswap_buf_2;

Run the test:
./tests/checkasm/checkasm --test=bswapdsp --bench=bswap_buf

bswap_buf_c:                          0.5 ( 1.00x)
bswap_buf_test:                       0.3 ( 2.04x)

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
---
 libavutil/cpu_internal.h  |  4 ++++
 tests/checkasm/checkasm.c | 15 +++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/libavutil/cpu_internal.h b/libavutil/cpu_internal.h
index 8dca62334a..7f36fecd49 100644
--- a/libavutil/cpu_internal.h
+++ b/libavutil/cpu_internal.h
@@ -44,6 +44,10 @@
 #define CPUEXT_FAST(flags, cpuext) CPUEXT_SUFFIX_FAST(flags, , cpuext)
 #define CPUEXT_SLOW(flags, cpuext) CPUEXT_SUFFIX_SLOW(flags, , cpuext)
 
+/* Fake CPU flag for testing only */
+#define AV_CPU_FLAG_TEST        0x80000000
+#define ff_is_cpu_flags_test    (av_get_cpu_flags() & AV_CPU_FLAG_TEST)
+
 int ff_get_cpu_flags_mips(void);
 int ff_get_cpu_flags_aarch64(void);
 int ff_get_cpu_flags_arm(void);
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 7dcdaeb2a4..8eb7e366bd 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -60,7 +60,7 @@
 #include "checkasm.h"
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
-#include "libavutil/cpu.h"
+#include "libavutil/cpu_internal.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/random_seed.h"
 
@@ -420,6 +420,9 @@ static const struct {
 #elif ARCH_WASM
     { "SIMD128",    "simd128",  AV_CPU_FLAG_SIMD128 },
 #endif
+
+    /* Don't put any flag after this one */
+    { "TEST", "test", AV_CPU_FLAG_TEST },
     { NULL }
 };
 
@@ -861,9 +864,13 @@ static void check_cpu_flag(const char *name, int flag)
 {
     int old_cpu_flag = state.cpu_flag;
 
-    flag |= old_cpu_flag;
-    av_force_cpu_flags(-1);
-    state.cpu_flag = flag & av_get_cpu_flags();
+    if (flag == AV_CPU_FLAG_TEST) {
+        state.cpu_flag = flag;
+    } else {
+        flag |= old_cpu_flag;
+        av_force_cpu_flags(-1);
+        state.cpu_flag = flag & av_get_cpu_flags();
+    }
     av_force_cpu_flags(state.cpu_flag);
 
     if (!flag || state.cpu_flag != old_cpu_flag) {
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2026-01-09 18:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=176798217890.25.17828040842867030168@4457048688e7 \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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