From patchwork Thu Sep 22 18:37:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?R=C3=A9mi_Denis-Courmont?= X-Patchwork-Id: 38159 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp514925pzh; Thu, 22 Sep 2022 11:38:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5ODabcduX6BiRjgwb30C9F909NNo3YuNukQyXcwbJgQbYLOqjo9Ey3yIWpL2nokFTZKbTc X-Received: by 2002:a17:906:9753:b0:781:be0a:5b7 with SMTP id o19-20020a170906975300b00781be0a05b7mr4084330ejy.752.1663871882532; Thu, 22 Sep 2022 11:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663871882; cv=none; d=google.com; s=arc-20160816; b=IEFG41m43hAI44C8TnwuSSK2A3aXfq5TNKNUEqtSWO+8GDE7MoxMwTk48pBtVopxHu IFjKdVwHjkZPhUv0jywFkuI7LN5Q1XuQpwmLwfQVsPoOwnkLJzCMbXVI7S+ZqUUmRLDc kiHoxcjFj5U2vCp/y82zF1I3wjVYXLkeBNqVDWSo68FY8TZ/66DR0s6s+UZ3DGnNMuj8 eogmfg3YRoXyLxE3cW9ZI4F9ELPLbjQGlRhbNomRXvy67mpd6dwsjaVVqToYoismWory YY0hC7fYDu93qZcgIEDRg5dxdF/gqQl0mtFq1yG3WAuY0YZP/8JwBKZ62ulPJe7czrht HlHg== 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:references:in-reply-to:message-id :date:to:from:delivered-to; bh=V4B/YU9eFKm2OOzroHLUVbA+Oo/nZPjwJPGo0pdRm3o=; b=aDWNwCeSXECrsWA1RZXdHLfpsGCBPf0y+Q7WZudegisnLrd7g6XtQXtSCN4Km/8M+X 2NcFLJBpl01/ShL2c3wWh5nGIAr2hDBstCQ40HgRULvX4cvjRmi97UcxAJplOLcJt54q nI/pe7xLfeEZdcAIZDIVq6AIT99+vVIa+pXlxTY3iziXHaGVxCmc13h9gcVGgW0cFNfh kAa0ZCgFYvULdJELrK0MNSobioQMQQA+1uim+Qh8waQuP1hl61D2p2eEr1q/14RjYAeV DBPeB1eBSVqnHAMog0faQhNRatrU+CYYBS95EItKaFflI6CBqTO1obh8OYi9x/ESAYJh aBBg== 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 m9-20020a056402510900b00451b2764a9asi6531560edd.387.2022.09.22.11.38.02; Thu, 22 Sep 2022 11:38:02 -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 1E87668BB86; Thu, 22 Sep 2022 21:37:37 +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 F3C6068B94F for ; Thu, 22 Sep 2022 21:37:31 +0300 (EEST) Received: from basile.remlab.net (localhost [IPv6:::1]) by ursule.remlab.net (Postfix) with ESMTP id 60FD4C00B3 for ; Thu, 22 Sep 2022 21:37:27 +0300 (EEST) From: remi@remlab.net To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Sep 2022 21:37:04 +0300 Message-Id: <20220922183726.38624-7-remi@remlab.net> X-Mailer: git-send-email 2.37.2 In-Reply-To: <12078904.O9o76ZdvQC@basile.remlab.net> References: <12078904.O9o76ZdvQC@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/29] lavu/floatdsp: RISC-V V vector_fmul_scalar 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: ghrdTI8BhDX9 From: Rémi Denis-Courmont This is based on existing code from the VLC git tree with two minor changes to account for the different function prototypes. --- libavutil/float_dsp.c | 2 ++ libavutil/float_dsp.h | 1 + libavutil/riscv/Makefile | 4 +++- libavutil/riscv/float_dsp_init.c | 39 +++++++++++++++++++++++++++++++ libavutil/riscv/float_dsp_rvv.S | 40 ++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 libavutil/riscv/float_dsp_init.c create mode 100644 libavutil/riscv/float_dsp_rvv.S diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c index 8676c8b0f8..742dd679d2 100644 --- a/libavutil/float_dsp.c +++ b/libavutil/float_dsp.c @@ -156,6 +156,8 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact) ff_float_dsp_init_arm(fdsp); #elif ARCH_PPC ff_float_dsp_init_ppc(fdsp, bit_exact); +#elif ARCH_RISCV + ff_float_dsp_init_riscv(fdsp); #elif ARCH_X86 ff_float_dsp_init_x86(fdsp); #elif ARCH_MIPS diff --git a/libavutil/float_dsp.h b/libavutil/float_dsp.h index 9c664592bd..7cad9fc622 100644 --- a/libavutil/float_dsp.h +++ b/libavutil/float_dsp.h @@ -205,6 +205,7 @@ float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len); void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp); void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp); void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict); +void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp); void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp); void ff_float_dsp_init_mips(AVFloatDSPContext *fdsp); diff --git a/libavutil/riscv/Makefile b/libavutil/riscv/Makefile index 1f818043dc..89a8d0d990 100644 --- a/libavutil/riscv/Makefile +++ b/libavutil/riscv/Makefile @@ -1 +1,3 @@ -OBJS += riscv/cpu.o +OBJS += riscv/float_dsp_init.o \ + riscv/cpu.o +RVV-OBJS += riscv/float_dsp_rvv.o diff --git a/libavutil/riscv/float_dsp_init.c b/libavutil/riscv/float_dsp_init.c new file mode 100644 index 0000000000..de567c50d2 --- /dev/null +++ b/libavutil/riscv/float_dsp_init.c @@ -0,0 +1,39 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/float_dsp.h" + +void ff_vector_fmul_scalar_rvv(float *dst, const float *src, float mul, + int len); + +av_cold void ff_float_dsp_init_riscv(AVFloatDSPContext *fdsp) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_RV_ZVE32F) + fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_rvv; +#endif +} diff --git a/libavutil/riscv/float_dsp_rvv.S b/libavutil/riscv/float_dsp_rvv.S new file mode 100644 index 0000000000..5095ed5bfc --- /dev/null +++ b/libavutil/riscv/float_dsp_rvv.S @@ -0,0 +1,40 @@ +/* + * Copyright © 2022 Rémi Denis-Courmont. + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "asm.S" + +// (a0) = (a1) * fa0 [0..a2-1] +func ff_vector_fmul_scalar_rvv, zve32f +NOHWF fmv.w.x fa0, a2 +NOHWF mv a2, a3 +1: + vsetvli t0, a2, e32, m1, ta, ma + slli t1, t0, 2 + vle32.v v16, (a1) + add a1, a1, t1 + vfmul.vf v16, v16, fa0 + sub a2, a2, t0 + vse32.v v16, (a0) + add a0, a0, t1 + bnez a2, 1b + + ret +endfunc