Add support for RDRAND in IvyBridge.
The standard library now provides a variety of rdrand() functions that call out to RDRAND, when available. Issue #263.
This commit is contained in:
35
tests/rdrand-6.ispc
Normal file
35
tests/rdrand-6.ispc
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
export uniform int width() { return programCount; }
|
||||
|
||||
export void f_f(uniform float RET[], uniform float aFOO[]) {
|
||||
#if !defined(ISPC_TARGET_AVX11) && !defined(ISPC_TARGET_AVX2)
|
||||
RET[programIndex] = 0;
|
||||
#else
|
||||
|
||||
int set[32] = { 0 };
|
||||
uniform int count = 1024*1024;
|
||||
for (uniform int i = 0; i < count; ++i) {
|
||||
uniform int32 rr[programCount];
|
||||
int * ptr = rr + programIndex;
|
||||
while (!rdrand(ptr))
|
||||
;
|
||||
int32 r = rr[programIndex];
|
||||
for (uniform int b = 0; b < 32; ++b)
|
||||
if (((unsigned int32)r >> b) & 1)
|
||||
++set[b];
|
||||
}
|
||||
|
||||
RET[programIndex] = 0;
|
||||
for (uniform int b = 0; b < 32; ++b) {
|
||||
float r = (double)set[b] / (double)(count);
|
||||
if (!(r >= .49 && r < .51)) {
|
||||
print("% % - %\n", b, r, set[b]);
|
||||
++RET[programIndex];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
export void result(uniform float RET[]) {
|
||||
RET[programIndex] = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user