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 9AA954041D for ; Fri, 22 Apr 2022 17:42:50 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7906668B339; Fri, 22 Apr 2022 20:42:48 +0300 (EEST) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D13C468B2BB for ; Fri, 22 Apr 2022 20:42:41 +0300 (EEST) Received: from localhost (213-47-68-29.cable.dynamic.surfer.at [213.47.68.29]) (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 1676620003 for ; Fri, 22 Apr 2022 17:42:40 +0000 (UTC) Date: Fri, 22 Apr 2022 19:42:40 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20220422174240.GV2829255@pb2> References: <20220217100404.1112755-1-alankelly@google.com> MIME-Version: 1.0 In-Reply-To: <20220217100404.1112755-1-alankelly@google.com> Subject: Re: [FFmpeg-devel] [PATCH v2 3/5] libswscale: Avx2 hscale can process inputs of any size. 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: multipart/mixed; boundary="===============2813339044654391805==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============2813339044654391805== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="a1XHjIRlD46OJB55" Content-Disposition: inline --a1XHjIRlD46OJB55 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 17, 2022 at 11:04:04AM +0100, Alan Kelly wrote: > The main loop processes blocks of 16 pixels. The tail processes blocks > of size 4. > --- > libswscale/x86/scale_avx2.asm | 48 +++++++++++++++++++++++++++++++++-- > 1 file changed, 46 insertions(+), 2 deletions(-) >=20 > diff --git a/libswscale/x86/scale_avx2.asm b/libswscale/x86/scale_avx2.asm > index 20acdbd633..dc42abb100 100644 > --- a/libswscale/x86/scale_avx2.asm > +++ b/libswscale/x86/scale_avx2.asm > @@ -53,6 +53,9 @@ cglobal hscale8to15_%1, 7, 9, 16, pos0, dst, w, srcmem,= filter, fltpos, fltsize, > mova m14, [four] > shr fltsized, 2 > %endif > + cmp wq, 16 > + jl .tail_loop > + mov countq, 0x10 > .loop: > movu m1, [fltposq] > movu m2, [fltposq+32] > @@ -97,11 +100,52 @@ cglobal hscale8to15_%1, 7, 9, 16, pos0, dst, w, srcm= em, filter, fltpos, fltsize, > vpsrad m6, 7 > vpackssdw m5, m5, m6 > vpermd m5, m15, m5 > - vmovdqu [dstq + countq * 2], m5 > + vmovdqu [dstq], m5 > + add dstq, 0x20 > add fltposq, 0x40 > add countq, 0x10 > cmp countq, wq > - jl .loop > + jle .loop > + > + sub countq, 0x10 > + cmp countq, wq > + jge .end > + > +.tail_loop: > + movu xm1, [fltposq] > +%ifidn %1, X4 > + pxor xm9, xm9 > + pxor xm10, xm10 > + xor innerq, innerq > +.tail_innerloop: > +%endif > + vpcmpeqd xm13, xm13 > + vpgatherdd xm3,[srcmemq + xm1], xm13 > + vpunpcklbw xm5, xm3, xm0 > + vpunpckhbw xm6, xm3, xm0 > + vpmaddwd xm5, xm5, [filterq] > + vpmaddwd xm6, xm6, [filterq + 16] > + add filterq, 0x20 > +%ifidn %1, X4 > + paddd xm9, xm5 > + paddd xm10, xm6 > + paddd xm1, xm14 > + add innerq, 1 > + cmp innerq, fltsizeq > + jl .tail_innerloop > + vphaddd xm5, xm9, xm10 > +%else > + vphaddd xm5, xm5, xm6 > +%endif > + vpsrad xm5, 7 > + vpackssdw xm5, xm5, xm5 > + vmovq [dstq], xm5 > + add dstq, 0x8 > + add fltposq, 0x10 > + add countq, 0x4 > + cmp countq, wq > + jl .tail_loop > +.end: > REP_RET > %endmacro countq is only used as counter after this If you count against 0 this reduces the instructions in the loop from add/cmp to just add. similarly the previously used [dstq + countq * 2] avoids a add can you comment on the performance impact of these changes ? On previous generations of CPUs this would have been generally slower I havnt really optimized ASM for current CPUs so these comments might not apply today but noone else seems reviewing this thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The worst form of inequality is to try to make unequal things equal. -- Aristotle --a1XHjIRlD46OJB55 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCYmLpDAAKCRBhHseHBAsP q00AAKCHoflsihd4OavnXqoLk69nAJ3M8wCfSN5/g1a3UKRptie7w4ksbsTbWU4= =uprN -----END PGP SIGNATURE----- --a1XHjIRlD46OJB55-- --===============2813339044654391805== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============2813339044654391805==--