LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Checking for SSE / SSE2 support (https://www.linuxquestions.org/questions/programming-9/checking-for-sse-sse2-support-115275/)

drivingon9 11-12-2003 01:09 PM

Checking for SSE / SSE2 support
 
In a program, does anyone know how one would check for SSE / SSE2 support being enabled in the OS without using exception handling/signals?

Thanks for any help!!
drivingon9

evil_Tak 11-12-2003 01:19 PM

You might want to check out the code MPlayer uses for runtime cpu detection.

jpc82 11-13-2003 09:46 AM

Would it be possible to just read in /proc/cpuinfo and search for "sse" or sse2"

TheOneKEA 11-13-2003 10:21 AM

Using /proc/cpuinfo is implicitly discouraged by the kernel folks, since the API may change in a nanosecond and is thus not stable, even though it has been for a longish while. Under 2.6, sysfs might have the CPU flags somewhere in an easy-to-parse place, but I doubt it.

See the mplayer program for how it detects SSE and SSE2.

drivingon9 11-13-2003 11:02 AM

Re: Checking for SSE / SSE2 support
 
Unfortunately, MPlayer uses signal handling. It executes an SSE/SSE2 instructions and catches the exception if the OS doesn't handle it. I was wondering if there was a cleaner way to do it.

Thanks.

MartinN 11-13-2003 01:04 PM

Use the assembler instruction CPUID

I found a small C program here that does pretty much exactly what you want:
http://www-ti.informatik.uni-tuebing...heim/software/

Martin

drivingon9 11-13-2003 05:31 PM

Quote:

Originally posted by MartinN
Use the assembler instruction CPUID

I found a small C program here that does pretty much exactly what you want:
http://www-ti.informatik.uni-tuebing...heim/software/

Martin

Can't do that.

CPUID will tell you whether the CPU supports SSE/SSE2, but not the OS.
The OS (linux in this case) can have SSE and/or SSE2 disabled.

MartinN 11-14-2003 05:42 AM

Quote:

Originally posted by drivingon9

The OS (linux in this case) can have SSE and/or SSE2 disabled.

:confused:
That was new to me. What do you mean by that? Is it possible for the OS to turn off certain instructions in the CPU, or is it just a question of whether the shared libs are compiled with SSE support?

Martin


All times are GMT -5. The time now is 02:13 PM.