diff mbox series

[FFmpeg-devel,v3] riscv: Tweak names of cpu flags, print flags in libavutil/tests/cpu

Message ID 20231217123608.2839656-1-martin@martin.st
State Accepted
Headers show
Series [FFmpeg-devel,v3] riscv: Tweak names of cpu flags, print flags in libavutil/tests/cpu | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Martin Storsjö Dec. 17, 2023, 12:36 p.m. UTC
The names of the cpu flags, when parsed from a string with
av_parse_cpu_caps, are parsed by the libavutil eval functions. These
interpret dashes as subtractions. Therefore, these previous cpu flag
names haven't been possible to set.

Use the official names for these extensions, as the previous ad-hoc
names wasn't parseable.

libavutil/tests/cpu tests that the cpu flags can be set, and prints
the detected flags.
---
v3: Fixed the name zve64d. Kept the cpuflags names all lowercase for
consistency with the other cpuflags.
---
 libavutil/cpu.c       | 12 ++++++------
 libavutil/tests/cpu.c | 10 ++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)

Comments

Rémi Denis-Courmont Dec. 17, 2023, 3:09 p.m. UTC | #1
Le sunnuntaina 17. joulukuuta 2023, 14.36.08 EET Martin Storsjö a écrit :
> The names of the cpu flags, when parsed from a string with
> av_parse_cpu_caps, are parsed by the libavutil eval functions. These
> interpret dashes as subtractions. Therefore, these previous cpu flag
> names haven't been possible to set.
> 
> Use the official names for these extensions, as the previous ad-hoc
> names wasn't parseable.
> 
> libavutil/tests/cpu tests that the cpu flags can be set, and prints
> the detected flags.

Acked-by: Rémi Denis-Courmont <remi@remlab.net>

> ---
> v3: Fixed the name zve64d. Kept the cpuflags names all lowercase for
> consistency with the other cpuflags.
> ---
>  libavutil/cpu.c       | 12 ++++++------
>  libavutil/tests/cpu.c | 10 ++++++++++
>  2 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/libavutil/cpu.c b/libavutil/cpu.c
> index 1e0607d581..48d195168c 100644
> --- a/libavutil/cpu.c
> +++ b/libavutil/cpu.c
> @@ -186,12 +186,12 @@ int av_parse_cpu_caps(unsigned *flags, const char *s)
>          { "rvi",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVI 
>     },    .unit = "flags" }, { "rvf",      NULL, 0, AV_OPT_TYPE_CONST, {
> .i64 = AV_CPU_FLAG_RVF      },    .unit = "flags" }, { "rvd",      NULL, 0,
> AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVD      },    .unit = "flags" }, -
>        { "rvv-i32",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_RVV_I32 },     .unit = "flags" }, -        { "rvv-f32",  NULL,
> 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F32 },     .unit = "flags"
> }, -        { "rvv-i64",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_RVV_I64 },     .unit = "flags" }, -        { "rvv",      NULL,
> 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F64 },     .unit = "flags"
> }, -        { "rvb-addr",NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_RVB_ADDR },   .unit = "flags" }, -        { "rvb-basic",NULL,
> 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB_BASIC },   .unit = "flags"
> }, +        { "zve32x",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_RVV_I32  },    .unit = "flags" }, +        { "zve32f",   NULL,
> 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F32  },    .unit = "flags"
> }, +        { "zve64x",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_RVV_I64  },    .unit = "flags" }, +        { "zve64d",   NULL,
> 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F64  },    .unit = "flags"
> }, +        { "zba",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> AV_CPU_FLAG_RVB_ADDR },    .unit = "flags" }, +        { "zbb",      NULL,
> 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB_BASIC },   .unit = "flags"
> }, #endif
>          { NULL },
>      };
> diff --git a/libavutil/tests/cpu.c b/libavutil/tests/cpu.c
> index 200f20388a..d91bfeab5c 100644
> --- a/libavutil/tests/cpu.c
> +++ b/libavutil/tests/cpu.c
> @@ -84,6 +84,16 @@ static const struct {
>  #elif ARCH_LOONGARCH
>      { AV_CPU_FLAG_LSX,       "lsx"        },
>      { AV_CPU_FLAG_LASX,      "lasx"       },
> +#elif ARCH_RISCV
> +    { AV_CPU_FLAG_RVI,       "rvi"        },
> +    { AV_CPU_FLAG_RVF,       "rvf"        },
> +    { AV_CPU_FLAG_RVD,       "rvd"        },
> +    { AV_CPU_FLAG_RVB_ADDR,  "zba"        },
> +    { AV_CPU_FLAG_RVB_BASIC, "zbb"        },
> +    { AV_CPU_FLAG_RVV_I32,   "zve32x"     },
> +    { AV_CPU_FLAG_RVV_F32,   "zve32f"     },
> +    { AV_CPU_FLAG_RVV_I64,   "zve64x"     },
> +    { AV_CPU_FLAG_RVV_F64,   "zve64d"     },
>  #endif
>      { 0 }
>  };
James Almer Dec. 17, 2023, 3:18 p.m. UTC | #2
On 12/17/2023 9:36 AM, Martin Storsjö wrote:
> The names of the cpu flags, when parsed from a string with
> av_parse_cpu_caps, are parsed by the libavutil eval functions. These
> interpret dashes as subtractions. Therefore, these previous cpu flag
> names haven't been possible to set.
> 
> Use the official names for these extensions, as the previous ad-hoc
> names wasn't parseable.
> 
> libavutil/tests/cpu tests that the cpu flags can be set, and prints
> the detected flags.
> ---
> v3: Fixed the name zve64d. Kept the cpuflags names all lowercase for
> consistency with the other cpuflags.
> ---
>   libavutil/cpu.c       | 12 ++++++------
>   libavutil/tests/cpu.c | 10 ++++++++++
>   2 files changed, 16 insertions(+), 6 deletions(-)

LGMT with a minor bump, as this changes how av_parse_cpu_caps() parses 
strings.

> 
> diff --git a/libavutil/cpu.c b/libavutil/cpu.c
> index 1e0607d581..48d195168c 100644
> --- a/libavutil/cpu.c
> +++ b/libavutil/cpu.c
> @@ -186,12 +186,12 @@ int av_parse_cpu_caps(unsigned *flags, const char *s)
>           { "rvi",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVI      },    .unit = "flags" },
>           { "rvf",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVF      },    .unit = "flags" },
>           { "rvd",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVD      },    .unit = "flags" },
> -        { "rvv-i32",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I32 },     .unit = "flags" },
> -        { "rvv-f32",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F32 },     .unit = "flags" },
> -        { "rvv-i64",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I64 },     .unit = "flags" },
> -        { "rvv",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F64 },     .unit = "flags" },
> -        { "rvb-addr",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB_ADDR },   .unit = "flags" },
> -        { "rvb-basic",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB_BASIC },   .unit = "flags" },
> +        { "zve32x",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I32  },    .unit = "flags" },
> +        { "zve32f",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F32  },    .unit = "flags" },
> +        { "zve64x",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I64  },    .unit = "flags" },
> +        { "zve64d",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F64  },    .unit = "flags" },
> +        { "zba",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB_ADDR },    .unit = "flags" },
> +        { "zbb",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB_BASIC },   .unit = "flags" },
>   #endif
>           { NULL },
>       };
> diff --git a/libavutil/tests/cpu.c b/libavutil/tests/cpu.c
> index 200f20388a..d91bfeab5c 100644
> --- a/libavutil/tests/cpu.c
> +++ b/libavutil/tests/cpu.c
> @@ -84,6 +84,16 @@ static const struct {
>   #elif ARCH_LOONGARCH
>       { AV_CPU_FLAG_LSX,       "lsx"        },
>       { AV_CPU_FLAG_LASX,      "lasx"       },
> +#elif ARCH_RISCV
> +    { AV_CPU_FLAG_RVI,       "rvi"        },
> +    { AV_CPU_FLAG_RVF,       "rvf"        },
> +    { AV_CPU_FLAG_RVD,       "rvd"        },
> +    { AV_CPU_FLAG_RVB_ADDR,  "zba"        },
> +    { AV_CPU_FLAG_RVB_BASIC, "zbb"        },
> +    { AV_CPU_FLAG_RVV_I32,   "zve32x"     },
> +    { AV_CPU_FLAG_RVV_F32,   "zve32f"     },
> +    { AV_CPU_FLAG_RVV_I64,   "zve64x"     },
> +    { AV_CPU_FLAG_RVV_F64,   "zve64d"     },
>   #endif
>       { 0 }
>   };
Martin Storsjö Dec. 17, 2023, 9:58 p.m. UTC | #3
On Sun, 17 Dec 2023, James Almer wrote:

> On 12/17/2023 9:36 AM, Martin Storsjö wrote:
>> The names of the cpu flags, when parsed from a string with
>> av_parse_cpu_caps, are parsed by the libavutil eval functions. These
>> interpret dashes as subtractions. Therefore, these previous cpu flag
>> names haven't been possible to set.
>> 
>> Use the official names for these extensions, as the previous ad-hoc
>> names wasn't parseable.
>> 
>> libavutil/tests/cpu tests that the cpu flags can be set, and prints
>> the detected flags.
>> ---
>> v3: Fixed the name zve64d. Kept the cpuflags names all lowercase for
>> consistency with the other cpuflags.
>> ---
>>   libavutil/cpu.c       | 12 ++++++------
>>   libavutil/tests/cpu.c | 10 ++++++++++
>>   2 files changed, 16 insertions(+), 6 deletions(-)
>
> LGMT with a minor bump, as this changes how av_parse_cpu_caps() parses 
> strings.

Thanks, pushed with a minor bump.

// Martin
diff mbox series

Patch

diff --git a/libavutil/cpu.c b/libavutil/cpu.c
index 1e0607d581..48d195168c 100644
--- a/libavutil/cpu.c
+++ b/libavutil/cpu.c
@@ -186,12 +186,12 @@  int av_parse_cpu_caps(unsigned *flags, const char *s)
         { "rvi",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVI      },    .unit = "flags" },
         { "rvf",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVF      },    .unit = "flags" },
         { "rvd",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVD      },    .unit = "flags" },
-        { "rvv-i32",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I32 },     .unit = "flags" },
-        { "rvv-f32",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F32 },     .unit = "flags" },
-        { "rvv-i64",  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I64 },     .unit = "flags" },
-        { "rvv",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F64 },     .unit = "flags" },
-        { "rvb-addr",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB_ADDR },   .unit = "flags" },
-        { "rvb-basic",NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB_BASIC },   .unit = "flags" },
+        { "zve32x",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I32  },    .unit = "flags" },
+        { "zve32f",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F32  },    .unit = "flags" },
+        { "zve64x",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_I64  },    .unit = "flags" },
+        { "zve64d",   NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVV_F64  },    .unit = "flags" },
+        { "zba",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB_ADDR },    .unit = "flags" },
+        { "zbb",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_RVB_BASIC },   .unit = "flags" },
 #endif
         { NULL },
     };
diff --git a/libavutil/tests/cpu.c b/libavutil/tests/cpu.c
index 200f20388a..d91bfeab5c 100644
--- a/libavutil/tests/cpu.c
+++ b/libavutil/tests/cpu.c
@@ -84,6 +84,16 @@  static const struct {
 #elif ARCH_LOONGARCH
     { AV_CPU_FLAG_LSX,       "lsx"        },
     { AV_CPU_FLAG_LASX,      "lasx"       },
+#elif ARCH_RISCV
+    { AV_CPU_FLAG_RVI,       "rvi"        },
+    { AV_CPU_FLAG_RVF,       "rvf"        },
+    { AV_CPU_FLAG_RVD,       "rvd"        },
+    { AV_CPU_FLAG_RVB_ADDR,  "zba"        },
+    { AV_CPU_FLAG_RVB_BASIC, "zbb"        },
+    { AV_CPU_FLAG_RVV_I32,   "zve32x"     },
+    { AV_CPU_FLAG_RVV_F32,   "zve32f"     },
+    { AV_CPU_FLAG_RVV_I64,   "zve64x"     },
+    { AV_CPU_FLAG_RVV_F64,   "zve64d"     },
 #endif
     { 0 }
 };