[FFmpeg-devel] libavutil simd

Rich Felker dalias
Tue Oct 2 06:16:27 CEST 2007


On Tue, Oct 02, 2007 at 01:40:00PM +1000, Nigel Pearson wrote:
> > Alternatively, if there's a reliable way such as /proc/cpuinfo
> 
> 
> OK. There are a few alternatives on OS X:
> 
> 
> 1) There is a utility instead of a file.
> Not the same format, but definitely parseable:

Not useful. A utility means forking. Lookup how this utility gets its
information and duplicate that.

> 3) Using the OS X Carbon compatibility library
>     to ask the Gestalt Manager:
> 
> SInt32 CPU;
> 
> if (Gestalt(gestaltNativeCPUfamily, &CPU) == noErr)
>      altivec = (CPU == gestaltCPUG4     ||  // G4
>                 CPU == gestaltCPUG47450 ||  // ,,
>                 CPU == gestaltCPUApollo ||  // ,,
>                 CPU == gestaltCPUG47447 ||  // G4 mobile
>                 CPU == gestaltCPU970    ||  // G5
>                 CPU == gestaltCPU970FX)     // ,,
> else
>      altivec = false;  // probably

Not a bad idea, but your test is backwards. You should assume altivec
is available unless one of a fixed set of pre-altivec cpu types is
detected. The number of cpu models without altivec is already
fixed/finite. The number of cpu models with altivec is unlimited since
all future ones will have it.

> None of these are really light-weight enough to be called
> multiple times, though. I suspect the Amiga ones are similar.
> So either a "call once" guard, or leave this as example code,
> and let the calling application deal with it.

Of course not. Saving the result is fine. There's no race condition or
reentrancy issues since the same value would be written every time
anyway.

Rich




More information about the ffmpeg-devel mailing list