[FFmpeg-devel] [PATCH] Runtime detection for the number of processors/cores
Wed May 21 18:09:37 CEST 2008
> >> > This is the wrong way to go about it. The number of processors
> > > > in
> >> > the
> >> > machine is not interesting, the number of processors we're
> > > > running
> >> > on
> >> > is. On Linux, this information can be found from
> >> > sched_get_affinity().
> >> > Other systems have other methods.
> >> _SC_NPROCESSORS_ONLN Number of processors online
> >> Seems to mean the same to me, unlike:
> > Unless of course sched_get_affinity() returns a subset mask for
> > NUMA
> > machines, then disregard.
> sched_get_affinity() returns the processors on which the process is
> allowed to run, which can be any subset of the processors currently
Right, processes can be bound to a subset of cpus.
> (On a normal desktop system, all processors are always online.)
In BeOS one can disable any cpu live at runtime though... :D
On big NUMA systems I believe CPUs can be hotplugged...
At least Multics could do that :D
> > It's POSIX only anyway so it has to be platform dependant...
> It's not POSIX, at least not anywhere that I can find it.
sysconf(_SC_NPROCESSORS_ONLN), or sysconf() at least, I meant.
sched_* is linux only.
> > Hmm doesn't pthread have a less linuxish call for that btw ?
> I couldn't find one.
> > Else one can still #ifdef __linux__ to use sched_get_affinity and
> > fall
> > back to sysconf.
> #ifdef __some_os_or_other__ is banned from FFmpeg.
That was intended for the foothread.c files, which are platform
Of course you can also just check for sched_get_affinity in configure
if ifdef gives your purulent buttons.
More information about the ffmpeg-devel