From patchwork Tue May 21 12:32:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Dekker" X-Patchwork-Id: 49100 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:3a48:b0:1af:fc2d:ff5a with SMTP id zu8csp5197725pzb; Tue, 21 May 2024 05:33:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVazpA8h6YQMCsgtaqrx1KCPw5vjIhRNLnUSeWewmOhfwcytDZ2/13Q1OcEV6jRpEgNB80XL159augU2hlmggtmWmvco3qkkYPmUg== X-Google-Smtp-Source: AGHT+IFT81RcJyp/cHk2zBKt0Y3eQePm3zOiNuZSHQZ6H4C2shAs9NoIruAVW99amB4A8mwCw4n/ X-Received: by 2002:a05:6402:26d3:b0:574:ffa9:7f7 with SMTP id 4fb4d7f45d1cf-574ffa9095bmr12697704a12.2.1716294835093; Tue, 21 May 2024 05:33:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1716294835; cv=none; d=google.com; s=arc-20160816; b=F1HWDB9NCwG9KQIbOpU7FBqS9woe16cAwPp9kVbSyNVhS2X8vGGDIEZ3EELqT1WtFQ Z9DBaFF6Vrne/7uu0htsm4YRgYQG7zPcGc4KskWa/MY4JAFYGE5WVsuln7nca7I0Qu3z uppq0Em3DKHPHSwiFRvHfRj3vcJgCompkSmyAKTJ1Q2rBtPbqUx0/mswcr0kAJrf+fsD LSag+kuNFFFJKVXLBEjKXlBLjjSfZgEq4usMPSc32DRlblnIG16JAuJWQMEJpVL2K4kQ rswVGpLTqHot1qGGEy6/zfpH9oKERekFEkvZh4OZM841XLmhyo3olZciiIwYCV+A7gub 1/Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:feedback-id:dkim-signature:dkim-signature:delivered-to; bh=h0sRwGdVZhWi6gbGksXAnF1hqEy+f/CU/+xvYDPPyic=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=jkJa0Gwr5D2vXCnaw/SKP4PVRYowP1C5HedcJfUXF0rTXr0xxqj+EFlCty7LFboKeG EJnQQXZGiN1qdw187ntERinZN0gQPvzvbyc5EBZ0bh82y9zNpmuhVTeuprxHx6kqTzRt Md4+1QUkO2TWXs7PrfjlzJK2kmlm03u54OwkjhLRqUdTF2W7NrBklSSvifOE2tbITr1U Zxmu7xyKhSPnKIHRs1DTI2VVe9ypUFvDVbrU0yUauvWXCaf0J3T38n3MgUdgTFIm6anr IUFtmi3eTyPA87Cw9aAkwe69TOjDDgIe/rg2xHFXyROvDCu7iJ4ZpywC7IPYkhb1b2i4 44jw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm2 header.b="eRVT0R/L"; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm1 header.b=UBevHcV7; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-574b4aafe61si11596973a12.346.2024.05.21.05.33.53; Tue, 21 May 2024 05:33:55 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm2 header.b="eRVT0R/L"; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm1 header.b=UBevHcV7; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3299568D38D; Tue, 21 May 2024 15:33:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from wfout4-smtp.messagingengine.com (wfout4-smtp.messagingengine.com [64.147.123.147]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5122A68CF59 for ; Tue, 21 May 2024 15:33:44 +0300 (EEST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.west.internal (Postfix) with ESMTP id 4DD6A1C000E9 for ; Tue, 21 May 2024 08:33:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Tue, 21 May 2024 08:33:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itanimul.li; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm2; t=1716294821; x= 1716381221; bh=TMp3Vh86mKmSaWMZ/oVzAKvR4rRmpLPNIxauxYDRzdI=; b=e RVT0R/LhEc0mwuzUUUCbmyklwh0SBYhRndSfNHMyYfp0wxeqi18hx5xc0AEr9Swf PDySZImIc+rw+vkBXXymvrXjvgswPtqlmspg7jhViRZ6PIQZUsfIWTeGFhjPsGQm JusUqvJRXY/M+Y7OzozUB1XSDPLaBRgcbeqgVi0FQTG2F0TKkFDgqRIhP/WXvsYK udMpoNMqN8VL8OD5NILINOmBF+B2rCp9lk5I20ifk0C06h4O0SEoNu/tQaMM/iNU NWzWBoqrbq9N1brwgdnlviWPyNWQwlldLhTTYckU5pFTGPxS+wlAtAKjucmSLMxZ Ko+bjKOcxbw0Qg4ahEoYQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1716294821; x=1716381221; bh=TMp3Vh86mKmSa WMZ/oVzAKvR4rRmpLPNIxauxYDRzdI=; b=UBevHcV7RGGmlyqsu24L/+Iuw2SPj W9UJBfP3+19MmpISPyv3O1Uildd08g7M8mBiYUU+9ml/xS0A78BG4GQVQEfWqSHp 8rrdGGZmqu1UDEZX8LnEh4eEBYFSs/tQf058FpuiW1d6GIHZsew9KQxIAwmfrVZA cz6auhs5h/19bbyTd6zOfr6HJNdVN1UpSzAVTxL5sJlN+vnOvvFr+Kcitk2IUPav mM2uObyHXPJJVc/yUMDNyfuRzBGeIP+nhnoFL5RXhR0nYA/uaXXeEAKcK9tdK11m KbEie5afl+YXRndd5+9WEsWBhaia87xuHB0Dk04EhmiE7kNcV89aYVqog== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdeivddghedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomhepfdflrdcuffgvkhhkvghrfdcuoehjuggvkhesihhtrghnihhm uhhlrdhliheqnecuggftrfgrthhtvghrnhepgedvhfffuddugeehveeikeeifeefgfevff ektdehkeeifefhveeuteeufefhteetnecuvehluhhsthgvrhfuihiivgeptdenucfrrghr rghmpehmrghilhhfrhhomhepjhguvghksehithgrnhhimhhulhdrlhhi X-ME-Proxy: Feedback-ID: i84994747:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Tue, 21 May 2024 08:33:41 -0400 (EDT) From: "J. Dekker" To: ffmpeg-devel@ffmpeg.org Date: Tue, 21 May 2024 14:32:33 +0200 Message-ID: <20240521123338.29539-1-jdek@itanimul.li> X-Mailer: git-send-email 2.42.0 In-Reply-To: <12435148.O9o76ZdvQC@basile.remlab.net> References: <12435148.O9o76ZdvQC@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2] checkasm: add sample argument to adjust during bench X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: WvVWz/ste/8k 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 --- 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=] [--verbose] [seed]\n", + "Usage: %s [--bench] [--samples=] [--test=] [--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__);\