views:

173

answers:

3

I've been looking at ways to determine the CPU, and its capabilities (eg SEE,SSE2,etc).

However all the ways I've found involved assembly code using the cpuid instruction. Given the differing ways of doing assembly in c/c++ between compilers and even targets (no inline assembly for 64bit targets under VC), id rather avoid that.

Is there some simple library around, or OS functions (for both windows and linux) for getting this information?

Currently I'm only interested in platforms using the x86 and x86-64 CPU's, and I defiantly need to support at least AMD and Intel.

A: 

This so hardware-dependent --- which is an aspect the OS usually shields you from --- that requiring it to be cross-platform is a tad hard.

It would be useful to have, but I fear you may just have to enumerate the cross-product of CPU s and features you would like to support, times the number of OSs (here two) and write tests for all. I do not think it has been done -- and someone will surely correct me if I overlooked something.

That would be a useful library to have, so good luck with the endeavor!

Dirk Eddelbuettel
+3  A: 

EDIT: At first, I googled for "libcpuid" remembering a conversation with peer programmers, and the google search pointed me to this sourceforge page which looks quite outdated. Then I noticed it was the project page of "libcpu".

Actually, there really is a libcpuid that might suit your needs.


Last time I looked for such a library, I found crisscross. It's C++ though.

There is also geekinfo.

But I don't know a cross-platform library that just does cpuid.

Gregory Pakosz
+1  A: 

Under linux peek in /proc/cpuinfo

Thorbjørn Ravn Andersen