[FFmpeg-devel] libavutil simd

Nigel Pearson nigel
Tue Oct 2 05:40:00 CEST 2007


> 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:

% /usr/bin/hostinfo
Mach kernel version:
          Darwin Kernel Version 7.9.0:
Wed Mar 30 20:11:17 PST 2005; root:xnu/xnu-517.12.7.obj~1/RELEASE_PPC


Kernel configured for a single processor only.
1 processor is physically available.
Processor type: ppc7450 (PowerPC 7450)
Processor active: 0
Primary memory available: 512.00 megabytes.
Default processor set: 52 tasks, 134 threads, 1 processors
Load average: 0.16, Mach factor: 0.83



2) Generate such a file first:

mkdir("/proc");
system("echo -n 'processor: ' >/proc/cpuinfo");
system("machine >>/proc/cpuinfo");
    system("echo -n 'cpu family: ' >/proc/cpuinfo");
    system("arch >>/proc/cpuinfo");


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





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.



And then there is gcc sprinkling Altivec code throughout.
But that is a problem for the compiler maintainers?

--
Nigel Pearson, nigel at ind.tansu.com.au|"In this city I confess;
Telstra Net. Eng., Sydney, Australia | god is mammon, more is less.
Office: 9202 3900    Fax:  9261 3912 | Off like lemmings at the gun!
Mobile: 0408 664435  Home: 9792 6998 | I know better, still I run"




More information about the ffmpeg-devel mailing list