diff options
author | Rémi Denis-Courmont <remi@remlab.net> | 2024-05-29 18:41:07 +0300 |
---|---|---|
committer | Rémi Denis-Courmont <remi@remlab.net> | 2024-06-01 18:05:58 +0300 |
commit | eed0a1d3d4524e1e87aca0e75e4bec09833f76f4 (patch) | |
tree | 5093b618bb4e84b3153f14c6dff8f7b1ec6b014d | |
parent | fc85aff72f197d07751ef76cf4e9744f720d9f3e (diff) | |
download | ffmpeg-eed0a1d3d4524e1e87aca0e75e4bec09833f76f4.tar.gz |
lavu/lls: R-V V update_lls
update_lls_8_c: 7.5
update_lls_8_rvv_f64: 4.2
update_lls_12_c: 14.5
update_lls_12_rvv_f64: 5.7
-rw-r--r-- | libavutil/lls.c | 4 | ||||
-rw-r--r-- | libavutil/lls.h | 1 | ||||
-rw-r--r-- | libavutil/riscv/Makefile | 4 | ||||
-rw-r--r-- | libavutil/riscv/lls_init.c | 57 | ||||
-rw-r--r-- | libavutil/riscv/lls_rvv.S | 39 |
5 files changed, 103 insertions, 2 deletions
diff --git a/libavutil/lls.c b/libavutil/lls.c index 1096ae69d5..fe8f55976d 100644 --- a/libavutil/lls.c +++ b/libavutil/lls.c @@ -112,7 +112,9 @@ av_cold void avpriv_init_lls(LLSModel *m, int indep_count) m->indep_count = indep_count; m->update_lls = update_lls; m->evaluate_lls = evaluate_lls; -#if ARCH_X86 +#if ARCH_RISCV + ff_init_lls_riscv(m); +#elif ARCH_X86 ff_init_lls_x86(m); #endif } diff --git a/libavutil/lls.h b/libavutil/lls.h index 0709275822..7acef4eff8 100644 --- a/libavutil/lls.h +++ b/libavutil/lls.h @@ -57,6 +57,7 @@ typedef struct LLSModel { } LLSModel; void avpriv_init_lls(LLSModel *m, int indep_count); +void ff_init_lls_riscv(LLSModel *m); void ff_init_lls_x86(LLSModel *m); void avpriv_solve_lls(LLSModel *m, double threshold, unsigned short min_order); diff --git a/libavutil/riscv/Makefile b/libavutil/riscv/Makefile index 1597154ba5..7e9a51194b 100644 --- a/libavutil/riscv/Makefile +++ b/libavutil/riscv/Makefile @@ -1,5 +1,7 @@ OBJS += riscv/float_dsp_init.o \ riscv/fixed_dsp_init.o \ + riscv/lls_init.o \ riscv/cpu.o RVV-OBJS += riscv/float_dsp_rvv.o \ - riscv/fixed_dsp_rvv.o + riscv/fixed_dsp_rvv.o \ + riscv/lls_rvv.o diff --git a/libavutil/riscv/lls_init.c b/libavutil/riscv/lls_init.c new file mode 100644 index 0000000000..b1317dc925 --- /dev/null +++ b/libavutil/riscv/lls_init.c @@ -0,0 +1,57 @@ +/* + * Copyright © 2024 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 <assert.h> +#include <stdint.h> + +#include "config.h" +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/riscv/cpu.h" +#include "libavutil/lls.h" + +void ff_lls_update_covariance_rvv(double covar[][36], const double *var, + int count); +double ff_scalarproduct_double_rvv(const double *, const double *, size_t); + +static void ff_lls_update_rvv(struct LLSModel *m, const double *var) +{ + ff_lls_update_covariance_rvv(m->covariance, var, m->indep_count + 1); +} + +static double ff_lls_evaluate_rvv(struct LLSModel *m, const double *var, + int order) +{ + return ff_scalarproduct_double_rvv(m->coeff[order], var, order + 1); +} + +av_cold void ff_init_lls_riscv(LLSModel *m) +{ +#if HAVE_RVV + int flags = av_get_cpu_flags(); + + if ((flags & AV_CPU_FLAG_RVB_ADDR) && (flags & AV_CPU_FLAG_RVV_F64)) { + if ((flags & AV_CPU_FLAG_RVB_BASIC) && + ff_get_rv_vlenb() > m->indep_count) + m->update_lls = ff_lls_update_rvv; + m->evaluate_lls = ff_lls_evaluate_rvv; + } +#endif +} diff --git a/libavutil/riscv/lls_rvv.S b/libavutil/riscv/lls_rvv.S new file mode 100644 index 0000000000..e0e6f1008e --- /dev/null +++ b/libavutil/riscv/lls_rvv.S @@ -0,0 +1,39 @@ +/* + * Copyright © 2024 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 "asm.S" + +func ff_lls_update_covariance_rvv, zve64d, zbb + vtype_vli t0, a2, t1, e64, ta, ma + vsetvl zero, a2, t0 + vle64.v v8, (a1) +1: + vfmv.f.s ft0, v8 + vsetvl zero, a2, t0 + vle64.v v16, (a0) + vfmacc.vf v16, ft0, v8 + addi a2, a2, -1 + vslidedown.vi v8, v8, 1 + vse64.v v16, (a0) + addi a0, a0, (36 + 1) * 8 # 1 row + 1 element + bnez a2, 1b + + ret +endfunc |