根据 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/