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
This commit is contained in:
Rémi Denis-Courmont 2024-05-29 18:41:07 +03:00
parent fc85aff72f
commit eed0a1d3d4
5 changed files with 103 additions and 2 deletions

View File

@ -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
}

View File

@ -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);

View File

@ -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

View File

@ -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
}

39
libavutil/riscv/lls_rvv.S Normal file
View File

@ -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