Remove checks to see if system's processor matches the target the code was compiled for.
(Preparation for multi-target output.)
This commit is contained in:
@@ -55,7 +55,6 @@
|
|||||||
using namespace ispc;
|
using namespace ispc;
|
||||||
|
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "../cpuid.h"
|
|
||||||
|
|
||||||
#define NSUBSAMPLES 2
|
#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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc != 4) {
|
if (argc != 4) {
|
||||||
@@ -151,8 +118,6 @@ int main(int argc, char **argv)
|
|||||||
height = atoi (argv[3]);
|
height = atoi (argv[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
// Allocate space for output images
|
// Allocate space for output images
|
||||||
img = new unsigned char[width * height * 3];
|
img = new unsigned char[width * height * 3];
|
||||||
fimg = new float[width * height * 3];
|
fimg = new float[width * height * 3];
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ using namespace ispc;
|
|||||||
|
|
||||||
#include "instrument.h"
|
#include "instrument.h"
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "../cpuid.h"
|
|
||||||
|
|
||||||
#define NSUBSAMPLES 2
|
#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)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -149,8 +117,6 @@ int main(int argc, char **argv)
|
|||||||
height = atoi (argv[3]);
|
height = atoi (argv[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
// Allocate space for output images
|
// Allocate space for output images
|
||||||
img = new unsigned char[width * height * 3];
|
img = new unsigned char[width * height * 3];
|
||||||
fimg = new float[width * height * 3];
|
fimg = new float[width * height * 3];
|
||||||
|
|||||||
@@ -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 <intrin.h>
|
|
||||||
#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
|
|
||||||
@@ -58,45 +58,10 @@
|
|||||||
#include "deferred.h"
|
#include "deferred.h"
|
||||||
#include "kernels_ispc.h"
|
#include "kernels_ispc.h"
|
||||||
#include "../timing.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) {
|
int main(int argc, char** argv) {
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
printf("usage: deferred_shading <input_file (e.g. data/pp1280x720.bin)>\n");
|
printf("usage: deferred_shading <input_file (e.g. data/pp1280x720.bin)>\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "../cpuid.h"
|
|
||||||
#include "mandelbrot_ispc.h"
|
#include "mandelbrot_ispc.h"
|
||||||
using namespace ispc;
|
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() {
|
int main() {
|
||||||
unsigned int width = 768;
|
unsigned int width = 768;
|
||||||
unsigned int height = 512;
|
unsigned int height = 512;
|
||||||
@@ -111,8 +78,6 @@ int main() {
|
|||||||
int maxIterations = 256;
|
int maxIterations = 256;
|
||||||
int *buf = new int[width*height];
|
int *buf = new int[width*height];
|
||||||
|
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Compute the image using the ispc implementation; report the minimum
|
// Compute the image using the ispc implementation; report the minimum
|
||||||
// time of three runs.
|
// time of three runs.
|
||||||
|
|||||||
@@ -42,7 +42,6 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "../cpuid.h"
|
|
||||||
#include "mandelbrot_ispc.h"
|
#include "mandelbrot_ispc.h"
|
||||||
using namespace ispc;
|
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() {
|
static void usage() {
|
||||||
fprintf(stderr, "usage: mandelbrot [--scale=<factor>]\n");
|
fprintf(stderr, "usage: mandelbrot [--scale=<factor>]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -132,8 +100,6 @@ int main(int argc, char *argv[]) {
|
|||||||
else
|
else
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
int maxIterations = 512;
|
int maxIterations = 512;
|
||||||
int *buf = new int[width*height];
|
int *buf = new int[width*height];
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "../cpuid.h"
|
|
||||||
#include "noise_ispc.h"
|
#include "noise_ispc.h"
|
||||||
using namespace ispc;
|
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() {
|
int main() {
|
||||||
unsigned int width = 768;
|
unsigned int width = 768;
|
||||||
unsigned int height = 768;
|
unsigned int height = 768;
|
||||||
@@ -108,8 +75,6 @@ int main() {
|
|||||||
|
|
||||||
float *buf = new float[width*height];
|
float *buf = new float[width*height];
|
||||||
|
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Compute the image using the ispc implementation; report the minimum
|
// Compute the image using the ispc implementation; report the minimum
|
||||||
// time of three runs.
|
// time of three runs.
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ using std::max;
|
|||||||
|
|
||||||
#include "options_defs.h"
|
#include "options_defs.h"
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "../cpuid.h"
|
|
||||||
|
|
||||||
#include "options_ispc.h"
|
#include "options_ispc.h"
|
||||||
using namespace ispc;
|
using namespace ispc;
|
||||||
@@ -54,41 +53,7 @@ extern void binomial_put_serial(float Sa[], float Xa[], float Ta[],
|
|||||||
float ra[], float va[],
|
float ra[], float va[],
|
||||||
float result[], int count);
|
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() {
|
int main() {
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
float *S = new float[N_OPTIONS];
|
float *S = new float[N_OPTIONS];
|
||||||
float *X = new float[N_OPTIONS];
|
float *X = new float[N_OPTIONS];
|
||||||
float *T = new float[N_OPTIONS];
|
float *T = new float[N_OPTIONS];
|
||||||
|
|||||||
@@ -45,7 +45,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "../cpuid.h"
|
|
||||||
#include "rt_ispc.h"
|
#include "rt_ispc.h"
|
||||||
|
|
||||||
using namespace ispc;
|
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() {
|
static void usage() {
|
||||||
fprintf(stderr, "rt [--scale=<factor>] <scene name base>\n");
|
fprintf(stderr, "rt [--scale=<factor>] <scene name base>\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -151,8 +118,6 @@ int main(int argc, char *argv[]) {
|
|||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
#define READ(var, n) \
|
#define READ(var, n) \
|
||||||
if (fread(&(var), sizeof(var), n, f) != (unsigned int)n) { \
|
if (fread(&(var), sizeof(var), n, f) != (unsigned int)n) { \
|
||||||
fprintf(stderr, "Unexpected EOF reading scene file\n"); \
|
fprintf(stderr, "Unexpected EOF reading scene file\n"); \
|
||||||
|
|||||||
@@ -33,47 +33,12 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "../cpuid.h"
|
|
||||||
|
|
||||||
// Include the header file that the ispc compiler generates
|
// Include the header file that the ispc compiler generates
|
||||||
#include "simple_ispc.h"
|
#include "simple_ispc.h"
|
||||||
using namespace ispc;
|
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() {
|
int main() {
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
float vin[16], vout[16];
|
float vin[16], vout[16];
|
||||||
|
|
||||||
// Initialize input buffer
|
// Initialize input buffer
|
||||||
|
|||||||
@@ -42,43 +42,10 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "../cpuid.h"
|
|
||||||
#include "stencil_ispc.h"
|
#include "stencil_ispc.h"
|
||||||
using namespace ispc;
|
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,
|
extern void loop_stencil_serial(int t0, int t1, int x0, int x1,
|
||||||
int y0, int y1, int z0, int z1,
|
int y0, int y1, int z0, int z1,
|
||||||
int Nx, int Ny, int Nz,
|
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() {
|
int main() {
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
int Nx = 256, Ny = 256, Nz = 256;
|
int Nx = 256, Ny = 256, Nz = 256;
|
||||||
int width = 4;
|
int width = 4;
|
||||||
float *Aserial[2], *Aispc[2];
|
float *Aserial[2], *Aispc[2];
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "../cpuid.h"
|
|
||||||
#include "volume_ispc.h"
|
#include "volume_ispc.h"
|
||||||
using namespace ispc;
|
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.
|
/* Load image and viewing parameters from a camera data file.
|
||||||
FIXME: we should add support to be able to specify viewing parameters
|
FIXME: we should add support to be able to specify viewing parameters
|
||||||
in the program here directly. */
|
in the program here directly. */
|
||||||
@@ -172,8 +140,6 @@ int main(int argc, char *argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureTargetISAIsSupported();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Load viewing data and the volume density data
|
// Load viewing data and the volume density data
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user