FFmpeg
libavutil
riscv
cpu.c
Go to the documentation of this file.
1
/*
2
* Copyright © 2022 Rémi Denis-Courmont.
3
*
4
* This file is part of FFmpeg.
5
*
6
* FFmpeg is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* FFmpeg is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with FFmpeg; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
#include "
libavutil/cpu.h
"
22
#include "
libavutil/cpu_internal.h
"
23
#include "
libavutil/log.h
"
24
#include "config.h"
25
26
#if HAVE_GETAUXVAL
27
#include <sys/auxv.h>
28
#define HWCAP_RV(letter) (1ul << ((letter) - 'A'))
29
#endif
30
31
int
ff_get_cpu_flags_riscv
(
void
)
32
{
33
int
ret
= 0;
34
#if HAVE_GETAUXVAL
35
const
unsigned
long
hwcap = getauxval(AT_HWCAP);
36
37
if
(hwcap & HWCAP_RV(
'I'
))
38
ret
|=
AV_CPU_FLAG_RVI
;
39
if
(hwcap & HWCAP_RV(
'F'
))
40
ret
|=
AV_CPU_FLAG_RVF
;
41
if
(hwcap & HWCAP_RV(
'D'
))
42
ret
|=
AV_CPU_FLAG_RVD
;
43
if
(hwcap & HWCAP_RV(
'B'
))
44
ret
|=
AV_CPU_FLAG_RVB_BASIC
;
45
46
/* The V extension implies all Zve* functional subsets */
47
if
(hwcap & HWCAP_RV(
'V'
))
48
ret
|=
AV_CPU_FLAG_RVV_I32
|
AV_CPU_FLAG_RVV_I64
49
|
AV_CPU_FLAG_RVV_F32
|
AV_CPU_FLAG_RVV_F64
;
50
#endif
51
52
#ifdef __riscv_i
53
ret
|=
AV_CPU_FLAG_RVI
;
54
#endif
55
#if defined (__riscv_flen) && (__riscv_flen >= 32)
56
ret
|=
AV_CPU_FLAG_RVF
;
57
#if (__riscv_flen >= 64)
58
ret
|=
AV_CPU_FLAG_RVD
;
59
#endif
60
#endif
61
62
#ifdef __riscv_zbb
63
ret
|=
AV_CPU_FLAG_RVB_BASIC
;
64
#endif
65
66
/* If RV-V is enabled statically at compile-time, check the details. */
67
#ifdef __riscv_vectors
68
ret
|=
AV_CPU_FLAG_RVV_I32
;
69
#if __riscv_v_elen >= 64
70
ret
|=
AV_CPU_FLAG_RVV_I64
;
71
#endif
72
#if __riscv_v_elen_fp >= 32
73
ret
|=
AV_CPU_FLAG_RVV_F32
;
74
#if __riscv_v_elen_fp >= 64
75
ret
|=
AV_CPU_FLAG_RVV_F64
;
76
#endif
77
#endif
78
#endif
79
80
return
ret
;
81
}
AV_CPU_FLAG_RVB_BASIC
#define AV_CPU_FLAG_RVB_BASIC
Basic bit-manipulations.
Definition:
cpu.h:89
AV_CPU_FLAG_RVF
#define AV_CPU_FLAG_RVF
F (single precision FP)
Definition:
cpu.h:83
AV_CPU_FLAG_RVV_F64
#define AV_CPU_FLAG_RVV_F64
Vectors of double's.
Definition:
cpu.h:88
AV_CPU_FLAG_RVV_F32
#define AV_CPU_FLAG_RVV_F32
Vectors of float's */.
Definition:
cpu.h:86
cpu_internal.h
AV_CPU_FLAG_RVD
#define AV_CPU_FLAG_RVD
D (double precision FP)
Definition:
cpu.h:84
cpu.h
log.h
AV_CPU_FLAG_RVV_I32
#define AV_CPU_FLAG_RVV_I32
Vectors of 8/16/32-bit int's */.
Definition:
cpu.h:85
ret
ret
Definition:
filter_design.txt:187
AV_CPU_FLAG_RVI
#define AV_CPU_FLAG_RVI
I (full GPR bank)
Definition:
cpu.h:82
AV_CPU_FLAG_RVV_I64
#define AV_CPU_FLAG_RVV_I64
Vectors of 64-bit int's */.
Definition:
cpu.h:87
ff_get_cpu_flags_riscv
int ff_get_cpu_flags_riscv(void)
Definition:
cpu.c:31
Generated on Tue Feb 28 2023 21:34:11 for FFmpeg by
1.8.17