[FFmpeg-devel] [PATCH] fftools/cmdutils.c: Add cmd line option to override detection of cpu count

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Jun 6 15:35:16 EEST 2021


Thilo Borgmann:
> Hi,
> 
> add an option to override auto-detection of cpu count. Defaults to auto-detection, of course.
> 
> -Thilo
> 

> 
>  doc/fftools-common-opts.texi |  7 +++++++
>  fftools/cmdutils.c           | 27 +++++++++++++++++++++++++++
>  fftools/cmdutils.h           |  7 +++++++
>  libavutil/cpu.c              | 14 ++++++++++++++
>  libavutil/cpu.h              |  6 ++++++

The changes to libavutil and cmdutils should be in separate patches; and
of course the commit message should mention that you are changing
libavutil -- I would have nearly missed this patch (given that I don't
pay much attention to fftools in general).

> 
> diff --git a/libavutil/cpu.c b/libavutil/cpu.c
> index 52f6b9a3bf..ccd5b5adac 100644
> --- a/libavutil/cpu.c
> +++ b/libavutil/cpu.c

52f6b9a3bf is the state of cpu.c after
e387fcd01cb84d9493f3b96158addd2a85f086c6. This is completely outdated.

> 
> @@ -306,14 +307,27 @@ int av_cpu_count(void)
>      nb_cpus = sysinfo.dwNumberOfProcessors;
>  #endif
>  
> +    int count = atomic_load_explicit(&cpu_count, memory_order_relaxed);
> +
>      if (!printed) {
>          av_log(NULL, AV_LOG_DEBUG, "detected %d logical cores\n", nb_cpus);
> +        if (count > 0) {
> +            av_log(NULL, AV_LOG_DEBUG, "overriding to %d logical cores\n", count);
> +        }
>          printed = 1;
>      }
>  
> +    if (count > 0) {
> +        nb_cpus = count;
> +    }
> +
>      return nb_cpus;
>  }
>  
In particular, this hunk doesn't apply to git master at all any more
(did I already mention that cpu.c only has 245 lines atm, not >300?).
And the declaration of count would lead to a statement-after-declaration
warning.

- Andreas


More information about the ffmpeg-devel mailing list