FFmpeg
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 
32 {
33  int ret = 0;
34 #if HAVE_GETAUXVAL
35  const unsigned long hwcap = getauxval(AT_HWCAP);
36 
37  if (hwcap & HWCAP_RV('I'))
39  if (hwcap & HWCAP_RV('F'))
41  if (hwcap & HWCAP_RV('D'))
43  if (hwcap & HWCAP_RV('B'))
45 
46  /* The V extension implies all Zve* functional subsets */
47  if (hwcap & HWCAP_RV('V'))
50 #endif
51 
52 #ifdef __riscv_i
54 #endif
55 #if defined (__riscv_flen) && (__riscv_flen >= 32)
57 #if (__riscv_flen >= 64)
59 #endif
60 #endif
61 
62 #ifdef __riscv_zba
64 #endif
65 #ifdef __riscv_zbb
67 #endif
68 
69  /* If RV-V is enabled statically at compile-time, check the details. */
70 #ifdef __riscv_vector
72 #if __riscv_v_elen >= 64
74 #endif
75 #if __riscv_v_elen_fp >= 32
77 #if __riscv_v_elen_fp >= 64
79 #endif
80 #endif
81 #endif
82 
83  return ret;
84 }
AV_CPU_FLAG_RVB_BASIC
#define AV_CPU_FLAG_RVB_BASIC
Basic bit-manipulations.
Definition: cpu.h:91
AV_CPU_FLAG_RVF
#define AV_CPU_FLAG_RVF
F (single precision FP)
Definition: cpu.h:85
AV_CPU_FLAG_RVV_F64
#define AV_CPU_FLAG_RVV_F64
Vectors of double's.
Definition: cpu.h:90
AV_CPU_FLAG_RVV_F32
#define AV_CPU_FLAG_RVV_F32
Vectors of float's *‍/.
Definition: cpu.h:88
cpu_internal.h
AV_CPU_FLAG_RVB_ADDR
#define AV_CPU_FLAG_RVB_ADDR
Address bit-manipulations.
Definition: cpu.h:92
AV_CPU_FLAG_RVD
#define AV_CPU_FLAG_RVD
D (double precision FP)
Definition: cpu.h:86
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:87
ret
ret
Definition: filter_design.txt:187
AV_CPU_FLAG_RVI
#define AV_CPU_FLAG_RVI
I (full GPR bank)
Definition: cpu.h:84
AV_CPU_FLAG_RVV_I64
#define AV_CPU_FLAG_RVV_I64
Vectors of 64-bit int's *‍/.
Definition: cpu.h:89
ff_get_cpu_flags_riscv
int ff_get_cpu_flags_riscv(void)
Definition: cpu.c:31