试试 intel rng 随机数生成器
2014-04-16 15:38
381 查看
今天看蒙特卡罗方法,看到对随机数的质量蛮强调的,搜索了一下随机数生成器,注意到intel的 drng,下载了guide 跟着实验了一下。
Bull Mountain Software Implementation Guide
下载地址 https://software.intel.com/file/37157
Intel® Digital Random Number Generator (DRNG) Software Implementation Guide
地址:https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide/
还可以下个paper参考下:
基于Intel_RNG的真随机数生成器研究
地址:http://download.csdn.net/detail/deltatang/7202395
顺便贴一下如何检测 服务器是intel芯片以及如何判断是否支持RNG的代码:
文件 get_cpuid_v1_lix64.s
文件:get_cpuid_v1_lix64.h
文件:rngchk.c
然后执行:
得到 rngchk 执行结果:
结果发现俺测试服务器不支持,好吧,先留着,以后再说吧:)
Bull Mountain Software Implementation Guide
下载地址 https://software.intel.com/file/37157
Intel® Digital Random Number Generator (DRNG) Software Implementation Guide
地址:https://software.intel.com/en-us/articles/intel-digital-random-number-generator-drng-software-implementation-guide/
还可以下个paper参考下:
基于Intel_RNG的真随机数生成器研究
地址:http://download.csdn.net/detail/deltatang/7202395
顺便贴一下如何检测 服务器是intel芯片以及如何判断是否支持RNG的代码:
文件 get_cpuid_v1_lix64.s
.intel_syntax noprefix .text .global get_cpuid_info_v1 get_cpuid_info_v1: mov r8, rdi # array addr mov r9, rsi # leaf mov r10, rdx # subleaf push rax push rbx push rcx push rdx mov eax, r9d mov ecx, r10d cpuid mov DWORD PTR [r8], eax mov DWORD PTR [r8+4], ebx mov DWORD PTR [r8+8], ecx mov DWORD PTR [r8+12], edx pop rdx pop rcx pop rbx pop rax ret 0 #get_cpuid_info_v1 ENDP #_TEXT ENDS
文件:get_cpuid_v1_lix64.h
typedef struct { unsigned int EAX; unsigned int EBX; unsigned int ECX; unsigned int EDX; } CPUIDinfo; extern void get_cpuid_info_v1(CPUIDinfo *info, const unsigned int func, const unsigned int subfunc);
文件:rngchk.c
#include <stdio.h> #include <stdlib.h> #include "get_cpuid_v1_lix64.h" void _CPUID(CPUIDinfo *info, const unsigned int func, const unsigned int subfunc) { get_cpuid_info_v1(info, func, subfunc); } typedef unsigned int DWORD; int _rdrand_check_support() { CPUIDinfo info; int got_intel_cpu=0; _CPUID(&info, 0, 0); if(memcmp((char *)(&info.EBX), "Genu", 4) == 0 && memcmp((char *)(&info.EDX), "ineI", 4) == 0 && memcmp((char *)(&info.ECX), "ntel", 4) == 0) { got_intel_cpu = 1; } if (got_intel_cpu) { _CPUID(&info, 1, 0); if ((info.ECX & 0x40000000)==0x40000000) return 1; } else { return 2; } return 0; } int main(int argc, char **argv) { int ret = _rdrand_check_support(); printf("is not intel cpu? [%c]\n", (ret == 2 ? 'Y' : 'N')); printf("is intel rng supported? [%c]\n", (ret == 1 ? 'Y' : 'N')); }
然后执行:
gcc -g -c get_cpuid_v1_lix64.s -o get_cpuid_v1_lix64.o gcc rngchk.c get_cpuid_v1_lix64.o -o rngchk
得到 rngchk 执行结果:
[root@localhost rng]# ./rngchk is not intel cpu? is intel rng supported?
结果发现俺测试服务器不支持,好吧,先留着,以后再说吧:)
相关文章推荐
- OpenCV 随机数生成器 RNG
- 基于 intel MKL 的高性能随机数生成器
- OpenCV学习(十一)之随机数生成器RNG
- 使用加密服务提供程序 (CSP) 提供的实现来实现加密随机数生成器 (RNG)
- opencv中的随机数生成器RNG
- 【BZOJ】【P3671】【NOI2014】【随机数生成器】【题解】【贪心】
- OpenCV基础篇之绘图及RNG随机数对象
- OpenCV基础篇之绘图及RNG随机数对象
- 纯线性同余随机数生成器
- bzoj 3122: [Sdoi2013]随机数生成器【BSGS】
- 【原创】开源Math.NET基础数学类库使用(13)C#实现其他随机数生成器
- OpenCV学习笔记之随机数生成器
- Luogu3600 随机数生成器
- 解密随机数生成器
- 随机数生成器
- bzoj2875: [Noi2012]随机数生成器 裸矩阵乘法
- 【Java】_ 数组、哈希表、迭代器以及随机数生成器
- bzoj3671: [Noi2014]随机数生成器
- 随机数的生成:给定1-n的随机数生成器randn(),生成1-m的随机数
- bzo j3122: [Sdoi2013]随机数生成器