[FFmpeg-devel] [PATCH] Runtime detection for the number of processors/cores

François Revol revol
Wed May 21 15:54:15 CEST 2008


> > 
> > Philipp Meinen wrote:
> > > Hello FFmpeg Team
> > >
> > > The attached patch is an attempt to allow runtime detection for 
> > > the
> > > number of online processors/cores instead of having to specify 
> > > the
> > > number of threads. The idea is to type:
> > >     ffmpeg -threads 0 ....
> > > to use as many threads as processors/cores are online.
> > >
> > > I guess cmdutils.c/h is not the right file to place the new
> > > detection function. To which file should this function belong?
> > >
> > > Comments welcome :)
> > 
> > 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.

It's POSIX only anyway so it has to be platform dependant...

Hmm doesn't pthread have a less linuxish call for that btw ?

Else one can still #ifdef __linux__ to use sched_get_affinity and fall 
back to sysconf.

Fran?ois.





More information about the ffmpeg-devel mailing list