Add ISPC_HAS_RAND definition on targets that have a HW RNG.

This lets us check for a functioning rdrand() call in the stdlib
more reliably.  Fixes issue #333.
This commit is contained in:
Matt Pharr
2012-10-03 09:18:12 -07:00
parent 360cc8044e
commit 411d5b44ef
7 changed files with 8 additions and 6 deletions

View File

@@ -1788,6 +1788,8 @@ Module::execPreprocessor(const char* infilename, llvm::raw_string_ostream* ostre
if (g->target.hasHalf)
opts.addMacroDef("ISPC_TARGET_HAS_HALF");
if (g->target.hasRand)
opts.addMacroDef("ISPC_TARGET_HAS_RAND");
if (g->target.hasTranscendentals)
opts.addMacroDef("ISPC_TARGET_HAS_TRANSCENDENTALS");
if (g->opt.forceAlignedMemory)

View File

@@ -2,7 +2,7 @@
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)
#ifndef ISPC_HAS_RAND
RET[programIndex] = 1;
#else

View File

@@ -2,7 +2,7 @@
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)
#ifndef ISPC_HAS_RAND
RET[programIndex] = 1;
#else

View File

@@ -2,7 +2,7 @@
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)
#ifndef ISPC_HAS_RAND
RET[programIndex] = 1;
#else

View File

@@ -2,7 +2,7 @@
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)
#ifndef ISPC_HAS_RAND
RET[programIndex] = 0;
#else

View File

@@ -2,7 +2,7 @@
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)
#ifndef ISPC_HAS_RAND
RET[programIndex] = 0;
#else

View File

@@ -2,7 +2,7 @@
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)
#ifndef ISPC_HAS_RAND
RET[programIndex] = 0;
#else