From patchwork Sat Jul 15 15:23:33 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: 42738 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4376151pzb; Sat, 15 Jul 2023 08:23:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlEvz1cVitsPLUNaYD7MKMqXOprEaNRyVyty1rnuKkLvctidWGZeUQmKSjm3fp+l8u9FS4rE X-Received: by 2002:a17:906:256:b0:993:fe68:569c with SMTP id 22-20020a170906025600b00993fe68569cmr7462447ejl.6.1689434629671; Sat, 15 Jul 2023 08:23:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689434629; cv=none; d=google.com; s=arc-20160816; b=WQbHwpEowFLPpE1TdST7ewkx6d5LWPkLDbPB6p/NId6H2E9QtbDT1ncJZXIrQjj6e/ hyYxuzjU3QSAE9MAl+7Zj7sLjPfPVvSsngFK/RpY1E6BDYcOwfM7tGMaXZkPLNlZRf43 +I0Ws3Dq1AaQxGpJY2EHCAyKGCaGeaxsIdnPtuVmp5g+O0Z8N+XjAaX0AU8IbHcmkiHx BmIhEYnq8SRunP2OeEhfQ/DDreviuTppNm0X7xFcKDqQTGBz7/keS8fTlHBWAoaZBpcb DQGjrNpyZ6sQn+zxnERS8/90Xnp/HwJ4MOLRC9XKol+/yG1qhXvpHLyCf5fDOIOzq+Hz k4Ag== 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=XwZIgAs8GL/AkPyVTQQbKRoGWMkVhNoiMq0nSQDsNFw=; fh=hQcp50obTJ8bXC1it5NuEN23RGKfx0/zZ3s2gmreL+A=; b=m3l+8rvMfNSzvxfddaSPe7JoGTaakGqk/HqVu3uY4z7ZxNiQcDMxiyqRJL0GTD02Q2 Hc8wXN6o/wWkpmNghJ/j2VqHk3GOpul3y8rVqNZZOaXVskq47mhIVeL+ZcOCtf5i05iU SDdMxfH8EsqBPzfnqQoJyIvh4ZdEroNT3QkXqble/dEo9xhXECTvPe1ysk+p3IDYcC/x w5q+V8M+Igz3Hc7zgp6CeZ5a7QtLWvLSUVttnYugJqdwGadC3TSPfFetlEpQxkiWj36j Y3Vg8RR0Vx/AGNbPX5WvY18JpjX5zO3oqi529F73rbHJg8GoNMPyPfDj6NvkHKKaeSMg VklA== 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 lz5-20020a170906fb0500b00993b3881ed2si9718556ejb.686.2023.07.15.08.23.49; Sat, 15 Jul 2023 08:23:49 -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 D7ECE68C657; Sat, 15 Jul 2023 18:23:46 +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 8C71E68C1FF for ; Sat, 15 Jul 2023 18:23:40 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 03675C0010 for ; Sat, 15 Jul 2023 18:23:39 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 15 Jul 2023 18:23:33 +0300 Message-Id: <20230715152339.13234-1-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 1/7] checkasm: improve Linux perf error message 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: IZGSNA9IEgay Report the failing system call name, as is convention, rather than just a rather unhelpful "syscall". --- tests/checkasm/checkasm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 4311a8ffcb..8702c9a30a 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -666,7 +666,7 @@ static int bench_init_linux(void) state.sysfd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0); if (state.sysfd == -1) { - perror("syscall"); + perror("perf_event_open"); return -1; } return 0; From patchwork Sat Jul 15 15:23: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: 42739 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4376237pzb; Sat, 15 Jul 2023 08:23:57 -0700 (PDT) X-Google-Smtp-Source: APBJJlEjn6Tg8rVuZekAd05f4TM2T0ZHzeIFppbxSEJ20/lT2sTKZ61bUVXVcopE2bvu/riELdk7 X-Received: by 2002:a17:907:9252:b0:978:a555:9bde with SMTP id kb18-20020a170907925200b00978a5559bdemr6219361ejb.59.1689434637699; Sat, 15 Jul 2023 08:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689434637; cv=none; d=google.com; s=arc-20160816; b=jy6LlG7JLoOn6Q9Fo1GIonJR250XifuX2hfnclhE7IR/2Vgs6LtnKTjQ3qMUCng38G asCbGwCyP2vNfytf2ZXq9yiEDYlcmr3V+GmxR1DJZ3Mu6zHjRxmDoMhGX3f6E/W63wfz QWyjmFGTfIK+1ooZ6d3j/gE6Sh9GlbKP4tJLg4sy9ym95vIDAoX2N0qyB6yj6WWtbkWJ k1dWAnwNbS7awr0HCsH3Vj8GKrp6YHvkRQaagttyWvucjjqmVCkP0zWAncar+oSn0Wxq GhkF9I4B5uAMNAuZ95OXsG7JYtuCipYAq9GbJIF46w7XqasZxQ7TXrUHyF8TJW/HPIxe 087w== 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=wfDu/UA8vUFFpA045MTYqEuGW0ALbipkDj/Y1W1ffj0=; fh=hQcp50obTJ8bXC1it5NuEN23RGKfx0/zZ3s2gmreL+A=; b=baxdZeb87XyYgACTkhWlnhKRPJa0SLkziILRS3A5ZKdygB5Z+Ka5oHmqT+8Bgf3yzJ cTKPesC7lqcoRXXfbUhwPEJUM2dxQ2Mjmm8HcbSYuK/xAUlBj2fZQ+OI1ungitvVRYOY Lee+AZ6hJV235pJPP3a4BP+nYPcr92FG2vmvzJPNwqIIlRPdEg+wOxaY2GyKgiZzw3Hu 31QvjhGfsGNo8EMGv3c/6ve00FZY9o7hgq7l8rV7zKyJtn4YUqGPiwcGF+3Roe2CoK37 aNv1nJgWoFwlWEuLqQTHyHS/5azbyyP2E243XBG/NU9fjdavZp2zLrovERXai/vcXQ/P 5UYA== 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 p6-20020a170906614600b00993686e193csi10991602ejl.53.2023.07.15.08.23.57; Sat, 15 Jul 2023 08:23:57 -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 C132768C675; Sat, 15 Jul 2023 18:23:47 +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 A274768C2C7 for ; Sat, 15 Jul 2023 18:23:40 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 385E3C0017 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:34 +0300 Message-Id: <20230715152339.13234-2-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 2/7] checkasm: make perf macros functional 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: T61Gg4bv0vYn This converts the bench/perf start/stop macros into functional macros, and for that to work, take the Linux perf code out of line. --- tests/checkasm/checkasm.c | 24 ++++++++++++++++++++---- tests/checkasm/checkasm.h | 36 +++++++++++++----------------------- 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 8702c9a30a..d8f571f301 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -513,11 +513,9 @@ static int measure_nop_time(void) int i, nop_sum = 0; av_unused const int sysfd = state.sysfd; - uint64_t t = 0; for (i = 0; i < 10000; i++) { - PERF_START(t); - PERF_STOP(t); - nops[i] = t; + uint64_t t = checkasm_bench_start(); + nops[i] = checkasm_bench_stop() - t; } qsort(nops, 10000, sizeof(uint16_t), cmp_nop); @@ -651,6 +649,24 @@ static void print_cpu_name(void) } #if CONFIG_LINUX_PERF +uint64_t checkasm_bench_linux_perf_start(void) +{ + int fd = state.sysfd; + + ioctl(fd, PERF_EVENT_IOC_RESET, 0); + ioctl(fd, PERF_EVENT_IOC_ENABLE, 0); + return 0; +} + +uint64_t checkasm_bench_linux_perf_stop(void) +{ + uint64_t t; + int fd = state.sysfd; + + ioctl(fd, PERF_EVENT_IOC_DISABLE, 0); + return (read(fd, &t, sizeof(t)) == sizeof (t)) ? t : 0; +} + static int bench_init_linux(void) { struct perf_event_attr attr = { diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 117d4dd35c..8a62b98f3e 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -238,25 +238,20 @@ typedef struct CheckasmPerf { int iterations; } CheckasmPerf; -#if defined(AV_READ_TIME) || CONFIG_LINUX_PERF || CONFIG_MACOS_KPERF - #if CONFIG_LINUX_PERF -#define PERF_START(t) do { \ - ioctl(sysfd, PERF_EVENT_IOC_RESET, 0); \ - ioctl(sysfd, PERF_EVENT_IOC_ENABLE, 0); \ -} while (0) -#define PERF_STOP(t) do { \ - int ret; \ - ioctl(sysfd, PERF_EVENT_IOC_DISABLE, 0); \ - ret = read(sysfd, &t, sizeof(t)); \ - (void)ret; \ -} while (0) +uint64_t checkasm_bench_linux_perf_start(void); +uint64_t checkasm_bench_linux_perf_stop(void); +#define checkasm_bench_start() checkasm_bench_linux_perf_start() +#define checkasm_bench_stop() checkasm_bench_linux_perf_stop() #elif CONFIG_MACOS_KPERF -#define PERF_START(t) t = ff_kperf_cycles() -#define PERF_STOP(t) t = ff_kperf_cycles() - t +#define checkasm_bench_start() ff_kperf_cycles() +#define checkasm_bench_stop() ff_kperf_cycles() +#elif defined (AV_READ_TIME) +#define checkasm_bench_start() AV_READ_TIME() +#define checkasm_bench_stop() AV_READ_TIME() #else -#define PERF_START(t) t = AV_READ_TIME() -#define PERF_STOP(t) t = AV_READ_TIME() - t +#define checkasm_bench_start() UINT64_C(0) +#define checkasm_bench_stop() UINT64_C(0) #endif /* Benchmark the function */ @@ -270,12 +265,12 @@ typedef struct CheckasmPerf { int ti, tcount = 0;\ uint64_t t = 0; \ for (ti = 0; ti < BENCH_RUNS; ti++) {\ - PERF_START(t);\ + t = checkasm_bench_start(); \ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ - PERF_STOP(t);\ + t = checkasm_bench_stop() - t;\ if (t*tcount <= tsum*4 && ti > 0) {\ tsum += t;\ tcount++;\ @@ -286,11 +281,6 @@ typedef struct CheckasmPerf { perf->iterations++;\ }\ } while (0) -#else -#define bench_new(...) while(0) -#define PERF_START(t) while(0) -#define PERF_STOP(t) while(0) -#endif #define DECL_CHECKASM_CHECK_FUNC(type) \ int checkasm_check_##type(const char *const file, const int line, \ From patchwork Sat Jul 15 15:23:35 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: 42740 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4376321pzb; Sat, 15 Jul 2023 08:24:06 -0700 (PDT) X-Google-Smtp-Source: APBJJlGqJM3PDivr8mfj6OLKFXFtyx19cnAu8KmthG82lxr4ZgcbhJzQ5OWWTdz0XoTa3/zbJd8V X-Received: by 2002:a05:600c:da:b0:3f7:f584:5796 with SMTP id u26-20020a05600c00da00b003f7f5845796mr7249755wmm.2.1689434646421; Sat, 15 Jul 2023 08:24:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689434646; cv=none; d=google.com; s=arc-20160816; b=E4WLbCxaFdGrVsCau5wo7M9X/MlCiEtQQnuuD76ULv8LyxVLyg3J4879WKeXWjWqm4 gAeXaVrRnhoeuXo15/sSOhQ4k4toIAracKJBzSbfiAOl8cnZj6i46JG+hw+TwrJaSfIa bEjD25w/fq+b7uq0iVnzP5r3LpWCrXExNp6RXQevhPOrNORluFu6yKAj/S5LdTagk7fn cqqrEgP10OEP3ViDxTPiORa//knyP89RRKsodW3qhTcI8FC75jHbNKaXRKppKouzEcaY FgnZpH0pSir6B1n8yv9u3TeydYdD4P1lAxKXJRMOBIfpyOxVZdB2ppqnCia8l3pt3heY vWug== 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=XcVMEWnRCIk6mHyTBKblHUf2AM0TYGLDknZQ+AfK2NE=; fh=hQcp50obTJ8bXC1it5NuEN23RGKfx0/zZ3s2gmreL+A=; b=OKt7ALF2WViSj0gkIh0M1LDzg4scS+y4764b6aQCfPEpuKEbMRS1Elo9kKtZ9km3xx Bt0B97JMShwtPjQCw4jqiKJXv9sgBev/BmeDrmiTv+/f++dYzzSXH7vRJS9f4KsVP40U FO/zfzr3CibHnlpLcv8XG0cdB0x5DkKcgHMCPl+E8UQiuv5xMA3bwXjfAmQ4j1H30Bdx ykFDxXv6lHElMgzQ21MgxhpQqSitbKUQvwkPksry7BIABv6diwIsMmIJLZshAv1/xU+G u7VDJe+HhmGyvfZTKvzPoWMmxjWjF0b2ze3HnDyHDtzPYiyKX+acVl812ILuibl0GVOe iPPg== 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 ox29-20020a170907101d00b00988f21df36esi2986763ejb.594.2023.07.15.08.24.05; Sat, 15 Jul 2023 08:24:06 -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 9EE0368C1FF; Sat, 15 Jul 2023 18:23:48 +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 D7D0868C2C7 for ; Sat, 15 Jul 2023 18:23:40 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 6DCC2C0217 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:35 +0300 Message-Id: <20230715152339.13234-3-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 3/7] checkasm: use pointers for start/stop functions 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: MA1WqidvmrRN This makes all calls to the bench start and stop functions via function pointers. While the primary goal is to support run-time selection of the performance measurement back-end in later commits, this has the side benefit of containing platform dependencies in to checkasm.c and out of checkasm.h. --- tests/checkasm/checkasm.c | 33 ++++++++++++++++++++++++++++----- tests/checkasm/checkasm.h | 33 ++++++--------------------------- 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index d8f571f301..e921257257 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -57,6 +57,14 @@ #if HAVE_UNISTD_H #include #endif +#if CONFIG_LINUX_PERF +#include +#include +#include +#endif +#if CONFIG_MACOS_KPERF +#include "libavutil/macos_kperf.h" +#endif #if !HAVE_ISATTY #define isatty(fd) 1 @@ -506,6 +514,9 @@ static int cmp_nop(const void *a, const void *b) return *(const uint16_t*)a - *(const uint16_t*)b; } +static uint64_t (*checkasm_bench_start)(void); +static uint64_t (*checkasm_bench_stop)(void); + /* Measure the overhead of the timing code (in decicycles) */ static int measure_nop_time(void) { @@ -649,7 +660,7 @@ static void print_cpu_name(void) } #if CONFIG_LINUX_PERF -uint64_t checkasm_bench_linux_perf_start(void) +static uint64_t checkasm_bench_linux_perf_start(void) { int fd = state.sysfd; @@ -658,7 +669,7 @@ uint64_t checkasm_bench_linux_perf_start(void) return 0; } -uint64_t checkasm_bench_linux_perf_stop(void) +static uint64_t checkasm_bench_linux_perf_stop(void) { uint64_t t; int fd = state.sysfd; @@ -685,24 +696,34 @@ static int bench_init_linux(void) perror("perf_event_open"); return -1; } + checkasm_bench_start = checkasm_bench_linux_perf_start; + checkasm_bench_stop = checkasm_bench_linux_perf_stop; return 0; } #elif CONFIG_MACOS_KPERF static int bench_init_kperf(void) { ff_kperf_init(); + checkasm_bench_start = checkasm_bench_stop = ff_kperf_cycles; return 0; } -#else +#elif defined (AV_READ_TIME) +static uint64_t ff_read_time(void) +{ + return AV_READ_TIME(); +} + static int bench_init_ffmpeg(void) { -#ifdef AV_READ_TIME printf("benchmarking with native FFmpeg timers\n"); + 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 } #endif @@ -869,6 +890,8 @@ CheckasmPerf *checkasm_get_perf_context(void) CheckasmPerf *perf = &state.current_func_ver->perf; memset(perf, 0, sizeof(*perf)); perf->sysfd = state.sysfd; + perf->start = checkasm_bench_start; + perf->stop = checkasm_bench_start; return perf; } diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 8a62b98f3e..8f966f49af 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -26,15 +26,6 @@ #include #include "config.h" -#if CONFIG_LINUX_PERF -#include // read(3) -#include -#include -#include -#elif CONFIG_MACOS_KPERF -#include "libavutil/macos_kperf.h" -#endif - #include "libavutil/avstring.h" #include "libavutil/cpu.h" #include "libavutil/internal.h" @@ -236,41 +227,29 @@ typedef struct CheckasmPerf { int sysfd; uint64_t cycles; int iterations; + uint64_t (*start)(void); + uint64_t (*stop)(void); } CheckasmPerf; -#if CONFIG_LINUX_PERF -uint64_t checkasm_bench_linux_perf_start(void); -uint64_t checkasm_bench_linux_perf_stop(void); -#define checkasm_bench_start() checkasm_bench_linux_perf_start() -#define checkasm_bench_stop() checkasm_bench_linux_perf_stop() -#elif CONFIG_MACOS_KPERF -#define checkasm_bench_start() ff_kperf_cycles() -#define checkasm_bench_stop() ff_kperf_cycles() -#elif defined (AV_READ_TIME) -#define checkasm_bench_start() AV_READ_TIME() -#define checkasm_bench_stop() AV_READ_TIME() -#else -#define checkasm_bench_start() UINT64_C(0) -#define checkasm_bench_stop() UINT64_C(0) -#endif - /* Benchmark the function */ #define bench_new(...)\ do {\ if (checkasm_bench_func()) {\ struct CheckasmPerf *perf = checkasm_get_perf_context();\ av_unused const int sysfd = perf->sysfd;\ + uint64_t (*const start)(void) = perf->start;\ + uint64_t (*const stop)(void) = perf->stop;\ func_type *tfunc = func_new;\ uint64_t tsum = 0;\ int ti, tcount = 0;\ uint64_t t = 0; \ for (ti = 0; ti < BENCH_RUNS; ti++) {\ - t = checkasm_bench_start(); \ + t = start(); \ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ tfunc(__VA_ARGS__);\ - t = checkasm_bench_stop() - t;\ + t = stop() - t;\ if (t*tcount <= tsum*4 && ti > 0) {\ tsum += t;\ tcount++;\ From patchwork Sat Jul 15 15:23:36 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: 42741 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4376383pzb; Sat, 15 Jul 2023 08:24:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlHKR0QY2uU0V+2IKICa0ZAfhXeBMuw83+JvtJZ87F+ErX0liWUl8eJQngrheUixGfrUxgbx X-Received: by 2002:a17:907:1a58:b0:992:c40e:3c17 with SMTP id mf24-20020a1709071a5800b00992c40e3c17mr5859453ejc.75.1689434654300; Sat, 15 Jul 2023 08:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689434654; cv=none; d=google.com; s=arc-20160816; b=a5lisiFgy97haDyan6hm8SqX9JEDU5j2Cr5+s/GyDpmAzEV+ivHXYkA9l6yjC7FgX5 dU2RNQMPLG6ejwXjmZO/cU4Usqp1RIQJ66znbl11zdjKOhZwkZZSoPiBBmVEyEjeCWv4 mAcOpiPmwxPEgMjhC1CJx7EoM2BKPgHe9hPxt8TgQiKEHJIocd8l6AvUbkr4svXmJsuX VDHCoq8zH2pZHao6iCLWs94g9W3/jv5OhwR0Gu9a0ZuwAfvDzIsE/1qLfnSIqMJ9Vana RuJtonhQ913QGir0JSN9mxaAii3n6Pyl/HlrBrm9oxIDJyMeRkpXvcbES9588cS0xF+8 56Aw== 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=phARcAQz+pd6/830LYVA23+7mAMyjUlhDNXQHo15CMw=; fh=hQcp50obTJ8bXC1it5NuEN23RGKfx0/zZ3s2gmreL+A=; b=xedbgR4KPA+gi73DiNXVetLdui6WONXk7KvIqpekSkzZmu5pn0jy9F4dIDU//6BrA2 Y9q+HejAXVYHYG3dEJkTuB5ReCjvaFhb2leQq7q5X1mJq7W6/cAPk9BAZ0J4hTj6A3C6 uub6tmPoK6jpDb9np8vuUGAyyY3nwz+R13xNI7t0R8O+wOFmEW4UWSDYo2NL9BWtnUOy aq95xoUDnTQYkXgOc/bg1+m0X42L/JxiDPEK3EX0SX4IiQs1R30ApLKBYCJDqFAVbbCE e1kqOKj/x4EVa3fDk/tskr6XLy2Lx+nkqti3HglEN4Gv7QK5xaCGVVRv3uS6hWMutsl2 v41Q== 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 j23-20020a17090686d700b009888665e53fsi10815459ejy.190.2023.07.15.08.24.13; Sat, 15 Jul 2023 08:24:14 -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 8E95568C683; Sat, 15 Jul 2023 18:23:49 +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 15F3B68C2C7 for ; Sat, 15 Jul 2023 18:23:41 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id A33A2C0218 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:36 +0300 Message-Id: <20230715152339.13234-4-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 4/7] checkasm: remove unused variables 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: MYUalKJ0kHti --- tests/checkasm/checkasm.c | 2 -- tests/checkasm/checkasm.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index e921257257..c90f361ff7 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -522,7 +522,6 @@ static int measure_nop_time(void) { uint16_t nops[10000]; int i, nop_sum = 0; - av_unused const int sysfd = state.sysfd; for (i = 0; i < 10000; i++) { uint64_t t = checkasm_bench_start(); @@ -889,7 +888,6 @@ CheckasmPerf *checkasm_get_perf_context(void) { CheckasmPerf *perf = &state.current_func_ver->perf; memset(perf, 0, sizeof(*perf)); - perf->sysfd = state.sysfd; perf->start = checkasm_bench_start; perf->stop = checkasm_bench_start; return perf; diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 8f966f49af..6a3f826a7f 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -224,7 +224,6 @@ void *checkasm_get_wrapper(void); #endif typedef struct CheckasmPerf { - int sysfd; uint64_t cycles; int iterations; uint64_t (*start)(void); @@ -236,7 +235,6 @@ typedef struct CheckasmPerf { do {\ if (checkasm_bench_func()) {\ struct CheckasmPerf *perf = checkasm_get_perf_context();\ - av_unused const int sysfd = perf->sysfd;\ uint64_t (*const start)(void) = perf->start;\ uint64_t (*const stop)(void) = perf->stop;\ func_type *tfunc = func_new;\ From patchwork Sat Jul 15 15:23:37 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: 42743 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4376520pzb; Sat, 15 Jul 2023 08:24:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlH8Imcy8vjpw5PblnDlEFobCh/+JU44IJ4J2ttECHd56U+N8uIJ0Ex5Doxj0RQh9mg/GFZu X-Received: by 2002:a17:906:314c:b0:957:1df0:9cbf with SMTP id e12-20020a170906314c00b009571df09cbfmr5494121eje.19.1689434671062; Sat, 15 Jul 2023 08:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689434671; cv=none; d=google.com; s=arc-20160816; b=Jj6igt3TBTwY9plDREJPeTLdXwnLWAMeyRRkMV4vHHU8QdB7HtuZOx27THQD83IV0r W2C3OirvNnx6ZHBwmrwTqT5Epv784xRXVPI3ZZl178kaUUWSqzyjFk1oD0m8mocHEP4G IKu5aqbWFHYkN7K5bjHyY25XoU6+qTmDbNmLS7ISUXJhG8npd7X5hwAr2cf80MXlA0Yy wcYPnKqZa4E84T/ASEfUYxgYVSqS7rwlOlZ+2N2MvPxS0yazOCWwrxGhAdjp/NxxUzjh tMG8/4gbfJ4ylmEHvhiTjQpq+hkztiXgWymWEr4cAAmCZz5Wvq0S9RlAwcN4dTPT4uaa 2WxQ== 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=Q/Pg71dHWPweodnhA9rg1CQL2YkQROQFKmWu9ZC5cz8=; fh=hQcp50obTJ8bXC1it5NuEN23RGKfx0/zZ3s2gmreL+A=; b=QHRALjqRSjx+fCT58rRBHe45O5B2bfiGGAL9FMGijd14SZH3jTEieJuehG2QJ635i7 AnFrLjk+ngF3XvN6tXmHD15xLO0XwqbdDFhgvH3F6ndFOvRJThCcNK+Y0LsWD14Z0209 Q5Q8KFQPQPuwRLGAp9Eq40DPSAXrCCG6ypQuJRy31cNBYiALYNOUZ/2FrarqgXGRiESH slds65PzYPws47PELlOOkBS2tgmTQK6aJeE8rzzP0YFE53H5CshIDcIzh3CRefXAhLqa O8ZrG03EK1vfT1hRPd9bs9RokWPMB8nBym+bqK8+pQU+IJjQG/hY4gQ6sIymAL7bQg1i 4ciw== 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 gx3-20020a170906f1c300b009827b36b8ffsi2241767ejb.718.2023.07.15.08.24.30; Sat, 15 Jul 2023 08:24:31 -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 EC48068C6A6; Sat, 15 Jul 2023 18:23:51 +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 3BFB468C2C7 for ; Sat, 15 Jul 2023 18:23:41 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id CE2AAC0219 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:37 +0300 Message-Id: <20230715152339.13234-5-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 5/7] checkasm: make bench clean-up also a function pointer 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: sAG/ajSu4Q5F Because we might as well at this point. This incidentally fixes a corner case bug that state.sys_fd == 0 could be either the initial value from .bss or a valid file descriptor (in which case it didn't get closed). --- tests/checkasm/checkasm.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index c90f361ff7..2e327de3a4 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -319,7 +319,9 @@ static struct { /* perf */ int nop_time; +#ifdef CONFIG_LINUX_PERF int sysfd; +#endif int cpu_flag; const char *cpu_flag_name; @@ -516,6 +518,7 @@ static int cmp_nop(const void *a, const void *b) static uint64_t (*checkasm_bench_start)(void); static uint64_t (*checkasm_bench_stop)(void); +static void (*checkasm_bench_close)(void); /* Measure the overhead of the timing code (in decicycles) */ static int measure_nop_time(void) @@ -677,6 +680,11 @@ static uint64_t checkasm_bench_linux_perf_stop(void) return (read(fd, &t, sizeof(t)) == sizeof (t)) ? t : 0; } +static void checkasm_bench_linux_perf_close(void) +{ + close(state.sysfd); +} + static int bench_init_linux(void) { struct perf_event_attr attr = { @@ -697,6 +705,7 @@ static int bench_init_linux(void) } checkasm_bench_start = checkasm_bench_linux_perf_start; checkasm_bench_stop = checkasm_bench_linux_perf_stop; + checkasm_bench_close = checkasm_bench_linux_perf_close; return 0; } #elif CONFIG_MACOS_KPERF @@ -743,14 +752,6 @@ static int bench_init(void) return 0; } -static void bench_uninit(void) -{ -#if CONFIG_LINUX_PERF - if (state.sysfd > 0) - close(state.sysfd); -#endif -} - int main(int argc, char *argv[]) { unsigned int seed = av_get_random_seed(); @@ -805,7 +806,8 @@ int main(int argc, char *argv[]) } destroy_func_tree(state.funcs); - bench_uninit(); + if (checkasm_bench_close != NULL) + checkasm_bench_close(); return ret; } 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); From patchwork Sat Jul 15 15:23:39 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: 42742 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp4376461pzb; Sat, 15 Jul 2023 08:24:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlHtqyUdaeLgYBzx2Ds+DE9KIRN5aZetBplSiWQ/+z+jvkb3qkQ0/zWh/jCsmzuDYlJeG3hM X-Received: by 2002:a17:906:7a53:b0:994:3207:cde3 with SMTP id i19-20020a1709067a5300b009943207cde3mr7433686ejo.49.1689434662744; Sat, 15 Jul 2023 08:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689434662; cv=none; d=google.com; s=arc-20160816; b=j1CK26JsZs1IDDZJiYczN7cEw6khIlqIxFderW0CS4GWr5JJ40vC9Ksu65ZRM+vL1X YwFPMD+GeyH13iU6D4E+hV4+UbD3anH+r7vrJzoS7iEKI13q9cnhradz4kpPxqUn6FJ+ EjAP16/LpZ3QLU2+B2ai3XOGz86Pnze5xTVS0b5L2GPrfE4WO1IDFodqLZFkK4gbOUTj +OxCMkk/hzw4ze5P2BMqfiZjtRRkQ3RdBV56qJQvsHukq8d8garKxd7c2JrAFBjTacoz j0HLpV++d32vvm4v+Czb0pe9Q0Id3VpkINEPABfwQlw6/1jLZInCUHWftUUCMVVzqteY e8mw== 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=HPQ24dS0ZCyrftpS1rve03+nLXjSs+0U91CjBifKcE4=; fh=hQcp50obTJ8bXC1it5NuEN23RGKfx0/zZ3s2gmreL+A=; b=qIJ1+eyKH0UAltC15TNWXLb5LemGxqIYivvYMPYjmgoG16s+q+EsmwwOAHzdPnaxVC 5wOTJwrz4EG7fw1BYe0ffAzQ4RTmpq/5nX3YILQdGIZFowEvZWmtijsGIbtwOAcJ/dbR w2RZt84blPAegTOYB7qWMzcHaS+LVEGcTSkKo4yhZfDu2z3hfrUSU3lJVY4J9BqnSyHG stPxHUwvxB8ISpWsv/xCnTmPpWss9ZfyJYfYy36/Dr0Hcoy3iHsfkb00eeKpH6cjNpQs q191bURiX7HNDKUDoiOp+gE8l0YCQmrNUcQrWpADEaKJO/mjJ1ULdyisXzA4hTFbLaV3 wEQQ== 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 um15-20020a170906cf8f00b009937e7c4e4fsi11295365ejb.80.2023.07.15.08.24.22; Sat, 15 Jul 2023 08:24:22 -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 835B268C294; Sat, 15 Jul 2023 18:23: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 3D1AB68C648 for ; Sat, 15 Jul 2023 18:23:46 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 39ECBC021B for ; Sat, 15 Jul 2023 18:23:41 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 15 Jul 2023 18:23:39 +0300 Message-Id: <20230715152339.13234-7-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 7/7] configure: enable Linux perf on RISC-V by default 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: 4edXIN7tLGpy Now that checkasm can automatically fall back to RDCYCLE, it is safe to enable this for forward compatibility with kernel versions mitigating the "Cycle Drift" side channel attack. Where available, this should also reduce measurement noise, since kernel and hypervisor cycles should no longer be counted. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 0ab0761011..3be074e15b 100755 --- a/configure +++ b/configure @@ -5754,7 +5754,7 @@ case $target_os in ;; linux) enable section_data_rel_ro - enabled_any arm aarch64 && enable_weak linux_perf + enabled_any arm aarch64 riscv && enable_weak linux_perf ;; irix*) target_os=irix