From patchwork Sat Jul 15 15:23:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 42737 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4376585pzb; Sat, 15 Jul 2023 08:24:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlFqI4hVqdd0MsW8UvwP0gF3jbtoMxZdSuFkf6NaYLOTf1WfYhjmlQ+qMSkSBTqTO1XDRJ3s X-Received: by 2002:a7b:cbc6:0:b0:3fc:70:2f76 with SMTP id n6-20020a7bcbc6000000b003fc00702f76mr6776411wmi.20.1689434678694; Sat, 15 Jul 2023 08:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689434678; cv=none; d=google.com; s=arc-20160816; b=LaFjY0CW70yllZKN4TVKnyT5Ah5m4stPY7et2Xam7VE3zkCKdwsiWGKvO6nl4UghkX 5qjZdw2G0HAzhn5UAMkZ294mff+w5htY00NEV5Wvrb14DVE0iyHjvcsa5GtneDfXQIs9 rUlckVRGYLNSOA+WSwnQ7lmjrCEB4OVZxrTg58g3OTq1rpklA0gEyTc5NNzZNMItwHoT uQyywV3wnTtynBQj20tuJXgyyCcQus05yvDZ8rV6JTaO/QQcORYjF+v8b+TGxFskAbq/ QYYoXF9nHl2bo2PDV6EwnXLcc7DLfdOoPwFARahC+kBZTCODbgQRAB7ja12h9aJceqMI 7sFQ== 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:delivered-to; bh=EdGJeyUEDp2ZRl53hXDfm4EDPNp0EBJ5nLP+qkhRYTU=; fh=hQcp50obTJ8bXC1it5NuEN23RGKfx0/zZ3s2gmreL+A=; b=iDLioixnoliZyvzuBwm88nt+jHxQ7W90IRxMR+kBWYz/rINcS9E6iVejdDlzHpJxsS Gg0iDLaj7aM6Sma1oo+4q9PkEkClgdFw9rqbLfHlK+kFjBKagp3z4rpAz+UM33HXsbzO hzPxQejD0wh4eUbkYcbfLrkBmV5CeeslIek8apS7LuW3fSFeHGmNJkgfTk3QiT1OvJX/ ItxD+4e3PzySSm7JGg0l6sJFyC+lDo+T88TxRJ0olQMYbN1gmqDY0E9d+HgLk046D4a+ w/mYSqMxo0X1SIJEtx50pT57J8w7Qo/KNsYnh7Ab1yl7n7l+fuOZrhJ9LY6avwfqTsR9 CCSA== ARC-Authentication-Results: i=1; mx.google.com; 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 j25-20020a170906095900b009938899a3besi10755611ejd.211.2023.07.15.08.24.38; Sat, 15 Jul 2023 08:24:38 -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; 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 04B3968C69D; Sat, 15 Jul 2023 18:23:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E933368C699 for ; Sat, 15 Jul 2023 18:23:45 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 055A9C021A for ; Sat, 15 Jul 2023 18:23:40 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 15 Jul 2023 18:23:38 +0300 Message-Id: <20230715152339.13234-6-remi@remlab.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <2708777.0sFzvF9Jai@basile.remlab.net> References: <2708777.0sFzvF9Jai@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/7] checkasm: allow run-time fallback to AV_READ_TIME 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: oA1KLYXuZPVh On Linux RISC-V, depending on kernel version and configuration, the cycle counters may be available: - via Linux perf (as on Arm), - directly with RDCYCLE (which is considered legacy), - neither (if admistratively disabled), or - or both (in legacy compatibility mode). This allows to try Linux perf, with a fallback to RDCYCLE. Without this, bench will stop working in upcoming kernel releases. --- tests/checkasm/checkasm.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 2e327de3a4..ad2dc9ab5a 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -708,7 +708,8 @@ static int bench_init_linux(void) checkasm_bench_close = checkasm_bench_linux_perf_close; return 0; } -#elif CONFIG_MACOS_KPERF +#endif +#if CONFIG_MACOS_KPERF static int bench_init_kperf(void) { ff_kperf_init(); @@ -727,25 +728,27 @@ static int bench_init_ffmpeg(void) checkasm_bench_start = checkasm_bench_stop = ff_read_time; return 0; } -#else -static int bench_init_ffmpeg(void) -{ - fprintf(stderr, "checkasm: --bench is not supported on your system\n"); - return -1; -} #endif static int bench_init(void) { + int ret = -1; #if CONFIG_LINUX_PERF - int ret = bench_init_linux(); -#elif CONFIG_MACOS_KPERF - int ret = bench_init_kperf(); -#else - int ret = bench_init_ffmpeg(); + if (ret < 0) + ret = bench_init_linux(); +#endif +#if CONFIG_MACOS_KPERF + if (ret < 0) + ret = bench_init_kperf(); #endif +#ifdef AV_READ_TIME if (ret < 0) - return ret; + ret = bench_init_ffmpeg(); +#endif + if (ret < 0) { + fputs("checkasm: --bench is not supported on your system\n", stderr); + return -1; + } state.nop_time = measure_nop_time(); printf("nop: %d.%d\n", state.nop_time/10, state.nop_time%10);