简体   繁体   English

Microsoft编译器下_rdrand_step内在函数是否可用?

[英]Availability of _rdrand_step intrinsics under Microsoft compilers?

According to Microsoft's x64 (amd64) Intrinsics List , Microsoft offers an intrinsic for RDRAND: 根据Microsoft的x64(amd64)内部函数列表 ,Microsoft提供了RDRAND的内部函数:

  • _rdrand16_step
  • _rdrand32_step
  • _rdrand64_step

However, the page does not discuss detecting the availability of the intrinsic. 但是,该页面没有讨论检测内部函数的可用性。 There is a footnote with [2] , but it says its only available for Intel CPUs. [2]有一个脚注,但它说它仅适用于Intel CPU。

I have two questions. 我有两个问题。 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 . 也就是说,应该使用哪个预处理程序宏来保护调用_rdrand64_step的调用。

Second, how can I access RDRAND under AMD CPUs. 其次,如何在AMD CPU下访问RDRAND。 According to the AMD manual, AMD offers it too. 根据AMD手册,AMD也提供它。

(More humorously, Microsoft titles the page amd64 Intrinsic List. Why do they call it AMD64 Intrinsic List when they don't include AMD???) (更幽默的是,Microsoft为页面amd64 Intrinsic List命名。为什么当不包括AMD时为什么将其称为AMD64 Intrinsic List?)


For AMD and the RDRAND instruction, reference AMD64 Architecture Programmer's Manual Volume 3: General-Purpose and System Instructions , page 278. 有关AMD和RDRAND指令,请参考AMD64体系结构程序员手册第3卷:通用和系统指令 ,第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. 也就是说,我应该使用哪个预处理程序宏来保护调用_rdrand64_step的调用。

Here are the compiler versions needed for RDRAND intrinsics: 以下是RDRAND内部函数所需的编译器版本:

  • Microsoft added RDRAND in August 2012, VS2012. 微软于2012年8月在VS2012中添加了RDRAND。 Test for _MSC_VER >= 1700 . 测试_MSC_VER >= 1700
  • GCC added RDRAND in December 2010, GCC 4.6. GCC于2010年12月在GCC 4.6中添加了RDRAND。
  • Clang added RDRAND in July 2012, Clang 3.2. Clang于2012年7月在Clang 3.2中添加了RDRAND。
  • Intel added RDRAND in September 2011, ICC 12.1. 英特尔于2011年9月在ICC 12.1中添加了RDRAND。

Second, how can I access RDRAND under AMD CPUs. 其次,如何在AMD CPU下访问RDRAND。 According to the AMD manual, AMD offers it too. 根据AMD手册,AMD也提供它。

AMD CPUs that provide the RDRAND instruction appear to be forth coming. 提供RDRAND指令的AMD CPU即将面世。 That is, there are currently no CPUs shipping with the feature. 也就是说,当前没有附带此功能的CPU。

The Microsoft docs clearly state the intrinsics are for Intel CPUs only. Microsoft文档明确声明了内在函数仅适用于Intel CPU。 To ensure AMD support given the anti-competitive history between Intel and AMD , the ASM should be crafted by hand and assembled with MASM/ML and MASM64/ML64. 考虑到Intel和AMD之间的反竞争历史,要确保AMD支持,ASM应该手工制作并与MASM / ML和MASM64 / ML64组装在一起。

you can check the version of MS compiler using: 您可以使用以下命令检查MS编译器的版本:

  1. MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) Detailed MSVC ++ 14.0 _MSC_VER == 1900(Visual Studio 2015) 详细

  2. I am not sure how to use it with AMD architecture. 我不确定如何在AMD体系结构中使用它。 Will let you know if I get some solution 如果我有解决办法,会告诉您

  3. You can get the answer why MS documentation calls it amd64 in this post . 在这篇文章中,您可以获得MS文档将其称为amd64的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM