From patchwork Fri Jul 14 18:28:34 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: 42687 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp3863687pzb; Fri, 14 Jul 2023 11:29:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlFkKDxY6XC42jgGF/Ck4eLcpzuyvjsqczSA+2e+0SNdiFCznJk0LYzZIMerbavJCgng8ApH X-Received: by 2002:aa7:df04:0:b0:519:b784:b157 with SMTP id c4-20020aa7df04000000b00519b784b157mr4692164edy.12.1689359375288; Fri, 14 Jul 2023 11:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689359375; cv=none; d=google.com; s=arc-20160816; b=gkqIW14RRjt7cSZ3Tlu792FaZLnGp8iA9cAHZCGPLMOSaI0xL33BXecAQnZ46Tz3Bv 30tbKaHKUIViivGGupjlyU6O1tELqc3VWyhbL6U+IumOD2NtoEeIa8P69SdflJqal9s3 P+FZXb1gDJsKWtv5AzOXWmV308UHzxmimrET4BPvzAlgbsA387cj1q+0Dzn0piDr0pSk sc2V6pyrDIoFaGhBCj71tep6wpQrYwfookNuktriQAhj9ITqFo1j9nlee3Td1LeWATXI OfPvFEOaCk+oBuNXlC+21rh8Gapzb9HV+ZAaTpplJkkm54xusycXdr/zHktBlkXwocX8 fHzw== 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=hO/pdb7sp/oubN68WfYk11BX0f/uU9ngn6LW27ipgrQ=; fh=hQcp50obTJ8bXC1it5NuEN23RGKfx0/zZ3s2gmreL+A=; b=by9aq6cQg8R1riXyQCmHe/V1sNmjUP870rE2al7YitwA4Fk5HSr6oQya+rD67PdIiV QM0yNXTW1AT7N5E8Y+zTfJhNhD0k4ZRTWNgCHLcFc1z6Ac+1PeZ64vnqU3bzkBYo0Pwx WI6VJHG3snRzcDTI6LkEkL2iBVGU1l/KQ9GP6Sfpq6390cQ4zaK717e04MwrMYDikcQi Q8drN912dIGUHLLxLaRc93GAfwFsZdasa7uym2UpvwqJED4GltWTvu3LqCVGQqNemtQy 7VqurpMyKqBdIq1FQKrMiYAu9EYP3+0nxF3HQkm13ZGSic4OjVHGYwteyKtALFJzwxup Omhg== 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 v22-20020aa7d656000000b0051ff1fb2631si3080092edr.416.2023.07.14.11.29.34; Fri, 14 Jul 2023 11:29:35 -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 3F11B68C4CE; Fri, 14 Jul 2023 21:28:50 +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 4CACB68C678 for ; Fri, 14 Jul 2023 21:28:41 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 9383AC021A for ; Fri, 14 Jul 2023 21:28:36 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 Jul 2023 21:28:34 +0300 Message-Id: <20230714182835.66326-6-remi@remlab.net> X-Mailer: git-send-email 2.40.1 In-Reply-To: <12243004.O9o76ZdvQC@basile.remlab.net> References: <12243004.O9o76ZdvQC@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: UMSeVBQeTjTs 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 c3075fe37c..d72850f076 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -701,7 +701,8 @@ static int bench_init_linux(void) checkasm_bench_stop = checkasm_bench_linux_perf_stop; return 0; } -#elif CONFIG_MACOS_KPERF +#endif +#if CONFIG_MACOS_KPERF static int bench_init_kperf(void) { ff_kperf_init(); @@ -720,25 +721,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);