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 A71C14346B for ; Wed, 13 Jul 2022 20:49:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D044568BA05; Wed, 13 Jul 2022 23:49:06 +0300 (EEST) Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 858C268B9F8 for ; Wed, 13 Jul 2022 23:48:57 +0300 (EEST) Received: by mail-lj1-f177.google.com with SMTP id q7so14804884lji.12 for ; Wed, 13 Jul 2022 13:48:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3KFB27n+E+jGMdUV8dieHyAtfVoFJZB5OIDderjqANI=; b=JfQPm1lu/6/D73x/LQlWyESwLmPw8CZhCW5lnnh4PD5fzKyBHe6UgvSAEB0SptWOB/ MCYvdQaWdjuRzCvoMWy/Aa9UkjCnPVN80axC6deIcK0as7hwnQlmpZ2X+gMmgszdCfwi V9U3fbJWiJ7HSSHb/bxPE0KhfWO5Z1Kt5tD1XB29b8kMyJa+jXpOkKiwqk7M1gYVCfEw W8rXC94CjhtLjXsja7j9uNvwL5EACCnPmXPkRplg4gw8c40rmzpy5T9E44ohNMCwSOJT K5nxh+jCmCGe0HlS/ff2/XimOWGLSD0vSNS8+AGcBfINtlqx9VK9ym+U2TfufNABN17y A9Yg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3KFB27n+E+jGMdUV8dieHyAtfVoFJZB5OIDderjqANI=; b=I84NWGenRvqWs5bMkejmB1aUZxRzn7cZUC1GvuJ1Owq1macnOdUQnQ9VRctSxn51f5 aBfCLOfjvt/uS5cIZxKakPCyd8vJ/zrHDYm/D6LOVqhtlI/WJ/XyoqoPl9vF3O0DFPqS zt34LhXdsaWlXAF0BaTimcoKmE126bK0LodnhywJcKqgN3/RHMWi6G5L7YK1x1xySWIj n411vSMq4FdqB2M5pQFIGxa4d0GWntToN6YdmxcEl13OBAhR3qndeLWuj7OSXNhjNqOd T8oa3HXkXFc9VREoCNKxPei2TZIM9cvQJksWW10Cwa8njwXhYBB46mj7nPsM72HYmLe8 EZ5Q== X-Gm-Message-State: AJIora8gwvetLChWro8xlEE56RUGO29f8Gss/IYjYQnVZfzU3JLElTa/ i846l/v+vW8arWLPU8h08mp6u87E+V3gLY8o X-Google-Smtp-Source: AGRyM1tmIIkf65pK5YTnSkb/dsX7HpYXNNMYH7Jp1DIU5v3ZUaO6AcGq7CAEzF/BYEyGz/JEsljCIA== X-Received: by 2002:a05:651c:1691:b0:25d:8240:6b3a with SMTP id bd17-20020a05651c169100b0025d82406b3amr2463521ljb.305.1657745336744; Wed, 13 Jul 2022 13:48:56 -0700 (PDT) Received: from localhost.localdomain (dsl-tkubng21-58c01c-243.dhcp.inet.fi. [88.192.28.243]) by smtp.gmail.com with ESMTPSA id c3-20020a056512074300b00489e011bad7sm1993836lfs.218.2022.07.13.13.48.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 13:48:56 -0700 (PDT) From: =?UTF-8?q?Martin=20Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Wed, 13 Jul 2022 23:48:53 +0300 Message-Id: <20220713204854.3114817-4-martin@martin.st> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220713204854.3114817-1-martin@martin.st> References: <20220713204854.3114817-1-martin@martin.st> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] aarch64: me_cmp: Switch from uabd to uabal in ff_pix_abs16_xy2_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: Jonathan Swinney 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: Using absolute-difference-accumulate does use twice the amount of absolute-difference instructions, but avoids the need for the uaddl and add instructions, reducing the total number of instructions by 3. These can be interleaved in the rest of the calculation, to avoid tight dependencies at the end. Unfortunately, this is marginally slower on Cortex A53, but faster on A72 and A73. Before: Cortex A53 A72 A73 Graviton 3 pix_abs_0_3_neon: 175.7 109.2 92.0 41.2 After: pix_abs_0_3_neon: 179.7 96.7 87.5 41.2 --- libavcodec/aarch64/me_cmp_neon.S | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/libavcodec/aarch64/me_cmp_neon.S b/libavcodec/aarch64/me_cmp_neon.S index 0ae23d8922..89546869fb 100644 --- a/libavcodec/aarch64/me_cmp_neon.S +++ b/libavcodec/aarch64/me_cmp_neon.S @@ -124,6 +124,9 @@ function ff_pix_abs16_xy2_neon, export=1 add v26.8h, v30.8h, v2.8h // add up 0..7, using pix2 + pix2+1 values from pix3 above add v27.8h, v31.8h, v3.8h // add up 8..15, using pix2 + pix2+1 values from pix3 above + uabdl v24.8h, v1.8b, v23.8b // absolute difference 0..7, i=0 + uabdl2 v23.8h, v1.16b, v23.16b // absolute difference 8..15, i=0 + ld1 {v21.16b}, [x5], x3 // load pix3 ld1 {v20.16b}, [x1], x3 // load pix1 @@ -137,6 +140,9 @@ function ff_pix_abs16_xy2_neon, export=1 rshrn v28.8b, v28.8h, #2 // shift right 2 0..7 (rounding shift right) rshrn2 v28.16b, v29.8h, #2 // shift right 2 8..15 + uabal v24.8h, v16.8b, v26.8b // absolute difference 0..7, i=1 + uabal2 v23.8h, v16.16b, v26.16b // absolute difference 8..15, i=1 + uaddl v2.8h, v21.8b, v22.8b // pix3 + pix3+1 0..7 uaddl2 v3.8h, v21.16b, v22.16b // pix3 + pix3+1 8..15 add v30.8h, v4.8h, v2.8h // add up 0..7, using pix2 + pix2+1 values from pix3 above @@ -144,33 +150,17 @@ function ff_pix_abs16_xy2_neon, export=1 rshrn v30.8b, v30.8h, #2 // shift right 2 0..7 (rounding shift right) rshrn2 v30.16b, v31.8h, #2 // shift right 2 8..15 - // Averages are now stored in these registers: - // v23, v16, v28, v30 - // pix1 values in these registers: - // v1, v16, v17, v20 - // available: - // v4, v5, v7, v18, v19, v24, v25, v27, v29, v31 + uabal v24.8h, v17.8b, v28.8b // absolute difference 0..7, i=2 + uabal2 v23.8h, v17.16b, v28.16b // absolute difference 8..15, i=2 sub w4, w4, #4 // h -= 4 - // Using absolute-difference instructions instead of absolute-difference-accumulate allows - // us to keep the results in 16b vectors instead of widening values with twice the instructions. - // This approach also has fewer data dependencies, allowing better instruction level parallelism. - uabd v4.16b, v1.16b, v23.16b // absolute difference 0..15, i=0 - uabd v5.16b, v16.16b, v26.16b // absolute difference 0..15, i=1 - uabd v6.16b, v17.16b, v28.16b // absolute difference 0..15, i=2 - uabd v7.16b, v20.16b, v30.16b // absolute difference 0..15, i=3 + uabal v24.8h, v20.8b, v30.8b // absolute difference 0..7, i=3 + uabal2 v23.8h, v20.16b, v30.16b // absolute difference 8..15, i=3 cmp w4, #4 // loop if h >= 4 - // Now add up all the values in each vector, v4-v7 with widening adds - uaddl v19.8h, v4.8b, v5.8b - uaddl2 v18.8h, v4.16b, v5.16b - uaddl v4.8h, v6.8b, v7.8b - uaddl2 v5.8h, v6.16b, v7.16b - add v4.8h, v4.8h, v5.8h - add v4.8h, v4.8h, v18.8h - add v4.8h, v4.8h, v19.8h + add v4.8h, v23.8h, v24.8h uaddlv s4, v4.8h // finish adding up accumulated values add d0, d0, d4 // add the value to the top level accumulator -- 2.25.1 _______________________________________________ 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".