LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 11-12-2003, 02:09 PM   #1
drivingon9
LQ Newbie
 
Registered: Nov 2003
Posts: 3

Rep: Reputation: 0
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
 
Old 11-12-2003, 02:19 PM   #2
evil_Tak
Member
 
Registered: Oct 2003
Distribution: Debian/unstable
Posts: 85

Rep: Reputation: 15
You might want to check out the code MPlayer uses for runtime cpu detection.
 
Old 11-13-2003, 10:46 AM   #3
jpc82
Member
 
Registered: Oct 2001
Distribution: Gentoo
Posts: 139

Rep: Reputation: 15
Would it be possible to just read in /proc/cpuinfo and search for "sse" or sse2"
 
Old 11-13-2003, 11:21 AM   #4
TheOneKEA
Member
 
Registered: Oct 2003
Location: Somewhere in Surrey
Distribution: Debian GNU/Linux 7.4.0 (amd64) w/kernel 3.13.0
Posts: 279

Rep: Reputation: 30
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.
 
Old 11-13-2003, 12:02 PM   #5
drivingon9
LQ Newbie
 
Registered: Nov 2003
Posts: 3

Original Poster
Rep: Reputation: 0
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.
 
Old 11-13-2003, 02:04 PM   #6
MartinN
Member
 
Registered: Nov 2003
Location: Ronneby, Sweden
Posts: 555

Rep: Reputation: 30
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
 
Old 11-13-2003, 06:31 PM   #7
drivingon9
LQ Newbie
 
Registered: Nov 2003
Posts: 3

Original Poster
Rep: Reputation: 0
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.
 
Old 11-14-2003, 06:42 AM   #8
MartinN
Member
 
Registered: Nov 2003
Location: Ronneby, Sweden
Posts: 555

Rep: Reputation: 30
Quote:
Originally posted by drivingon9

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

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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
checking for kernel support scott.anderson Linux - Software 3 07-22-2005 10:53 AM
Is it possible to use intel MMX/SSE/SSE2 with lookup tables? shy Programming 2 06-24-2005 04:50 AM
Slackware 10, checking hardware support Datamike Slackware 3 11-04-2004 04:53 PM
FPU and SSE control word and processes proberts9999 Linux - General 0 08-20-2003 11:03 PM
Want P4, SSE2 output from 386 GCC Wondre Programming 2 01-09-2003 12:03 PM


All times are GMT -5. The time now is 06:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration