c - Microsoft 编译器下 _rdrand_step 内在函数的可用性?

标签 c windows visual-studio x86 rdrand

根据 Microsoft 的 x64 (amd64) Intrinsics List ,微软为 RDRAND 提供了一个内在函数:

  • _rdrand16_step
  • _rdrand32_step
  • _rdrand64_step

但是,该页面没有讨论检测内在函数的可用性。有一个脚注 [2],但它说它仅适用于 Intel CPU。

我有两个问题。首先,如何检测内在函数的可用性。也就是说,我应该使用什么预处理器宏来保护 _rdrand64_step 的调用。

二、AMD CPU下如何访问RDRAND?根据AMD手册,AMD也提供了。

(更幽默的是,微软将页面标题为amd64 Intrinsic List。为什么他们不包括AMD而将其称为AMD64 Intrinsic List???)


对于 AMD 和 RDRAND 指令,请引用 AMD64 Architecture Programmer’s Manual Volume 3: General-Purpose and System Instructions ,第 278 页。

最佳答案

First, how can I detect the availability of the intrinsics. That is, what preprocessor macro should I use to guard the call to say _rdrand64_step.

以下是 RDRAND 内在函数所需的编译器版本:

  • Microsoft 于 2012 年 8 月添加了 RDRAND,VS2012。测试 _MSC_VER >= 1700
  • GCC 于 2010 年 12 月添加了 RDRAND,即 GCC 4.6。
  • Clang 于 2012 年 7 月添加了 RDRAND,即 Clang 3.2。
  • 英特尔于 2011 年 9 月添加了 RDRAND,ICC 12.1。

Second, how can I access RDRAND under AMD CPUs. According to the AMD manual, AMD offers it too.

提供 RDRAND 指令的 AMD CPU 似乎即将推出。也就是说,目前还没有附带该功能的 CPU。

Microsoft 文档明确指出该内在函数仅适用于 Intel CPU。确保AMD支持given the anti-competitive history between Intel and AMD ,ASM应该是手工制作的,并用MASM/ML和MASM64/ML64组装。

关于c - Microsoft 编译器下 _rdrand_step 内在函数的可用性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33072605/

相关文章:

c++ - 为什么我的 visual studio 构建不正确?

c - 如何检查c中32位有符号整数的整数溢出

c - 格式字符串前加下划线 `_`

c - 访问主函数中 typedef 结构中定义的二维数组。代码是C语言

C 在 EOF 后继续读取文件

windows - 从 Windows 获取完整的音频设备名称

visual-studio - 为 Windows 8 编写的应用程序可以在 Windows Phone 8 上运行吗?

wpf - 如何更改为黑色 Windows 箭头光标?

mongodb - Windows MongoDB Compass 没有显示集合信息,但 Ubuntu MongoDB Compass 显示了什么?

c++ - 多个项目引用 MFC : "use mfc in a static library" vs "use mfc in a shared dll"?