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 ESMTPS id 89AEB4734E for ; Sun, 19 Jan 2025 20:58:10 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D02A568B5CC; Sun, 19 Jan 2025 22:58:06 +0200 (EET) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9A0BB68B34C for ; Sun, 19 Jan 2025 22:58:00 +0200 (EET) Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-304d9a1f198so32573661fa.0 for ; Sun, 19 Jan 2025 12:58:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20230601.gappssmtp.com; s=20230601; t=1737320280; x=1737925080; darn=ffmpeg.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=yKlkA32NCVhEl3N1FwDsk2v1oSU5Y2PpbjsIpWbdf58=; b=xaPX7+FtpRLll4AbqYgvtvjgNaF62HdGb8RG5DHZUrHBU05/PYOTOmS4fp9rEUCaE/ w/vkV83Yn4pxuPmu1jIIAaDBHavGyOF2vpawa7rSpQCPUb7RG+EmJ5A0MNBXpUTOcEec 6n9YbZBNsPnZcZucotdOn29fgOC2IC8axsZ6neXBzLorrvB3E/U/tO4f2EpiFcYQXPxS b11bMW98WtdupOxLuq1s/N4Lr2U7LzQknl81YA6HnsoWnegKrkdRtoI2OAM80YBHL88T o99mlWC0tPSwFcRtstk4Q1XfPaWpee/aeRqQ7KaBAJ7C1Onx1VPYj+6YHu+tyxEfGsfs v4DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737320280; x=1737925080; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yKlkA32NCVhEl3N1FwDsk2v1oSU5Y2PpbjsIpWbdf58=; b=DzV0wTw88q/ujnbUNpL6Hls1pe/T1x6GScq7DdB85yQJreVXFuiR/F6wsUDGRzekdE wMfnbjMaPeq+EMItq3wAoR5GB9dHQunylSo16BLhNAgwMoQMQyrEf5/D+k2j2huuiwS9 z29sHsO5dPGHOKdZWbXtvTmKxVvoCoX2yRtFpcR5/knqCdrE3qnQMZ6WO8Xbpgn3ir7T 2Gz/HKGYHlcVztgziQAJtZr41posPB4Y3C+SpU+ktwztNcs18/MfHNXICBkuOM7S+8o0 LjFDqUtVp7XNzNUZrmNW9p7Lbvk+1ec5EQj8DMhINtxWEYCC2tQFfzkmhzwdv541S/Do S7sg== X-Gm-Message-State: AOJu0YyUJq6JKIRn5aVEumk5Xjk2w81df3rINvecxGrxIgy0HaFf0Ehu Pc527aq7bxoIdIaIplxzAkMeYME4ru42zoRWaRfstmoRX8bcwC3CBQg3ewkRz4YR2kZ+W0QZIFn p8g== X-Gm-Gg: ASbGncvctaXn8tht1JDQ2pGR1qfGML4ngLjhWhM84GNwVIwB/ZAqK9Ehr7tR5jyRwdP Ge6o/nRCBvyLC9YVhy54um15FtvQf7movNEiVpP/xOssu2I+TBBdstypZZ6uj0+MkO/JU6ymiVm YBwY25b6unu4YCxnqTV6scXsLkGj4QWtXhrsDdlQnE8PnNxOfLpVKC/idzFYHmbwOeOM/Tz/FVY hAzRJdSPv9Mn++JBmwD2KZvpcW0ueeIx7qSjqA5pnBRFJm8+dryzCLDzeQdajK1xHDShg+dItRL C/Sbj1jm4zxjQhtJWwQOiEIjYImSNhBOeFwjM5rxM7ZQ8JBG4Dx30bv01dLV6x448w== X-Google-Smtp-Source: AGHT+IFbep+KofcEdylkY/C1Guswd2s/wVPwL2ci8i8y44vpsZ9KD3KMvPYr6dDSYjDwMj4DCgNHCQ== X-Received: by 2002:a05:651c:1611:b0:307:2bc6:5eb9 with SMTP id 38308e7fff4ca-3072ca60d6fmr44493201fa.4.1737320279636; Sun, 19 Jan 2025 12:57:59 -0800 (PST) Received: from tunnel335574-pt.tunnel.tserv24.sto1.ipv6.he.net (tunnel335574-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:11::2]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5439af787dasm1095078e87.224.2025.01.19.12.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Jan 2025 12:57:59 -0800 (PST) Date: Sun, 19 Jan 2025 22:57:57 +0200 (EET) From: =?ISO-8859-15?Q?Martin_Storsj=F6?= To: Krzysztof Pyrkosz via ffmpeg-devel In-Reply-To: <20250119173259.1533-2-ffmpeg@szaka.eu> Message-ID: <8111ca5d-4d1c-15d2-bd32-e74959c2194f@martin.st> References: <20250119173259.1533-2-ffmpeg@szaka.eu> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] avutil/aarch64/float_dsp_neon: Refactor ff_vector_fmul_add_neon 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: Krzysztof Pyrkosz Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Sun, 19 Jan 2025, Krzysztof Pyrkosz via ffmpeg-devel wrote: > Removed a branch, unrolled loop. Speed increase bumped from 3.95 to 5.60. On what core is that? Please quote the actual output including the absolute numbers. I'm getting much more inconclusive numbers for this one: Before: Cortex A53 A72 A73 A78 vector_fmul_add_neon: 620.0 257.2 624.5 162.8 After: vector_fmul_add_neon: 767.0 259.2 767.5 110.5 This seems to make things quite a lot slower on 2 of these 4 cores. On the A78, I'm getting numbers that look like yours though. So while it makes things better on one kind of core, it also regresses things quite a bit on others, so I'm not quite as convinced about this one. > diff --git a/libavutil/aarch64/float_dsp_neon.S b/libavutil/aarch64/float_dsp_neon.S > index 35e2715b87..0ee5c67b91 100644 > --- a/libavutil/aarch64/float_dsp_neon.S > +++ b/libavutil/aarch64/float_dsp_neon.S > @@ -138,19 +138,21 @@ function ff_vector_fmul_window_neon, export=1 > endfunc > > function ff_vector_fmul_add_neon, export=1 > - ld1 {v0.4s, v1.4s}, [x1], #32 > - ld1 {v2.4s, v3.4s}, [x2], #32 > - ld1 {v4.4s, v5.4s}, [x3], #32 > -1: subs w4, w4, #8 > - fmla v4.4s, v0.4s, v2.4s > - fmla v5.4s, v1.4s, v3.4s > - b.eq 2f > - ld1 {v0.4s, v1.4s}, [x1], #32 > - ld1 {v2.4s, v3.4s}, [x2], #32 > - st1 {v4.4s, v5.4s}, [x0], #32 > - ld1 {v4.4s, v5.4s}, [x3], #32 > - b 1b > -2: st1 {v4.4s, v5.4s}, [x0], #32 > +1: > + ldp q0, q1, [x1], #32 > + ldp q2, q3, [x2], #32 > + ldp q4, q5, [x3], #32 > + fmla v4.4s, v0.4s, v2.4s > + fmla v5.4s, v1.4s, v3.4s > + stp q4, q5, [x0], #32 > + ldp q0, q1, [x1], #32 > + ldp q2, q3, [x2], #32 > + ldp q4, q5, [x3], #32 > + fmla v4.4s, v0.4s, v2.4s > + fmla v5.4s, v1.4s, v3.4s > + stp q4, q5, [x0], #32 > + sub w4, w4, #16 > + cbnz w4, 1b > ret Why do you use sub+cbnz, instead of subs+b.gt? Also, having the cbnz directly follow the sub that updates the register, usually causes stalls on in-order cores; the usual pattern would be to have such a decrement e.g. between the last fmla and the following store. Doing that change, i.e. fmla v4.4s, v0.4s, v2.4s fmla v5.4s, v1.4s, v3.4s + subs w4, w4, #16 stp q4, q5, [x0], #32 - sub w4, w4, #16 - cbnz w4, 1b + b.gt 1b ret has this effect on numbers: Before: Cortex A53 A72 A73 A78 vector_fmul_add_neon: 767.0 259.2 769.5 109.0 After: vector_fmul_add_neon: 751.0 254.5 751.0 109.2 That makes things a little bit better on A53,A72,A73, but it's still overall a notable regression on the A53 and A73. // Martin _______________________________________________ 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".