Fix issue #67: don't crash ungracefully if target ISA not supported on system.

- In the ispc-generated header files, a #define now indicates which compilation target
  was used.
- The examples use utility routines from the new file examples/cpuid.h to check the
  system's CPU's capabilities to see if it supports the ISA that was used for
  compiling the example code and print error messages if things aren't going to
  work...
This commit is contained in:
Matt Pharr
2011-07-18 12:29:43 +01:00
parent 213c3a9666
commit 6b0a6c0124
9 changed files with 327 additions and 0 deletions

View File

@@ -1316,6 +1316,21 @@ Module::writeHeader(const char *fn) {
fprintf(f, "#ifndef %s\n#define %s\n\n", guard.c_str(), guard.c_str());
fprintf(f, "#include <stdint.h>\n\n");
switch (g->target.isa) {
case Target::SSE2:
fprintf(f, "#define ISPC_TARGET_SSE2\n\n");
break;
case Target::SSE4:
fprintf(f, "#define ISPC_TARGET_SSE4\n\n");
break;
case Target::AVX:
fprintf(f, "#define ISPC_TARGET_AVX\n\n");
break;
default:
FATAL("Unhandled target in header emission");
}
fprintf(f, "#ifdef __cplusplus\nnamespace ispc {\n#endif // __cplusplus\n\n");
if (g->emitInstrumentation) {