RDRAND and RDSEED intrinsics GCC and Intel C++

我的未来我决定 提交于 2019-12-29 07:14:27

问题


Does Intel C++ compiler and/or GCC support the following intrinsics, like MSVC does since 2012 / 2013?

int _rdrand16_step(uint16_t*);
int _rdrand32_step(uint32_t*);
int _rdrand64_step(uint64_t*);
int _rdseed16_step(uint16_t*);
int _rdseed32_step(uint32_t*);
int _rdseed64_step(uint64_t*);

And if these intrinsics are supported, since which version are they supported (with compile-time-constant please)?


回答1:


Both GCC and Intel compiler support them. GCC support was introduced at the end of 2010. They require the header <immintrin.h>.

GCC support has been present since at least version 4.6, but there doesn't seem to be any specific compile-time constant - you can just check __GNUC_MAJOR__ > 4 || (__GNUC_MAJOR__ == 4 && __GNUC_MINOR__ >= 6).




回答2:


Microsoft compiler does not have intrinsics support for RDSEED and RDRAND instruction.

But, you may implement these instruction using NASM or MASM. Assembly code is available at:

https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide

For Intel Compiler, you can use header to determine the version. You can use following macros to determine the version and sub-version:

__INTEL_COMPILER //Major Version
__INTEL_COMPILER_UPDATE // Minor Update.

For instance if you use ICC15.0 Update 3 compiler, it will show that you have

__INTEL_COMPILER  = 1500
__INTEL_COMPILER_UPDATE = 3

For further details on pre-defined macros you can go to: https://software.intel.com/en-us/node/524490



来源:https://stackoverflow.com/questions/29372893/rdrand-and-rdseed-intrinsics-gcc-and-intel-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!