From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 37E224037D for ; Mon, 20 Dec 2021 15:26:24 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6AECF68AF81; Mon, 20 Dec 2021 17:26:22 +0200 (EET) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E9B6568A94D for ; Mon, 20 Dec 2021 17:26:15 +0200 (EET) Received: from w3.tutanota.de (unknown [192.168.1.164]) by w4.tutanota.de (Postfix) with ESMTP id 89BAE10601EF for ; Mon, 20 Dec 2021 15:26:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1640013975; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=fhgPyIKnkmTKb9MLtlronzj2vgZ0hF2oNTf5UlPoLac=; b=a8sOdCa/gLlOIw5Io/zMd4R1LYsNoQtQaIi2p0sfo/5YNsyozTagipgpai7CHXvj 0Bc7FzCIG0S12YJLkXCq8SMS5fQJccHBkG4XscOTjJYv96ibQZqwuNpsPHPUDfuQx4s cgbjj5EzaZWrU8B6SWioRmXeBC3OekM47pSdx9DOHKn5Ox9KFd2vHRwY+FvsrgbJTsv d0mC7+SOev7u8y6x8bpZDmq8w66q/ZM7RvYVUN2XL8Ey6440ToodJy2T9gLTL99CCUk bguC8Pq5oupeBNwRL3o/mmRWhnzwdMTTpxQtvUiT8JsROfxn4kBf6CJ+lA0v5Dl7t0c M2oW10alIw== Date: Mon, 20 Dec 2021 16:26:15 +0100 (CET) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: <20211220145903.838398-1-alankelly@google.com> References: <20211220135627.615097-1-alankelly@google.com> <8424d6a1-df63-954e-6823-740bf1fcb891@gmail.com> <20211220144312.738559-1-alankelly@google.com> <20211220145903.838398-1-alankelly@google.com> MIME-Version: 1.0 Subject: Re: [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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 20 Dec 2021, 15:59 by alankelly-at-google.com@ffmpeg.org: > This flag is set on Haswell and earlier and all AMD cpus. > --- > Sets this flag on Zen 3 and earlier. > libavutil/cpu.h | 1 + > libavutil/x86/cpu.c | 14 +++++++++++++- > 2 files changed, 14 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..11467ba99d 100644 > --- a/libavutil/x86/cpu.c > +++ b/libavutil/x86/cpu.c > @@ -146,8 +146,16 @@ 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(family == 6 && model < 70) > Shouldn't this check for the vendor as well? Nit: space after the if. > + 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) > @@ -196,6 +204,10 @@ int ff_get_cpu_flags_x86(void) > used unless explicitly disabled by checking AV_CPU_FLAG_AVXSLOW. */ > if ((family == 0x15 || family == 0x16) && (rval & AV_CPU_FLAG_AVX)) > rval |= AV_CPU_FLAG_AVXSLOW; > + > + /* Zen 3 and earlier have slow gather */ > Nit: put a space after the start of a comment and indent to the same level as the line below. > + if((rval & AV_CPU_FLAG_AVX2) & family <= 25) > Mistake: you're ANDing the conditions, you want `&& family <= 0x19` (hex because the other checks are all hex too). Nit: space after the if. > + rval |= AV_CPU_FLAG_SLOW_GATHER; > } > > /* XOP and FMA4 use the AVX instruction coding scheme, so they can't be > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".