From patchwork Fri May 26 08:03:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 41832 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp1145005pzb; Fri, 26 May 2023 01:03:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6dOEvOgsqWMJ7xH9xYJGchWiFmiE9gDjO1Eir0FnDQ9bmQC2pLZ7KEyIjIs8UvhswtLZIm X-Received: by 2002:a17:907:7daa:b0:96f:d04c:1d84 with SMTP id oz42-20020a1709077daa00b0096fd04c1d84mr754369ejc.12.1685088210235; Fri, 26 May 2023 01:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685088210; cv=none; d=google.com; s=arc-20160816; b=lb0IZ1wuPZ6E2ApQvuT1g0QmusE8w7aMAJK4Ca0jt0X5TM6i9LeGmarVkxFY61ozft ewSbnXyBghbkwfBq1FbcqOlKFk8r98/ZFYtm9P9NHOluKQKWP3MWTIQjrc4ZIybAq+/2 Rh3VY7qjV+cNwPc6DReDdFEy8GPJeYJNlxY7tw6jUs+xoThvckqbN0CgLJ+/oL16G/uC ZkFJNVc8kakP2+043JpY/g37N2fbwwIZMli2vkiGfFnes9n7QWYfu3uy767WIFQdDA0a 5sPAfkxB0PEWNEWQipxpSY3lI8ALbwkIw+ADJUf55GmiKPAp86y5Wj9mHbIWyelY6gaq /CIw== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=SJgUB53rDJO7B9VfWbwO2ui9Rb47c6NHg8fW6qYU8C0=; b=QVSA6pHIxGeDgsbOQ2Gx7DUpvqWiOlm/jyh4JaFST6E2K3yReD04rSHPOCV8iLOpT3 BRTyr45StO7fjFlw2lFec7RIclYYzy4O8J12eY6nJ5oibwtufRWprsmy1g5W12kFyLOI msqwSTDCL5HMecQU8fppek2DFV8qMrX7tJ/SbCnzyjdfXPiQobpbayAbsM7jKnLcAPr+ sFyrY6Oyk81zBokjHG6TYWCE3beq93TEh0CWlTflKMQ+4WBF4UyaB72rGp844vLESoGx QZufRPTVckZbSQu3JDhymYfME95Md3Y4wfDpobOQtGjBZ47kwKfis6BHkdakVS758DUH crNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20221208.gappssmtp.com header.s=20221208 header.b=gqbRh9qN; 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 z13-20020a1709060acd00b009662223f515si405273ejf.665.2023.05.26.01.03.29; Fri, 26 May 2023 01:03:30 -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=@martin-st.20221208.gappssmtp.com header.s=20221208 header.b=gqbRh9qN; 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 729A168C07D; Fri, 26 May 2023 11:03:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6ECC468C091 for ; Fri, 26 May 2023 11:03:17 +0300 (EEST) Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-4f3a611b3ddso2269881e87.0 for ; Fri, 26 May 2023 01:03:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20221208.gappssmtp.com; s=20221208; t=1685088196; x=1687680196; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=acagDSYhdq7056Wg6SktGzB/auJImajSYlFtr1r6ZlQ=; b=gqbRh9qNOW2J4Ex63gMIT6jLFlfQPLj3gFy7K8lVvKotVCLQhno7DcPwC8cUM3e44n G8MnmMo2kdkjg5YSbEdq6eqsWRWCK2iKW7SpjlaviC5hkwp3P3l+dU27UmnCs+WrN7pS 0x3RlPRoIqeLiOuxjvjphWI6uExxzIvvLOsvSyzLBk6xjjlE+3WXTmW73l/wjmC2/AZc bpPl5PyZlwermUZNDZvQWvAwpGJK5FiqFEpr/RGhqxjCXwwZS8Cd1gb/Rdpxc9HEOH/+ vPA5QrXgzm9pZ/IsofkTM/BoQfxP0qISMDeCMw8xtXfpbZ/0IMeSUM29MAywtqybYJvp be5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685088196; x=1687680196; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=acagDSYhdq7056Wg6SktGzB/auJImajSYlFtr1r6ZlQ=; b=JcA2g0S4EvZVZ7DFdFkYb1qBHre15wZkfWU/TTGNq5lnoaJcMGEN9MY27ZeAaPybw2 6aQW9yA0UBIeAvmI/sMgQ3SARtF1sdo6RL3EjPCni3a5DlM3Q5KBf8A98wlY8pYBRx8/ e69b+goAZcWoAH25tBFNrm5gd7n0/KtNF11Z1HETKh16tHkqIIbjoAhnfAC9EiWhg2AO UoyisHOR7h0qDGSE6cP3K2+IXpxQ8uqgS3SM+V4FPFQqje6gfXtedNQXiM80S/WYUbaj uFXLf2nfnktg6Xjz67Cn+6gEkIUrF1sd6wvxdrYJ/CgkS5tLI9WZaKlfxVj0KRwiaA3H 3Uvg== X-Gm-Message-State: AC+VfDwJ1t15HwkgCsuGW5WRxSyofFMOWyTTBBuokI9M+2NYHiRKIveo YvCeHPUCegINMmJ64yOJi3WgMHnLPL0mKtPLki1wOw== X-Received: by 2002:ac2:446d:0:b0:4f3:b9c8:5da with SMTP id y13-20020ac2446d000000b004f3b9c805damr343203lfl.33.1685088196113; Fri, 26 May 2023 01:03:16 -0700 (PDT) Received: from localhost (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id u2-20020a056512040200b004f4c3feb9f1sm517251lfk.62.2023.05.26.01.03.15 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 26 May 2023 01:03:15 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 May 2023 11:03:12 +0300 Message-Id: <20230526080315.83424-1-martin@martin.st> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] configure: aarch64: Support assembling the dotprod and i8mm arch extensions 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: Bsbu8s+vaA8A These are available since ARMv8.4-a and ARMv8.6-a respectively, but can also be available optionally since ARMv8.2-a. Check if these are available for use unconditionally (e.g. if compiling with -march=armv8.6-a), or if they can be enabled with specific assembler directives. Use ".arch_extension " for enabling a specific extension in assembly; the same can also be achieved with ".arch armv8.2-a+", but with .arch_extension is easier to combine multiple separate features. Enabling these extensions requires setting a base architecture level of armv8.2-a with .arch. Don't add ".arch armv8.2-a" unless necessary; if the base level is high enough (which might unlock other extensions without .arch_extension), we don't want to lower it. Only add .arch/.arch_extension if needed, e.g. current clang fails to recognize the dotprod and i8mm features in .arch_extension, but can successfully assemble these instructions if part of the baseline set with -march. --- configure | 77 ++++++++++++++++++++++++++++++++++++++++- libavutil/aarch64/asm.S | 13 +++++++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 87f7afc2e1..3c7473efb2 100755 --- a/configure +++ b/configure @@ -454,6 +454,8 @@ Optimization options (experts only): --disable-armv6t2 disable armv6t2 optimizations --disable-vfp disable VFP optimizations --disable-neon disable NEON optimizations + --disable-dotprod disable DOTPROD optimizations + --disable-i8mm disable I8MM optimizations --disable-inline-asm disable use of inline assembly --disable-x86asm disable use of standalone x86 assembly --disable-mipsdsp disable MIPS DSP ASE R1 optimizations @@ -1154,6 +1156,41 @@ check_insn(){ check_as ${1}_external "$2" } +check_archext_insn(){ + log check_archext_insn "$@" + feature="$1" + base_arch="$2" + archext="$3" + instr="$4" + # Check if the assembly is accepted unconditionally in either inline or + # external assembly. + check_inline_asm ${feature}_inline "\"$instr\"" + check_as ${feature}_external "$instr" + + enabled_any ${feature}_inline ${feature}_external || disable ${feature} + + if disabled ${feature}_external; then + # If not accepted unconditionally, check if we can assemble it + # with a suitable .arch_extension directive. + test_as < X-Patchwork-Id: 41833 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp1145168pzb; Fri, 26 May 2023 01:03:43 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6pHEz41OudTRAzO0koezrEUwpLMMIk2pnlfAGWgablVTVA10LKULuITDz2aVnKmFBHvFqg X-Received: by 2002:a17:907:930b:b0:94e:ec32:ba28 with SMTP id bu11-20020a170907930b00b0094eec32ba28mr1368755ejc.29.1685088223541; Fri, 26 May 2023 01:03:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685088223; cv=none; d=google.com; s=arc-20160816; b=IiZ9n17gY6UPQXnWXXVKsbSPK42p7YFjVKA+IE7PzVE5S3BcteJY/Vxa1UySiRK7ld XMaIpnzqnBsVEXjqyOceXiHqW+XGLG3XrhKYvjkuVN0Az/aEItrXwvNyNyxn+c75PvmJ SU4YwVjKE+gsHQkt5hvDsE4neLfJV1jAJUUsjdzy+rAGbB+LG1uC91TBxLXXQqfGmWh2 kFcE6J0e2NRZBF7QZ2uuEOap33PEtSLm9g4YRMPIvI3jI0iJTs3K9LIRw/nbTAe/Kj/w rU0QaoZGhg3zt5B4qPNcrfUuAyKeeRjxakpMtPmiL1kdZIICMs7VBvb0Gu1lZaPaQjZ6 8NjQ== 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:dkim-signature:delivered-to; bh=Bqdf9YjS8Y3Flsudd0cIWA3sE4avETRNVcn3qkiN/gM=; b=E4S1u60i9pnYOlRnB7EIqSPK9R6mTFWBkGRIH9hpNBEKm0+Hi5TZv9k7DniM1TTEBN 5QfRqg1lum4awELrpQyQafqNVYcsnfOhUDC3XAg5l2DNbU1egkqA4jx/090eOojLSIL0 Gyf6WEqCBN7B79soqA8KMZpBCjjrQ4rctTdX+ODC/Zi+vZotcynG2PaHYFuOSETkKV+E ku8xydOend1sTG3iHwRyP8rTzr165MS1ufHOj3+IjWOx4dsafAkP5XIgzK6vl9XXv6Wx W1Ve5uSgZdAGQnpc+AN/bC64n0uAZnBJ/+Vgv5frwLTJ7R+BaHfOmo+POBQqZb+WmUEc QaMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20221208.gappssmtp.com header.s=20221208 header.b=0MmRd5gp; 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 m10-20020aa7c2ca000000b00510e67aa1ddsi302357edp.658.2023.05.26.01.03.43; Fri, 26 May 2023 01:03:43 -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=@martin-st.20221208.gappssmtp.com header.s=20221208 header.b=0MmRd5gp; 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 78C0768C1CE; Fri, 26 May 2023 11:03:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2B84268B9FF for ; Fri, 26 May 2023 11:03:18 +0300 (EEST) Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2af177f12a5so4245881fa.2 for ; Fri, 26 May 2023 01:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20221208.gappssmtp.com; s=20221208; t=1685088197; x=1687680197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=L8yRQJJKd4bFjDo1Bqo1/bAPWXkS8VpFRmkM1wXOFV0=; b=0MmRd5gpWQKG1RXILeSCOLzeSpPULfherLDNqs/huHX8V5HnNvKOlTgoOiOHZfD/6l Dx4RRGVKQY3uRTCfPU+CxC2ZRnParRZJgBI2XKyNtrdUPdWXKvOuR0k3CJ/jy4/yGYJ3 V2L4x6yaUNVQv5Ws+kbomFn5DJtYe9A1mr9VI6J0I7rzKLiwLXZDlMm/RAP6Wu/TYWQ6 DH/ScjJKNSjkIQyhZhjiKfWv5xcTpJVboj34g85hV3+A3IdBu7zOutl+yZbKAvutHb7K BbM55Eg9wpjaCCOD2/xu/bhQ4+22hE+CnOJkf12/xZJOUruQuPJ407w0XT5/vo8ibu1y eBXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685088197; x=1687680197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L8yRQJJKd4bFjDo1Bqo1/bAPWXkS8VpFRmkM1wXOFV0=; b=Rbk39C9xTcjBRMZYB3iEgYd3nOLMO42SYNbPNYOOear3i9bGt5qkkivTe1oSkl9t/t nI32DmrV2vtem3XUuOS/ZETR3iCZDHBpB7Dg3o9ocajDBpMTMN3PzgsuxV5YZPKM8pi/ /i9QPSJ7qAVo8XG2wv0Zx/fQEqZXtIaRZk1Ks1MCZiSj/PrSYOk0Csi0cnPmACb9KgFu beGc0gqG4ROmQrwAcyOmDnMz7dBq8pJoMkjV47PuAfzVWzT9C1jPgqk5YWzcY/OINfmr S5DgnLQBqbYBoi0Hp14O6Zn+sztTeG+NOXXvnaIWsXnHAZkQcLQNu2rqg/poGD4GWB/S Ey7Q== X-Gm-Message-State: AC+VfDw5oJ2mXMPQ3cA+MF8+DsUZAWux5uyL7HKotCmkFU5BfL8ztzXC MFgVYV9JV7IEEsMgIB/510k5Yuaa/I+jQmEP7hA0qQ== X-Received: by 2002:a2e:7806:0:b0:2a8:eae2:d563 with SMTP id t6-20020a2e7806000000b002a8eae2d563mr523547ljc.53.1685088196837; Fri, 26 May 2023 01:03:16 -0700 (PDT) Received: from localhost (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id m25-20020a2e97d9000000b002a8b9570403sm602505ljj.31.2023.05.26.01.03.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 26 May 2023 01:03:16 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 May 2023 11:03:13 +0300 Message-Id: <20230526080315.83424-2-martin@martin.st> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230526080315.83424-1-martin@martin.st> References: <20230526080315.83424-1-martin@martin.st> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] aarch64: Add cpu flags for the dotprod and i8mm extensions 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: eKa3TkB7HuzC Set these available if they are available unconditionally for the compiler. --- libavutil/aarch64/cpu.c | 15 ++++++++++++--- libavutil/aarch64/cpu.h | 2 ++ libavutil/cpu.c | 2 ++ libavutil/cpu.h | 2 ++ libavutil/tests/cpu.c | 2 ++ tests/checkasm/checkasm.c | 2 ++ 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c index cc641da576..42b33e4a2d 100644 --- a/libavutil/aarch64/cpu.c +++ b/libavutil/aarch64/cpu.c @@ -22,9 +22,18 @@ int ff_get_cpu_flags_aarch64(void) { - return AV_CPU_FLAG_ARMV8 * HAVE_ARMV8 | - AV_CPU_FLAG_NEON * HAVE_NEON | - AV_CPU_FLAG_VFP * HAVE_VFP; + int flags = AV_CPU_FLAG_ARMV8 * HAVE_ARMV8 | + AV_CPU_FLAG_NEON * HAVE_NEON | + AV_CPU_FLAG_VFP * HAVE_VFP; + +#ifdef __ARM_FEATURE_DOTPROD + flags |= AV_CPU_FLAG_DOTPROD; +#endif +#ifdef __ARM_FEATURE_I8MM + flags |= AV_CPU_FLAG_I8MM; +#endif + + return flags; } size_t ff_get_cpu_max_align_aarch64(void) diff --git a/libavutil/aarch64/cpu.h b/libavutil/aarch64/cpu.h index 2ee3f9323a..64d703be37 100644 --- a/libavutil/aarch64/cpu.h +++ b/libavutil/aarch64/cpu.h @@ -25,5 +25,7 @@ #define have_armv8(flags) CPUEXT(flags, ARMV8) #define have_neon(flags) CPUEXT(flags, NEON) #define have_vfp(flags) CPUEXT(flags, VFP) +#define have_dotprod(flags) CPUEXT(flags, DOTPROD) +#define have_i8mm(flags) CPUEXT(flags, I8MM) #endif /* AVUTIL_AARCH64_CPU_H */ diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 2c5f7f4958..2ffc3986aa 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -174,6 +174,8 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) { "armv8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV8 }, .unit = "flags" }, { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" }, { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" }, + { "dotprod", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_DOTPROD }, .unit = "flags" }, + { "i8mm", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_I8MM }, .unit = "flags" }, #elif ARCH_MIPS { "mmi", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMI }, .unit = "flags" }, { "msa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MSA }, .unit = "flags" }, diff --git a/libavutil/cpu.h b/libavutil/cpu.h index 8fa5ea9199..da486f9c7a 100644 --- a/libavutil/cpu.h +++ b/libavutil/cpu.h @@ -69,6 +69,8 @@ #define AV_CPU_FLAG_NEON (1 << 5) #define AV_CPU_FLAG_ARMV8 (1 << 6) #define AV_CPU_FLAG_VFP_VM (1 << 7) ///< VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations +#define AV_CPU_FLAG_DOTPROD (1 << 8) +#define AV_CPU_FLAG_I8MM (1 << 9) #define AV_CPU_FLAG_SETEND (1 <<16) #define AV_CPU_FLAG_MMI (1 << 0) diff --git a/libavutil/tests/cpu.c b/libavutil/tests/cpu.c index dadadb31dc..a52637339d 100644 --- a/libavutil/tests/cpu.c +++ b/libavutil/tests/cpu.c @@ -38,6 +38,8 @@ static const struct { { AV_CPU_FLAG_ARMV8, "armv8" }, { AV_CPU_FLAG_NEON, "neon" }, { AV_CPU_FLAG_VFP, "vfp" }, + { AV_CPU_FLAG_DOTPROD, "dotprod" }, + { AV_CPU_FLAG_I8MM, "i8mm" }, #elif ARCH_ARM { AV_CPU_FLAG_ARMV5TE, "armv5te" }, { AV_CPU_FLAG_ARMV6, "armv6" }, diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 7389ebaee9..4311a8ffcb 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -230,6 +230,8 @@ static const struct { #if ARCH_AARCH64 { "ARMV8", "armv8", AV_CPU_FLAG_ARMV8 }, { "NEON", "neon", AV_CPU_FLAG_NEON }, + { "DOTPROD", "dotprod", AV_CPU_FLAG_DOTPROD }, + { "I8MM", "i8mm", AV_CPU_FLAG_I8MM }, #elif ARCH_ARM { "ARMV5TE", "armv5te", AV_CPU_FLAG_ARMV5TE }, { "ARMV6", "armv6", AV_CPU_FLAG_ARMV6 }, From patchwork Fri May 26 08:03:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 41834 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp1145287pzb; Fri, 26 May 2023 01:03:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7j1i3fbrYgX2wNKUxnuRq12CGeDejgMcHKEGmSRjxGMeiA8zNuFtvygGvtBeJCj2SEWoQk X-Received: by 2002:a05:6402:331:b0:50b:c72a:2b26 with SMTP id q17-20020a056402033100b0050bc72a2b26mr759912edw.9.1685088234842; Fri, 26 May 2023 01:03:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685088234; cv=none; d=google.com; s=arc-20160816; b=mz2gjgMg2KoEoo6xzAWB2he5pvqA6EtEE35k4yEsMcwKC3GMrijAT8bTtTIG/bPqF9 iPkFz+U/TLjrtHLxam3AsKvQN1jzuIBCz3zclwqTWdczKqHvjqaSogfRNjEbD7M99Kcj Oi9g5PGCUI3eaUbqMUZELLWKsVHSJ+7jq6WUwCLA1QrX4p/EwVfAzJhRRRk8wAfVUeQr GxHpji6sHOhAGRbugb3afX2tcVH+Lajy1iaHWVQMivAtRp7vT106hjDO3djCjpR6qPc8 KK7+dXWfCmNO6EmupCdtfasA+ve7hHSOt9fv+IkhiJsnfo+du3VPR8pqRSfuBvj0Q90a rFuw== 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:dkim-signature:delivered-to; bh=r9Rr02HM9jo1b5Q3MZXT2KfoE6xEjXyRB2Lc0BhWh5o=; b=sHjri48COObYmH5EtOxF84bl/XEZOdSyx5dB8JeVOOUoHXpEcLjHMJIZCxfnfkgOtU La0jNB/hUhUhgGqygNafWRtRcF9XU4kPEqLbXMy3a5PmIJTnVewI4GXC9IRnsB3RzhcE Jt4FjAgum2RosTDY8BWJ7TgUvJNRQX8nleBQZQOj+64BKSZNITa0579ohTpT5mX+6ao+ cKwqjzuVOYiucb/6N/8fKX8FVdwFpxkFJ7NcHyUu1Rq2f0k3ulHspXywcGGM5+2zibtS lvAPW3loDK+NlCasFD5+TnKmCKA7gIHIyjPjAOG0XHusuNa8iABqjL381OsEVnbhjUgv 206A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20221208.gappssmtp.com header.s=20221208 header.b=47z0HXwF; 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 l18-20020a056402345200b00509ee597a42si303648edc.588.2023.05.26.01.03.54; Fri, 26 May 2023 01:03:54 -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=@martin-st.20221208.gappssmtp.com header.s=20221208 header.b=47z0HXwF; 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 B0EF668C1A6; Fri, 26 May 2023 11:03:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6D5D668B9FF for ; Fri, 26 May 2023 11:03:18 +0300 (EEST) Received: by mail-lf1-f51.google.com with SMTP id 2adb3069b0e04-4f13d8f74abso426450e87.0 for ; Fri, 26 May 2023 01:03:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20221208.gappssmtp.com; s=20221208; t=1685088197; x=1687680197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=KiYSRHk3bh+yeQTaKoH8PJNgDjzCiG0kgyUE8zcuBoQ=; b=47z0HXwFYWvZnxfPprzZwxc7wfAkXinMRoyxAJkdin4iZDo2SU4joniVO7euodNNoC 5W3zwUf6yaCKl4lnjljCiB5ZRphnNi8zM1/Bv3BvfMgyvFetl3dx4k8TVoeP8CW0aFrx IThsYLOQz7zJ8S44tsGmK2EOJWIiClq3MlSdXEOG8Op+KLVoibTaiLq1LVPY8KC6xDAC NxUafZdMq8aSJ89zRdcaC/ySWkbNPHTV4nNvkQ3BQn7MerAu8r8WSHCJ3o2wJ700aRao kONk23Bt1FwdzXpraMjDXkA8aVho7n3c3HRY9IeDINQrKotnG71z6gJiSiT4AZqzahWf LnYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685088197; x=1687680197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KiYSRHk3bh+yeQTaKoH8PJNgDjzCiG0kgyUE8zcuBoQ=; b=YEe82OKy6VfvutycWpOsTzM1UbYR7QTDHxhbWM6/8a4YHLCnOQAtby3iowrSHqCKYh QExYu83n3uYJflEpeTB9MFdZGtfuEENOWD9XOaSr60nmGTn9vbP11IQvEBixjUWs/CiJ 4UvrcY7Dxzggaq4I0BF5I/0aBvGiRzqCzDxIyJqQw8qLIe/SHvA/HosvWTX7fQrA2+RE RHQD9qyfHEsoFKd8MdEqBJCzAuXY+X3Xg2K6X9sIgUPlFvwq/vaAugfcWu3JLLkeF7kn jrV4EmikPhK+RbUV6TG41s09d/GO71yLprfunrL1y4RHsL1JH/R7+dFuWgHqtmX/zwTn MAxw== X-Gm-Message-State: AC+VfDysG5uZpcMvPSENowsbr6cYP8ZzUU9FbK4uCvkBm0jhz35YEBNB QxCQC28ayxpvLSBhKgqSJLROwRVbwuzozxPI2r62Pg== X-Received: by 2002:ac2:5ec4:0:b0:4f3:7a8c:d46c with SMTP id d4-20020ac25ec4000000b004f37a8cd46cmr305610lfq.66.1685088197689; Fri, 26 May 2023 01:03:17 -0700 (PDT) Received: from localhost (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id r13-20020ac25a4d000000b004f00d3d9df9sm512668lfn.188.2023.05.26.01.03.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 26 May 2023 01:03:17 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 May 2023 11:03:14 +0300 Message-Id: <20230526080315.83424-3-martin@martin.st> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230526080315.83424-1-martin@martin.st> References: <20230526080315.83424-1-martin@martin.st> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] aarch64: Add linux runtime cpu feature detection using getauxval(AT_HWCAP) 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: HOGIUh+LWMey Based on code by Janne Grunau. Using HWCAP_CPUID for user space access to the CPU feature registers. See https://www.kernel.org/doc/html/latest/arm64/cpu-feature-registers.html. --- configure | 2 ++ libavutil/aarch64/cpu.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/configure b/configure index 3c7473efb2..b5357b8d27 100755 --- a/configure +++ b/configure @@ -2207,6 +2207,7 @@ HAVE_LIST_PUB=" HEADERS_LIST=" arpa_inet_h + asm_hwcap_h asm_types_h cdio_paranoia_h cdio_paranoia_paranoia_h @@ -6422,6 +6423,7 @@ check_headers io.h enabled libdrm && check_headers linux/dma-buf.h +check_headers asm/hwcap.h check_headers linux/perf_event.h check_headers libcrystalhd/libcrystalhd_if.h check_headers malloc.h diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c index 42b33e4a2d..34c838c2f5 100644 --- a/libavutil/aarch64/cpu.c +++ b/libavutil/aarch64/cpu.c @@ -20,6 +20,42 @@ #include "libavutil/cpu_internal.h" #include "config.h" +#if (defined(__linux__) || defined(__ANDROID__)) && HAVE_GETAUXVAL && HAVE_ASM_HWCAP_H +#include +#include +#include + +#define get_cpu_feature_reg(reg, val) \ + __asm__("mrs %0, " #reg : "=r" (val)) + +static int detect_flags(void) +{ + unsigned long ret = getauxval(AT_HWCAP); + int flags = 0; +#if defined(HWCAP_CPUID) + uint64_t tmp; + if (!(ret & HWCAP_CPUID)) + return flags; + get_cpu_feature_reg(ID_AA64ISAR0_EL1, tmp); + if (((tmp >> 44) & 0xf) == 0x1) + flags |= AV_CPU_FLAG_DOTPROD; + get_cpu_feature_reg(ID_AA64ISAR1_EL1, tmp); + if (((tmp >> 52) & 0xf) == 0x1) + flags |= AV_CPU_FLAG_I8MM; +#endif + + return flags; +} + +#else + +static int detect_flags(void) +{ + return 0; +} + +#endif + int ff_get_cpu_flags_aarch64(void) { int flags = AV_CPU_FLAG_ARMV8 * HAVE_ARMV8 | @@ -33,6 +69,8 @@ int ff_get_cpu_flags_aarch64(void) flags |= AV_CPU_FLAG_I8MM; #endif + flags |= detect_flags(); + return flags; } From patchwork Fri May 26 08:03:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 41835 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c51c:b0:10c:5e6f:955f with SMTP id gm28csp1145421pzb; Fri, 26 May 2023 01:04:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6dld1EVRuvaiQ8EW2MAuR++oiw7DhpDJxTKJqvBE5U6D8yjHM1/9qVqaZm7hZ1JF1mI7VG X-Received: by 2002:a17:907:d27:b0:94b:d57e:9d4b with SMTP id gn39-20020a1709070d2700b0094bd57e9d4bmr1525449ejc.2.1685088246433; Fri, 26 May 2023 01:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685088246; cv=none; d=google.com; s=arc-20160816; b=yF3ZDv3CKVmeAQEfaR23BqMBC/gHcuqXM7LXOrPdmunU35AYXetxTNUWiyeYs2dSyd dOynzPvKXiZCkkN/iAAH0Tt3wtBe/bHrBYOEdDBUrEhwkTmZaawzcSkBcdJGS46RYA+d r9zxwoFcMpvff6Md7gE5GQnsqFOxQtjJZFS2j2Gk+eDy3cqhXfQU7S5mkMa8iQwMDYm0 4y//1/dj+ZdDiWVUQXxtY+RUCkI2Kb9INDBmRK7iV85yMyYsoRLQ+Q9rcgnjYm5iUftm 2F4gwqE9nTtyVzsVFPvvi0d0ARMLNSPxbOgodf/xHzKAz9A4o9aJP57fKKilFzQ9n8gM aI4w== 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:dkim-signature:delivered-to; bh=FW6UFAckJ2g3iZzV/m548s7+AABtyx5CBzDTZKebSIM=; b=Dwo7pkiAoJvJ5CtMcoaivvvRun57gsT5gyX40hf7ulE50HGTdk/ru9te/Lql5yER76 OCWv+DfIsRmVwce+oYl2QwDBUFazh5PagPMi5OmzXc/YqLBUuu5jx3UhkXYQmuCdGmt2 0MepzyyfOxwKCqjg0pC7XOGub8Z0Rj0v7No1Dbq/xYIxzMSVl/EjwE+QQkOCAV7gDq3G 1UcmAPF63r3ZZMqP/b8/MhSnjji6I++g4icsXmfQ9UWjG+4+vlNbhgWCRCW+uWI3JWrq hlDdmU+13AKVARQOZRQCMNIrJUmGWec+AaCfnumFOzmMbsqQ3JVZhtIriNEVEOJ7zgOf 1Ojg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20221208.gappssmtp.com header.s=20221208 header.b=sk1MynBp; 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 st5-20020a170907c08500b00973877aac6fsi780864ejc.30.2023.05.26.01.04.06; Fri, 26 May 2023 01:04: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; dkim=neutral (body hash did not verify) header.i=@martin-st.20221208.gappssmtp.com header.s=20221208 header.b=sk1MynBp; 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 CB17468BBF7; Fri, 26 May 2023 11:03:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 13C1668B9FF for ; Fri, 26 May 2023 11:03:19 +0300 (EEST) Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2af1e290921so4281601fa.3 for ; Fri, 26 May 2023 01:03:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20221208.gappssmtp.com; s=20221208; t=1685088198; x=1687680198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=YFlUz7sZjYoQVjDEtjrVrhvD1J+V2cdKdTpEhwgUrLI=; b=sk1MynBpt8gcIODHgcn4K1wVPhQNPTUNFdoXKrF/74TyZazO7HcGFghNy68GW5+IQE mZlqzmt/gLkMlZ0GQiK/1NOaOX4iBPHPWi6k0p4xLuq7g0HBGvL+4ZJ85LeNonyyMh/j CJwUfdZwptwkjfe3sGrrMZnARLeCN3r4AfI6fhv+jGCS3R8+0i2fr0tY9ghMk4hraKee qndXjUGTlrgJ+mcxZPPj/Z1Cz76N6vjQW2gpbhwWPIRzj4kyKjtuacnQPpWLciPmeBBe 2r1kWKwdA3TMkq6r+iQPGHY/VBh40EUSjEX7O/jW1SWPeTDA8KXyzsbT+5e6mjszCfiu qAxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685088198; x=1687680198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=YFlUz7sZjYoQVjDEtjrVrhvD1J+V2cdKdTpEhwgUrLI=; b=WQpWULvU5socI1wbo6OyzlOqqjHcqfR8hp6teJn3RbIH4NMOLVhHqSGxczcolNZ4Qq NfRtSYeppJr9v1RS+I5Dlk3uuQ/49uZXuJJkJpmhHQM6nCR6Frw9Z+G+FbNVVAvojGIy 9z85qsGUWNpmLSgFZFZ711fcPIEVTcanyuDUMboew+zPaT2Sab7m50tcMllcR7PR83JS Nm7rLQVK6tQs7h3QGsC08XE2hshnmLLVMoadXbZJC0S2Kh+mYB5UXPDg6TdPHZoXxQu2 lX/rjaweFqdI1MEmqA5ruIWFKe4jcWj9UyrbZK+QfjL15Yw2aXVcQpDUHrNrRgKUNbVy ZKEQ== X-Gm-Message-State: AC+VfDz4MKg0WOxFBBgVOB/auNJG5WMQoQqkN9AcoPtAsmfPJKg9HIyu 4CzDrjOY/CCqdrhu1WYf9AF7ifG1RQWyViKs1oAMmw== X-Received: by 2002:a2e:b6c2:0:b0:2a8:a651:8098 with SMTP id m2-20020a2eb6c2000000b002a8a6518098mr349827ljo.38.1685088198363; Fri, 26 May 2023 01:03:18 -0700 (PDT) Received: from localhost (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id i10-20020a2e864a000000b002ad90c2d0dasm607301ljj.71.2023.05.26.01.03.18 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 26 May 2023 01:03:18 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Fri, 26 May 2023 11:03:15 +0300 Message-Id: <20230526080315.83424-4-martin@martin.st> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230526080315.83424-1-martin@martin.st> References: <20230526080315.83424-1-martin@martin.st> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] aarch64: Add Apple runtime detection of dotprod and i8mm using sysctl 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: X1nMqrxsxeF6 --- configure | 2 ++ libavutil/aarch64/cpu.c | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/configure b/configure index b5357b8d27..45bdc16c7d 100755 --- a/configure +++ b/configure @@ -2346,6 +2346,7 @@ SYSTEM_FUNCS=" strerror_r sysconf sysctl + sysctlbyname usleep UTGetOSTypeFromString VirtualAlloc @@ -6384,6 +6385,7 @@ check_func_headers mach/mach_time.h mach_absolute_time check_func_headers stdlib.h getenv check_func_headers sys/stat.h lstat check_func_headers sys/auxv.h getauxval +check_func_headers sys/sysctl.h sysctlbyname check_func_headers windows.h GetModuleHandle check_func_headers windows.h GetProcessAffinityMask diff --git a/libavutil/aarch64/cpu.c b/libavutil/aarch64/cpu.c index 34c838c2f5..f35e4356df 100644 --- a/libavutil/aarch64/cpu.c +++ b/libavutil/aarch64/cpu.c @@ -47,6 +47,28 @@ static int detect_flags(void) return flags; } +#elif defined(__APPLE__) && HAVE_SYSCTLBYNAME +#include + +static int detect_flags(void) +{ + uint32_t value = 0; + size_t size; + int flags = 0; + + size = sizeof(value); + if (!sysctlbyname("hw.optional.arm.FEAT_DotProd", &value, &size, NULL, 0)) { + if (value) + flags |= AV_CPU_FLAG_DOTPROD; + } + size = sizeof(value); + if (!sysctlbyname("hw.optional.arm.FEAT_I8MM", &value, &size, NULL, 0)) { + if (value) + flags |= AV_CPU_FLAG_I8MM; + } + return flags; +} + #else static int detect_flags(void)