From patchwork Mon Jul 17 17:25:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 42786 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6da1:b0:131:a7d0:bc6d with SMTP id gl33csp5525187pzb; Mon, 17 Jul 2023 10:26:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlEl4Oty9kHFoBYfZhaFGeCql4oX6SbLA6AsWESaurNcnguRqou5BtgJ1yrWDKh4af4xNSGF X-Received: by 2002:a17:906:19b:b0:993:eed1:8f2 with SMTP id 27-20020a170906019b00b00993eed108f2mr11920305ejb.1.1689614769527; Mon, 17 Jul 2023 10:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689614769; cv=none; d=google.com; s=arc-20160816; b=0g6VMk8xgBgG9Udw08+aM0qnkRI0RN36SqLYHI3FbGcX9Zj3Lhizj/abEtywYvv6eh kP7qpIDJjrEiQTInQ3MN4XcjrqDiZwXn7NQyhl30IQ19i6NdZfqqO/5EhFquu9XUJ6+c IeOB7+kwMctoN75DdmNcj6MxMo5L+QZAjzWkkY84jMvUdL8f2AQCnh81b0ibQgXj/Kvs ESNjUMDec+BS6aOY+FNn7PXbhZ4yQNLus/L8RgdTrG382jkTwtyXcXshnBWmeete6kYK vFAJ/lXSWohMc4Osiv1IBJS19RvaF2PtuJPZjBT5YYN9UsilXnXVrmbUp3U1VD2d8usc B6GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=5zUVWXMkgg5WkdUs2Y3NAF1J66RkVasKEaU9Fc/BrMs=; fh=hQcp50obTJ8bXC1it5NuEN23RGKfx0/zZ3s2gmreL+A=; b=qb2GiMYeUQMNskAUKjqiHUabUDDmnOw3InmcfQipklGgn7UIMTn0HvasBxiib7f+6G mfYt4fqOYFYUP2MUIkYjsEQkr9n/g9uxDtLYf6xI5fZq/ivWWFdpi4BZYUONYSWB6WqB /D46CS+ocBV7vmUPQz5/8XgEM97IsN7mUor7O+Qw2nJteL2ACw2gRQ7VxvyH9z44fLJV gN7oQNrh4RvZU66MZOBswHkk0t3dHeUUBUF5/NGCoJMGffOH8uu6qDcyIuVrQStNnqqu OmEfBSYLNabk17QCsoOblLwligUyPZ4UWWT0i4451Pm2qt3cD8Un1dMYWn+KTpornqEL TkCw== ARC-Authentication-Results: i=1; mx.google.com; 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 gv20-20020a170906f11400b00988786fec30si13419593ejb.935.2023.07.17.10.26.07; Mon, 17 Jul 2023 10:26:09 -0700 (PDT) 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; 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 7D55168C589; Mon, 17 Jul 2023 20:26:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from ursule.remlab.net (vps-a2bccee9.vps.ovh.net [51.75.19.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A2FDF68BF8D for ; Mon, 17 Jul 2023 20:25:58 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 0CF21C0014 for ; Mon, 17 Jul 2023 20:25:58 +0300 (EEST) From: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= To: ffmpeg-devel@ffmpeg.org Date: Mon, 17 Jul 2023 20:25:57 +0300 Message-Id: <20230717172557.15848-1-remi@remlab.net> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavu/float_dsp: rework RISC-V V scalar product 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: D1E/sqb850MP 1) Take the reductive sum out of the loop, leaving a regular vector addition in the loop. 2) Merge the addition and the multiplication. 3) Unroll. Before: scalarproduct_float_rvv_f32: 832.5 After: scalarproduct_float_rvv_f32: 275.2 --- libavutil/riscv/float_dsp_rvv.S | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S index 77961b7387..c80fde2f7e 100644 --- a/libavutil/riscv/float_dsp_rvv.S +++ b/libavutil/riscv/float_dsp_rvv.S @@ -166,20 +166,21 @@ endfunc // a0 = (a0).(a1) [0..a2-1] func ff_scalarproduct_float_rvv, zve32f - vsetivli zero, 1, e32, m1, ta, ma - vmv.s.x v8, zero + vsetvli t0, zero, e32, m8, ta, ma + vmv.v.x v8, zero + vmv.s.x v0, zero 1: - vsetvli t0, a2, e32, m1, ta, ma + vsetvli t0, a2, e32, m8, tu, ma vle32.v v16, (a0) sub a2, a2, t0 vle32.v v24, (a1) sh2add a0, t0, a0 - vfmul.vv v16, v16, v24 + vfmacc.vv v8, v16, v24 sh2add a1, t0, a1 - vfredusum.vs v8, v16, v8 bnez a2, 1b - vfmv.f.s fa0, v8 + vfredusum.vs v0, v8, v0 + vfmv.f.s fa0, v0 NOHWF fmv.x.w a0, fa0 ret endfunc