我一直在寻找确定CPU及其功能的方法(例如SEE,SSE2等)。
但是,我发现的所有方法都使用cpuid指令来处理汇编代码。 鉴于在编译器甚至目标之间在c / c ++中进行汇编的不同方式(在VC下没有64位目标的内联汇编),id反而避免这种情况。
是否有一些简单的库或OS功能(用于Windows和Linux)来获取此信息?
目前我只对使用x86和x86-64 CPU的平台感兴趣,而且我极力需要支持至少AMD和Intel。
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.
最满意答案
编辑:起初,我搜索“libcpuid”记住与同行程序员的对话,谷歌搜索指向我这个看起来已经过时的sourceforge页面 。 然后我注意到它是“libcpu”的项目页面。
实际上,确实存在一个可能适合您需求的libcpuid 。
上次我找到这样一个图书馆,我发现了十字路口 。 这是C ++。
还有geekinfo 。
但我不知道只有cpuid的跨平台库。
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.
更多推荐
发布评论