无需组装即可检测CPU功能(Detecting CPU capability without assembly)

编程入门 行业动态 更新时间:2024-10-26 18:15:42
无需组装即可检测CPU功能(Detecting CPU capability without assembly)

我一直在寻找确定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.

更多推荐

本文发布于:2023-07-16 07:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1125419.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:功能   CPU   Detecting   assembly   capability

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!