From 880cbb18cc1d78dd85f862ce6e522ff6f55571dc Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Tue, 4 Oct 2011 15:52:46 -0700 Subject: [PATCH] Remove checks to see if system's processor matches the target the code was compiled for. (Preparation for multi-target output.) --- examples/aobench/ao.cpp | 35 ------------- examples/aobench_instrumented/ao.cpp | 34 ------------ examples/cpuid.h | 66 ------------------------ examples/deferred/main.cpp | 35 ------------- examples/mandelbrot/mandelbrot.cpp | 35 ------------- examples/mandelbrot_tasks/mandelbrot.cpp | 34 ------------ examples/noise/noise.cpp | 35 ------------- examples/options/options.cpp | 35 ------------- examples/rt/rt.cpp | 35 ------------- examples/simple/simple.cpp | 35 ------------- examples/stencil/stencil.cpp | 35 ------------- examples/volume_rendering/volume.cpp | 34 ------------ 12 files changed, 448 deletions(-) delete mode 100644 examples/cpuid.h diff --git a/examples/aobench/ao.cpp b/examples/aobench/ao.cpp index 4d7de414..cbe75a0b 100644 --- a/examples/aobench/ao.cpp +++ b/examples/aobench/ao.cpp @@ -55,7 +55,6 @@ using namespace ispc; #include "../timing.h" -#include "../cpuid.h" #define NSUBSAMPLES 2 @@ -105,38 +104,6 @@ savePPM(const char *fname, int w, int h) } -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - - int main(int argc, char **argv) { if (argc != 4) { @@ -151,8 +118,6 @@ int main(int argc, char **argv) height = atoi (argv[3]); } - ensureTargetISAIsSupported(); - // Allocate space for output images img = new unsigned char[width * height * 3]; fimg = new float[width * height * 3]; diff --git a/examples/aobench_instrumented/ao.cpp b/examples/aobench_instrumented/ao.cpp index e2f2430e..b88c095b 100644 --- a/examples/aobench_instrumented/ao.cpp +++ b/examples/aobench_instrumented/ao.cpp @@ -55,7 +55,6 @@ using namespace ispc; #include "instrument.h" #include "../timing.h" -#include "../cpuid.h" #define NSUBSAMPLES 2 @@ -103,37 +102,6 @@ savePPM(const char *fname, int w, int h) } -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - int main(int argc, char **argv) { @@ -149,8 +117,6 @@ int main(int argc, char **argv) height = atoi (argv[3]); } - ensureTargetISAIsSupported(); - // Allocate space for output images img = new unsigned char[width * height * 3]; fimg = new float[width * height * 3]; diff --git a/examples/cpuid.h b/examples/cpuid.h deleted file mode 100644 index 81a25200..00000000 --- a/examples/cpuid.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright (c) 2010-2011, Intel Corporation - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - * Neither the name of Intel Corporation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER - OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ISPC_CPUID_H -#define ISPC_CPUID_H 1 - -#ifdef _MSC_VER -// Provides a __cpuid() function with same signature as below -#include -#else -static void __cpuid(int info[4], int infoType) { - __asm__ __volatile__ ("cpuid" - : "=a" (info[0]), "=b" (info[1]), "=c" (info[2]), "=d" (info[3]) - : "0" (infoType)); -} -#endif - -inline bool CPUSupportsSSE2() { - int info[4]; - __cpuid(info, 1); - return (info[3] & (1 << 26)) != 0; -} - -inline bool CPUSupportsSSE4() { - int info[4]; - __cpuid(info, 1); - return (info[2] & (1 << 19)) != 0; -} - -inline bool CPUSupportsAVX() { - int info[4]; - __cpuid(info, 1); - return (info[2] & (1 << 28)) != 0; -} - -#endif // ISPC_CPUID_H diff --git a/examples/deferred/main.cpp b/examples/deferred/main.cpp index 0c770049..88dab2d6 100644 --- a/examples/deferred/main.cpp +++ b/examples/deferred/main.cpp @@ -58,45 +58,10 @@ #include "deferred.h" #include "kernels_ispc.h" #include "../timing.h" -#include "../cpuid.h" /////////////////////////////////////////////////////////////////////////// -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - - int main(int argc, char** argv) { - ensureTargetISAIsSupported(); - if (argc != 2) { printf("usage: deferred_shading \n"); return 1; diff --git a/examples/mandelbrot/mandelbrot.cpp b/examples/mandelbrot/mandelbrot.cpp index 14a63f6a..7e73768f 100644 --- a/examples/mandelbrot/mandelbrot.cpp +++ b/examples/mandelbrot/mandelbrot.cpp @@ -41,7 +41,6 @@ #include #include #include "../timing.h" -#include "../cpuid.h" #include "mandelbrot_ispc.h" using namespace ispc; @@ -68,38 +67,6 @@ writePPM(int *buf, int width, int height, const char *fn) { } -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - - int main() { unsigned int width = 768; unsigned int height = 512; @@ -111,8 +78,6 @@ int main() { int maxIterations = 256; int *buf = new int[width*height]; - ensureTargetISAIsSupported(); - // // Compute the image using the ispc implementation; report the minimum // time of three runs. diff --git a/examples/mandelbrot_tasks/mandelbrot.cpp b/examples/mandelbrot_tasks/mandelbrot.cpp index 509ce293..0b32b3a7 100644 --- a/examples/mandelbrot_tasks/mandelbrot.cpp +++ b/examples/mandelbrot_tasks/mandelbrot.cpp @@ -42,7 +42,6 @@ #include #include #include "../timing.h" -#include "../cpuid.h" #include "mandelbrot_ispc.h" using namespace ispc; @@ -69,37 +68,6 @@ writePPM(int *buf, int width, int height, const char *fn) { } -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - static void usage() { fprintf(stderr, "usage: mandelbrot [--scale=]\n"); exit(1); @@ -132,8 +100,6 @@ int main(int argc, char *argv[]) { else usage(); - ensureTargetISAIsSupported(); - int maxIterations = 512; int *buf = new int[width*height]; diff --git a/examples/noise/noise.cpp b/examples/noise/noise.cpp index b3f3920d..58552ce3 100644 --- a/examples/noise/noise.cpp +++ b/examples/noise/noise.cpp @@ -41,7 +41,6 @@ #include #include #include "../timing.h" -#include "../cpuid.h" #include "noise_ispc.h" using namespace ispc; @@ -66,38 +65,6 @@ writePPM(float *buf, int width, int height, const char *fn) { } -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - - int main() { unsigned int width = 768; unsigned int height = 768; @@ -108,8 +75,6 @@ int main() { float *buf = new float[width*height]; - ensureTargetISAIsSupported(); - // // Compute the image using the ispc implementation; report the minimum // time of three runs. diff --git a/examples/options/options.cpp b/examples/options/options.cpp index 1f58e8eb..5fe48f86 100644 --- a/examples/options/options.cpp +++ b/examples/options/options.cpp @@ -41,7 +41,6 @@ using std::max; #include "options_defs.h" #include "../timing.h" -#include "../cpuid.h" #include "options_ispc.h" using namespace ispc; @@ -54,41 +53,7 @@ extern void binomial_put_serial(float Sa[], float Xa[], float Ta[], float ra[], float va[], float result[], int count); -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - - int main() { - ensureTargetISAIsSupported(); - float *S = new float[N_OPTIONS]; float *X = new float[N_OPTIONS]; float *T = new float[N_OPTIONS]; diff --git a/examples/rt/rt.cpp b/examples/rt/rt.cpp index 76e86362..4745f01d 100644 --- a/examples/rt/rt.cpp +++ b/examples/rt/rt.cpp @@ -45,7 +45,6 @@ #include #include #include "../timing.h" -#include "../cpuid.h" #include "rt_ispc.h" using namespace ispc; @@ -96,38 +95,6 @@ static void writeImage(int *idImage, float *depthImage, int width, int height, } -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - - static void usage() { fprintf(stderr, "rt [--scale=] \n"); exit(1); @@ -151,8 +118,6 @@ int main(int argc, char *argv[]) { if (filename == NULL) usage(); - ensureTargetISAIsSupported(); - #define READ(var, n) \ if (fread(&(var), sizeof(var), n, f) != (unsigned int)n) { \ fprintf(stderr, "Unexpected EOF reading scene file\n"); \ diff --git a/examples/simple/simple.cpp b/examples/simple/simple.cpp index 4a760341..e0d34bd7 100644 --- a/examples/simple/simple.cpp +++ b/examples/simple/simple.cpp @@ -33,47 +33,12 @@ #include #include -#include "../cpuid.h" // Include the header file that the ispc compiler generates #include "simple_ispc.h" using namespace ispc; -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - - int main() { - ensureTargetISAIsSupported(); - float vin[16], vout[16]; // Initialize input buffer diff --git a/examples/stencil/stencil.cpp b/examples/stencil/stencil.cpp index 98ff937a..05b39f7c 100644 --- a/examples/stencil/stencil.cpp +++ b/examples/stencil/stencil.cpp @@ -42,43 +42,10 @@ #include #include #include "../timing.h" -#include "../cpuid.h" #include "stencil_ispc.h" using namespace ispc; -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - - extern void loop_stencil_serial(int t0, int t1, int x0, int x1, int y0, int y1, int z0, int z1, int Nx, int Ny, int Nz, @@ -100,8 +67,6 @@ void InitData(int Nx, int Ny, int Nz, float *A[2], float *vsq) { int main() { - ensureTargetISAIsSupported(); - int Nx = 256, Ny = 256, Nz = 256; int width = 4; float *Aserial[2], *Aispc[2]; diff --git a/examples/volume_rendering/volume.cpp b/examples/volume_rendering/volume.cpp index cb9eb739..50b39d62 100644 --- a/examples/volume_rendering/volume.cpp +++ b/examples/volume_rendering/volume.cpp @@ -41,7 +41,6 @@ #include #include #include "../timing.h" -#include "../cpuid.h" #include "volume_ispc.h" using namespace ispc; @@ -70,37 +69,6 @@ writePPM(float *buf, int width, int height, const char *fn) { } -// Make sure that the vector ISA used during compilation is supported by -// the processor. The ISPC_TARGET_* macro is set in the ispc-generated -// header file that we include above. -static void -ensureTargetISAIsSupported() { -#if defined(ISPC_TARGET_SSE2) - bool isaSupported = CPUSupportsSSE2(); - const char *target = "SSE2"; -#elif defined(ISPC_TARGET_SSE4) - bool isaSupported = CPUSupportsSSE4(); - const char *target = "SSE4"; -#elif defined(ISPC_TARGET_AVX) - bool isaSupported = CPUSupportsAVX(); - const char *target = "AVX"; -#else -#error "Unknown ISPC_TARGET_* value" -#endif - if (!isaSupported) { - fprintf(stderr, "***\n*** Error: the ispc-compiled code uses the %s instruction " - "set, which isn't\n*** supported by this computer's CPU!\n", target); - fprintf(stderr, "***\n*** Please modify the " -#ifdef _MSC_VER - "MSVC project file " -#else - "Makefile " -#endif - "to select another target (e.g. sse2)\n***\n"); - exit(1); - } -} - /* Load image and viewing parameters from a camera data file. FIXME: we should add support to be able to specify viewing parameters in the program here directly. */ @@ -172,8 +140,6 @@ int main(int argc, char *argv[]) { return 1; } - ensureTargetISAIsSupported(); - // // Load viewing data and the volume density data //