[FFmpeg-devel] [PATCH] fftools/cmdutils.c: Add cmd line option to override detection of cpu count
Thilo Borgmann
thilo.borgmann at mail.de
Fri Jul 16 11:20:20 EEST 2021
Am 04.07.21 um 14:31 schrieb 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.
>>
>> Yes, messed up branches for the patch, thx!
>>
>>
>>>>
>>>> @@ -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.
>>
>> Done locally to apply to today's HEAD. I think I'll wait with sending both patches once we decided on atomic loads in "[PATCH] Stop using _explicit atomic operations where not necessary.".
>
> Discussion on atomic loads appear to have stalled mid-June... If there are no hard feeling, I'll push this version soon as the explicit (or not) loads can then be changed later.
Pushed, thanks!
-Thilo
More information about the ffmpeg-devel
mailing list