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:
15
module.cpp
15
module.cpp
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user