From patchwork Tue Dec 21 19:56:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Kelly X-Patchwork-Id: 32809 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp5757354iog; Tue, 21 Dec 2021 11:56:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQC00tXKBn0U7mSTV84ulvQzpG0bWDPUxGO018kQZBb8TugfvW8qhVPIU2rMkmcvQlOlUa X-Received: by 2002:a05:6402:4312:: with SMTP id m18mr4785931edc.273.1640116617168; Tue, 21 Dec 2021 11:56:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1640116617; cv=none; d=google.com; s=arc-20160816; b=DZhR5hjUIL5s6JwkVzmM/lq5UJ+KcqxCewKVdTyjoICO65GZj60EkfO8n6eIwc+dR0 Mb9X2jtqkHjSjpdBu9jXlTcaMymUiA1JEaaFwOcRLVOm1vjNCQ/FppPljb6dyUdbL3qx uFxDNiXavKLvpNuwQ3RynEkUJqgzUUbLqTLW6T5ErAu7xx46xXjN1oCHeXCeuu5SklIN v5nwiBooywKgE1K5m9TECb6S9V4qvGTqC2tNgR19IGXrCh0nhYuPiAD5G6YiwRoCSobe 5CYQ4OAXEWJM8QabPBIGuQi14wevyv+UHEK70LVp/hLpZ/tZv1g1/pDl2JamifGg4Bdc SDMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:to:from:references:mime-version :message-id:in-reply-to:date:dkim-signature:delivered-to; bh=ZiXdIks7eu3Rce7u/xV5xI63zd12VA8Ojwd8vhnUZOE=; b=OQKu5Bku+4MusBbOMXEs21ItHTkKXeNKpCJQ6q5skU9UA8Wts+hIi7goTm8p0cuYGO 7x6VKrUnT/yL1Mnggs+1LJUY3wBmrcscXK88iCWvHREmztSy4ILHoHkR8WpwRX89HkJR lKzDuZ8CAzQ7ZLryygmNthBWLkeX4u0Qe2oE5fihGm5dpzyLnx5pDoW1K9gxCyugKFrz DTcp79YHov6oi7I7e8cUXSzbEdwgj4SFcFWhnr9b/uyS6s6eUMx9R8hMs0ki93SuDt4I o6lvQWJwCCT0LdEqQnm8RPnBEnf9IwcxexFftdBceGz7fQq8F8Fc+GkF6jddtzr9CdOH sNRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=Q26gkNDu; 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 hz3si366568ejc.129.2021.12.21.11.56.56; Tue, 21 Dec 2021 11:56:57 -0800 (PST) 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=@google.com header.s=20210112 header.b=Q26gkNDu; 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 C70F868ADDC; Tue, 21 Dec 2021 21:56:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-lj1-f202.google.com (mail-lj1-f202.google.com [209.85.208.202]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE4CC68ADDC for ; Tue, 21 Dec 2021 21:56:45 +0200 (EET) Received: by mail-lj1-f202.google.com with SMTP id u8-20020a05651c130800b0022d6dad0418so1969lja.11 for ; Tue, 21 Dec 2021 11:56:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=L01ZbhGonrnPgyfaq/aGAXws87aMsH1nDEUtChbuYlo=; b=Q26gkNDu2AmHeY6hE8aUKct6z8QRo2jj7EYL9ph7RJY9m4pV1DdwG9hIAlMpMFEU9G w/PJB3hmk93JPHTHQfTsj6Bo8WF3iZV2n5SDIPc98fkFGIn2HmWkWo4JwOxLFRDxdGqm CKy0YiiobB9/NtWXHCn4T1mRm3wQ8ovQ/as6eSmvq1x074v/1IbFYBuec2XPI1JqxbIC RKRZrWwJ1EigOa0jGWtoA60S4/uDs2vtRclK6L4LDgIuo36UabxVFdY1mUKtjD+/PXqc +pY58RC4ewJqhDiaVSHllCXK924Y825mIiRUOthaq1FAGLF1yWePRVIxVhvk3Cn8+iC8 iD6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=L01ZbhGonrnPgyfaq/aGAXws87aMsH1nDEUtChbuYlo=; b=uP/74D0xQWkZU1/lT8jieTz37GhOBBcLkMpVfcD4A/UImgRZix1Lj7u1yGuK01DNFi MTE5yFU1TS85ouG0mgjkCofsEE1TagBzV9Q/hS0Zg2sx8jhFPVbJSbpJYv8VS3E63eOc ymkUJwTJIKkTa5sqtDSGVl5r7LAsuzRf+RByD7/LLPBzy4+d1BvJBWPtISCPqGKJowKH A2TqSyYe3KVRNfqBKuE3AzRDGnnOjqPGNXIK+cIxkBNgqJiss/OjE5SbQwcpX+svH2pS Woc8pkfQfMxhre1Vvkl/pO3FKF/TZJKGsbY97cOAc5jRykkkIXSm1ZB6Kwm172Oqveew 34kQ== X-Gm-Message-State: AOAM532w5DwehRihoiopkqVSzwGEIEUOL1zxuOmeKmRPjZgnCfVnLQxe uE6wnyEjsw5iqOPxcJhBNqCzrcO3uB6Nyrv6uNjZiujmnSiOn6W5TX1wSjWLElLKroWtFNV9oSb n9nXe7cJLihEU6+ZnJHdCGIYMsMdDhk7LhaAyfFYYEX1AV27obhMD/DsISdx8/JcmEnHY8/Y= X-Received: from alankelly0.zrh.corp.google.com ([2a00:79e0:61:301:b011:cab:46bb:c3b8]) (user=alankelly job=sendgmr) by 2002:a19:c217:: with SMTP id l23mr4297094lfc.599.1640116604733; Tue, 21 Dec 2021 11:56:44 -0800 (PST) Date: Tue, 21 Dec 2021 20:56:41 +0100 In-Reply-To: Message-Id: <20211221195641.1644735-1-alankelly@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.34.1.307.g9b7440fafd-goog From: Alan Kelly To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 1/2] libavutil/cpu: Add AV_CPU_FLAG_SLOW_GATHER. 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 Cc: Alan Kelly Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: jb1OdQ8ZIrD9 This flag is set on Haswell and earlier and all AMD cpus. --- Checks for family for Haswell. All checks are done where AVX2 flag is set as this is clearer. libavutil/cpu.h | 1 + libavutil/x86/cpu.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/libavutil/cpu.h b/libavutil/cpu.h index ae443eccad..ce9bf14bf7 100644 --- a/libavutil/cpu.h +++ b/libavutil/cpu.h @@ -54,6 +54,7 @@ #define AV_CPU_FLAG_BMI1 0x20000 ///< Bit Manipulation Instruction Set 1 #define AV_CPU_FLAG_BMI2 0x40000 ///< Bit Manipulation Instruction Set 2 #define AV_CPU_FLAG_AVX512 0x100000 ///< AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used +#define AV_CPU_FLAG_SLOW_GATHER 0x2000000 ///< CPU has slow gathers. #define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard #define AV_CPU_FLAG_VSX 0x0002 ///< ISA 2.06 diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c index bcd41a50a2..441b4695d5 100644 --- a/libavutil/x86/cpu.c +++ b/libavutil/x86/cpu.c @@ -146,8 +146,21 @@ int ff_get_cpu_flags_x86(void) if (max_std_level >= 7) { cpuid(7, eax, ebx, ecx, edx); #if HAVE_AVX2 - if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x00000020)) + if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x00000020)) { rval |= AV_CPU_FLAG_AVX2; + cpuid(1, eax, ebx, ecx, std_caps); + family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff); + model = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0); + /* Haswell has slow gather */ + if (!strncmp(vendor.c, "GenuineIntel", 12)) + if (family == 6 && model < 70) + rval |= AV_CPU_FLAG_SLOW_GATHER; + /* Zen 3 and earlier have slow gather */ + if (!strncmp(vendor.c, "AuthenticAMD", 12)) + if (family <= 0x19) + rval |= AV_CPU_FLAG_SLOW_GATHER; + } + #if HAVE_AVX512 /* F, CD, BW, DQ, VL */ if ((xcr0_lo & 0xe0) == 0xe0) { /* OPMASK/ZMM state */ if ((rval & AV_CPU_FLAG_AVX2) && (ebx & 0xd0030000) == 0xd0030000)