From 57f1db2438bb4f02cfa8446fcbc2571bf799b40e Mon Sep 17 00:00:00 2001
From: Branislav Jansik <branislav.jansik@vsb.cz>
Date: Tue, 2 Feb 2021 16:50:11 +0100
Subject: [PATCH] Hardware generator Initial commit

---
 random_hw.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 random_hw.c

diff --git a/random_hw.c b/random_hw.c
new file mode 100644
index 0000000..7a927f5
--- /dev/null
+++ b/random_hw.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#define MB 131072
+
+int main(int argc, char **argv)
+{
+int j,jmax=0;
+
+if (argc >1) jmax = atoi(argv[1]);
+
+#pragma omp parallel for default(none) shared(jmax,stdout) private(j) schedule(dynamic,1)
+for (j=0; j<jmax; j++)
+{
+uint64_t rndval[MB];
+int i;
+
+for(i=0; i<MB; i+=1)
+__asm__(
+        "cftest:\n\t"
+        "rdrand %%r8\n\t"
+        "jnc cftest \n\t"
+        "movq  %%r8,    (%0)\n\t"
+        : : "r" (rndval+i) :
+        "cc", "r8", "memory");
+
+
+#pragma omp critical
+fwrite(rndval,8,MB,stdout);
+}
+
+return(0);
+}
\ No newline at end of file
-- 
GitLab