changing of examples
This commit is contained in:
@@ -60,7 +60,7 @@ using namespace ispc;
|
|||||||
|
|
||||||
extern void ao_serial(int w, int h, int nsubsamples, float image[]);
|
extern void ao_serial(int w, int h, int nsubsamples, float image[]);
|
||||||
|
|
||||||
static unsigned int test_iterations;
|
static unsigned int test_iterations[] = {3, 7, 1};
|
||||||
static unsigned int width, height;
|
static unsigned int width, height;
|
||||||
static unsigned char *img;
|
static unsigned char *img;
|
||||||
static float *fimg;
|
static float *fimg;
|
||||||
@@ -106,16 +106,20 @@ savePPM(const char *fname, int w, int h)
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
if (argc != 4) {
|
if (argc < 3) {
|
||||||
printf ("%s\n", argv[0]);
|
printf ("%s\n", argv[0]);
|
||||||
printf ("Usage: ao [num test iterations] [width] [height]\n");
|
printf ("Usage: ao [width] [height] [ispc iterations] [tasks iterations] [serial iterations]\n");
|
||||||
getchar();
|
getchar();
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
test_iterations = atoi(argv[1]);
|
if (argc == 6) {
|
||||||
width = atoi (argv[2]);
|
for (int i = 0; i < 3; i++) {
|
||||||
height = atoi (argv[3]);
|
test_iterations[i] = atoi(argv[3 + i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
width = atoi (argv[1]);
|
||||||
|
height = atoi (argv[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate space for output images
|
// Allocate space for output images
|
||||||
@@ -127,13 +131,14 @@ int main(int argc, char **argv)
|
|||||||
// time for any of them.
|
// time for any of them.
|
||||||
//
|
//
|
||||||
double minTimeISPC = 1e30;
|
double minTimeISPC = 1e30;
|
||||||
for (unsigned int i = 0; i < test_iterations; i++) {
|
for (unsigned int i = 0; i < test_iterations[0]; i++) {
|
||||||
memset((void *)fimg, 0, sizeof(float) * width * height * 3);
|
memset((void *)fimg, 0, sizeof(float) * width * height * 3);
|
||||||
assert(NSUBSAMPLES == 2);
|
assert(NSUBSAMPLES == 2);
|
||||||
|
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
ao_ispc(width, height, NSUBSAMPLES, fimg);
|
ao_ispc(width, height, NSUBSAMPLES, fimg);
|
||||||
double t = get_elapsed_mcycles();
|
double t = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC run:\t\t\t[%.3f] million cycles\n", t);
|
||||||
minTimeISPC = std::min(minTimeISPC, t);
|
minTimeISPC = std::min(minTimeISPC, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,13 +152,14 @@ int main(int argc, char **argv)
|
|||||||
// minimum time for any of them.
|
// minimum time for any of them.
|
||||||
//
|
//
|
||||||
double minTimeISPCTasks = 1e30;
|
double minTimeISPCTasks = 1e30;
|
||||||
for (unsigned int i = 0; i < test_iterations; i++) {
|
for (unsigned int i = 0; i < test_iterations[1]; i++) {
|
||||||
memset((void *)fimg, 0, sizeof(float) * width * height * 3);
|
memset((void *)fimg, 0, sizeof(float) * width * height * 3);
|
||||||
assert(NSUBSAMPLES == 2);
|
assert(NSUBSAMPLES == 2);
|
||||||
|
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
ao_ispc_tasks(width, height, NSUBSAMPLES, fimg);
|
ao_ispc_tasks(width, height, NSUBSAMPLES, fimg);
|
||||||
double t = get_elapsed_mcycles();
|
double t = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC + TASKS run:\t\t\t[%.3f] million cycles\n", t);
|
||||||
minTimeISPCTasks = std::min(minTimeISPCTasks, t);
|
minTimeISPCTasks = std::min(minTimeISPCTasks, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,11 +173,12 @@ int main(int argc, char **argv)
|
|||||||
// minimum time.
|
// minimum time.
|
||||||
//
|
//
|
||||||
double minTimeSerial = 1e30;
|
double minTimeSerial = 1e30;
|
||||||
for (unsigned int i = 0; i < test_iterations; i++) {
|
for (unsigned int i = 0; i < test_iterations[2]; i++) {
|
||||||
memset((void *)fimg, 0, sizeof(float) * width * height * 3);
|
memset((void *)fimg, 0, sizeof(float) * width * height * 3);
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
ao_serial(width, height, NSUBSAMPLES, fimg);
|
ao_serial(width, height, NSUBSAMPLES, fimg);
|
||||||
double t = get_elapsed_mcycles();
|
double t = get_elapsed_mcycles();
|
||||||
|
printf("@time of serial run:\t\t\t\t[%.3f] million cycles\n", t);
|
||||||
minTimeSerial = std::min(minTimeSerial, t);
|
minTimeSerial = std::min(minTimeSerial, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,10 +62,16 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
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)> [tasks iterations] [serial iterations]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
static unsigned int test_iterations[] = {5, 3, 500}; //last value is for nframes, it is scale.
|
||||||
|
if (argc == 5) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
test_iterations[i] = atoi(argv[2 + i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
InputData *input = CreateInputDataFromFile(argv[1]);
|
InputData *input = CreateInputDataFromFile(argv[1]);
|
||||||
if (!input) {
|
if (!input) {
|
||||||
@@ -81,9 +87,9 @@ int main(int argc, char** argv) {
|
|||||||
InitDynamicCilk(input);
|
InitDynamicCilk(input);
|
||||||
#endif // __cilk
|
#endif // __cilk
|
||||||
|
|
||||||
int nframes = 5;
|
int nframes = test_iterations[2];
|
||||||
double ispcCycles = 1e30;
|
double ispcCycles = 1e30;
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < test_iterations[0]; ++i) {
|
||||||
framebuffer.clear();
|
framebuffer.clear();
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
for (int j = 0; j < nframes; ++j)
|
for (int j = 0; j < nframes; ++j)
|
||||||
@@ -91,6 +97,7 @@ int main(int argc, char** argv) {
|
|||||||
VISUALIZE_LIGHT_COUNT,
|
VISUALIZE_LIGHT_COUNT,
|
||||||
framebuffer.r, framebuffer.g, framebuffer.b);
|
framebuffer.r, framebuffer.g, framebuffer.b);
|
||||||
double mcycles = get_elapsed_mcycles() / nframes;
|
double mcycles = get_elapsed_mcycles() / nframes;
|
||||||
|
printf("@time of ISPC + TASKS run:\t\t\t[%.3f] million cycles\n", mcycles);
|
||||||
ispcCycles = std::min(ispcCycles, mcycles);
|
ispcCycles = std::min(ispcCycles, mcycles);
|
||||||
}
|
}
|
||||||
printf("[ispc static + tasks]:\t\t[%.3f] million cycles to render "
|
printf("[ispc static + tasks]:\t\t[%.3f] million cycles to render "
|
||||||
@@ -98,14 +105,16 @@ int main(int argc, char** argv) {
|
|||||||
input->header.framebufferWidth, input->header.framebufferHeight);
|
input->header.framebufferWidth, input->header.framebufferHeight);
|
||||||
WriteFrame("deferred-ispc-static.ppm", input, framebuffer);
|
WriteFrame("deferred-ispc-static.ppm", input, framebuffer);
|
||||||
|
|
||||||
|
nframes = 3;
|
||||||
#ifdef __cilk
|
#ifdef __cilk
|
||||||
double dynamicCilkCycles = 1e30;
|
double dynamicCilkCycles = 1e30;
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < test_iterations[1]; ++i) {
|
||||||
framebuffer.clear();
|
framebuffer.clear();
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
for (int j = 0; j < nframes; ++j)
|
for (int j = 0; j < nframes; ++j)
|
||||||
DispatchDynamicCilk(input, &framebuffer);
|
DispatchDynamicCilk(input, &framebuffer);
|
||||||
double mcycles = get_elapsed_mcycles() / nframes;
|
double mcycles = get_elapsed_mcycles() / nframes;
|
||||||
|
printf("@time of serial run:\t\t\t[%.3f] million cycles\n", mcycles);
|
||||||
dynamicCilkCycles = std::min(dynamicCilkCycles, mcycles);
|
dynamicCilkCycles = std::min(dynamicCilkCycles, mcycles);
|
||||||
}
|
}
|
||||||
printf("[ispc + Cilk dynamic]:\t\t[%.3f] million cycles to render image\n",
|
printf("[ispc + Cilk dynamic]:\t\t[%.3f] million cycles to render image\n",
|
||||||
@@ -114,12 +123,13 @@ int main(int argc, char** argv) {
|
|||||||
#endif // __cilk
|
#endif // __cilk
|
||||||
|
|
||||||
double serialCycles = 1e30;
|
double serialCycles = 1e30;
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < test_iterations[1]; ++i) {
|
||||||
framebuffer.clear();
|
framebuffer.clear();
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
for (int j = 0; j < nframes; ++j)
|
for (int j = 0; j < nframes; ++j)
|
||||||
DispatchDynamicC(input, &framebuffer);
|
DispatchDynamicC(input, &framebuffer);
|
||||||
double mcycles = get_elapsed_mcycles() / nframes;
|
double mcycles = get_elapsed_mcycles() / nframes;
|
||||||
|
printf("@time of serial run:\t\t\t[%.3f] million cycles\n", mcycles);
|
||||||
serialCycles = std::min(serialCycles, mcycles);
|
serialCycles = std::min(serialCycles, mcycles);
|
||||||
}
|
}
|
||||||
printf("[C++ serial dynamic, 1 core]:\t[%.3f] million cycles to render image\n",
|
printf("[C++ serial dynamic, 1 core]:\t[%.3f] million cycles to render image\n",
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "mandelbrot_ispc.h"
|
#include "mandelbrot_ispc.h"
|
||||||
|
#include <string.h>
|
||||||
using namespace ispc;
|
using namespace ispc;
|
||||||
|
|
||||||
extern void mandelbrot_serial(float x0, float y0, float x1, float y1,
|
extern void mandelbrot_serial(float x0, float y0, float x1, float y1,
|
||||||
@@ -67,7 +68,8 @@ writePPM(int *buf, int width, int height, const char *fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main(int argc, char *argv[]) {
|
||||||
|
static unsigned int test_iterations[] = {3, 3};
|
||||||
unsigned int width = 768;
|
unsigned int width = 768;
|
||||||
unsigned int height = 512;
|
unsigned int height = 512;
|
||||||
float x0 = -2;
|
float x0 = -2;
|
||||||
@@ -75,6 +77,19 @@ int main() {
|
|||||||
float y0 = -1;
|
float y0 = -1;
|
||||||
float y1 = 1;
|
float y1 = 1;
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
if (strncmp(argv[1], "--scale=", 8) == 0) {
|
||||||
|
float scale = atof(argv[1] + 8);
|
||||||
|
width *= scale;
|
||||||
|
height *= scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((argc == 3) || (argc == 4)) {
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
test_iterations[i] = atoi(argv[argc - 2 + i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int maxIterations = 256;
|
int maxIterations = 256;
|
||||||
int *buf = new int[width*height];
|
int *buf = new int[width*height];
|
||||||
|
|
||||||
@@ -83,10 +98,11 @@ int main() {
|
|||||||
// time of three runs.
|
// time of three runs.
|
||||||
//
|
//
|
||||||
double minISPC = 1e30;
|
double minISPC = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[0]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
mandelbrot_ispc(x0, y0, x1, y1, width, height, maxIterations, buf);
|
mandelbrot_ispc(x0, y0, x1, y1, width, height, maxIterations, buf);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minISPC = std::min(minISPC, dt);
|
minISPC = std::min(minISPC, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,10 +118,11 @@ int main() {
|
|||||||
// minimum time.
|
// minimum time.
|
||||||
//
|
//
|
||||||
double minSerial = 1e30;
|
double minSerial = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[1]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
mandelbrot_serial(x0, y0, x1, y1, width, height, maxIterations, buf);
|
mandelbrot_serial(x0, y0, x1, y1, width, height, maxIterations, buf);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of serial run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minSerial = std::min(minSerial, dt);
|
minSerial = std::min(minSerial, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,21 +69,20 @@ writePPM(int *buf, int width, int height, const char *fn) {
|
|||||||
|
|
||||||
|
|
||||||
static void usage() {
|
static void usage() {
|
||||||
fprintf(stderr, "usage: mandelbrot [--scale=<factor>]\n");
|
fprintf(stderr, "usage: mandelbrot [--scale=<factor>] [tasks iterations] [serial iterations]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
unsigned int width = 1536 * 8;
|
static unsigned int test_iterations[] = {7, 1};
|
||||||
unsigned int height = 1024 * 8;
|
unsigned int width = 1536;
|
||||||
|
unsigned int height = 1024;
|
||||||
float x0 = -2;
|
float x0 = -2;
|
||||||
float x1 = 1;
|
float x1 = 1;
|
||||||
float y0 = -1;
|
float y0 = -1;
|
||||||
float y1 = 1;
|
float y1 = 1;
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc > 1) {
|
||||||
;
|
|
||||||
else if (argc == 2) {
|
|
||||||
if (strncmp(argv[1], "--scale=", 8) == 0) {
|
if (strncmp(argv[1], "--scale=", 8) == 0) {
|
||||||
float scale = atof(argv[1] + 8);
|
float scale = atof(argv[1] + 8);
|
||||||
if (scale == 0.f)
|
if (scale == 0.f)
|
||||||
@@ -94,11 +93,13 @@ int main(int argc, char *argv[]) {
|
|||||||
width = (width + 0xf) & ~0xf;
|
width = (width + 0xf) & ~0xf;
|
||||||
height = (height + 0xf) & ~0xf;
|
height = (height + 0xf) & ~0xf;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
usage();
|
|
||||||
}
|
}
|
||||||
else
|
if ((argc == 3) || (argc == 4)) {
|
||||||
usage();
|
for (int i = 0; i < 2; i++) {
|
||||||
|
test_iterations[i] = atoi(argv[argc - 2 + i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int maxIterations = 512;
|
int maxIterations = 512;
|
||||||
int *buf = new int[width*height];
|
int *buf = new int[width*height];
|
||||||
@@ -108,13 +109,14 @@ int main(int argc, char *argv[]) {
|
|||||||
// time of three runs.
|
// time of three runs.
|
||||||
//
|
//
|
||||||
double minISPC = 1e30;
|
double minISPC = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[0]; ++i) {
|
||||||
// Clear out the buffer
|
// Clear out the buffer
|
||||||
for (unsigned int i = 0; i < width * height; ++i)
|
for (unsigned int i = 0; i < width * height; ++i)
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
mandelbrot_ispc(x0, y0, x1, y1, width, height, maxIterations, buf);
|
mandelbrot_ispc(x0, y0, x1, y1, width, height, maxIterations, buf);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC + TASKS run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minISPC = std::min(minISPC, dt);
|
minISPC = std::min(minISPC, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,13 +129,14 @@ int main(int argc, char *argv[]) {
|
|||||||
// minimum time.
|
// minimum time.
|
||||||
//
|
//
|
||||||
double minSerial = 1e30;
|
double minSerial = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[1]; ++i) {
|
||||||
// Clear out the buffer
|
// Clear out the buffer
|
||||||
for (unsigned int i = 0; i < width * height; ++i)
|
for (unsigned int i = 0; i < width * height; ++i)
|
||||||
buf[i] = 0;
|
buf[i] = 0;
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
mandelbrot_serial(x0, y0, x1, y1, width, height, maxIterations, buf);
|
mandelbrot_serial(x0, y0, x1, y1, width, height, maxIterations, buf);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of serial run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minSerial = std::min(minSerial, dt);
|
minSerial = std::min(minSerial, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "noise_ispc.h"
|
#include "noise_ispc.h"
|
||||||
|
#include <string.h>
|
||||||
using namespace ispc;
|
using namespace ispc;
|
||||||
|
|
||||||
extern void noise_serial(float x0, float y0, float x1, float y1,
|
extern void noise_serial(float x0, float y0, float x1, float y1,
|
||||||
@@ -65,14 +66,27 @@ writePPM(float *buf, int width, int height, const char *fn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main(int argc, char *argv[]) {
|
||||||
unsigned int width = 768 * 4;
|
static unsigned int test_iterations[] = {3, 1};
|
||||||
unsigned int height = 768 * 4;
|
unsigned int width = 768;
|
||||||
|
unsigned int height = 768;
|
||||||
float x0 = -10;
|
float x0 = -10;
|
||||||
float x1 = 10;
|
float x1 = 10;
|
||||||
float y0 = -10;
|
float y0 = -10;
|
||||||
float y1 = 10;
|
float y1 = 10;
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
if (strncmp(argv[1], "--scale=", 8) == 0) {
|
||||||
|
float scale = atof(argv[1] + 8);
|
||||||
|
width *= scale;
|
||||||
|
height *= scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((argc == 3) || (argc == 4)) {
|
||||||
|
for (int i = 0; i < 2; i++) {
|
||||||
|
test_iterations[i] = atoi(argv[argc - 2 + i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
float *buf = new float[width*height];
|
float *buf = new float[width*height];
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -80,10 +94,11 @@ int main() {
|
|||||||
// time of three runs.
|
// time of three runs.
|
||||||
//
|
//
|
||||||
double minISPC = 1e30;
|
double minISPC = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[0]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
noise_ispc(x0, y0, x1, y1, width, height, buf);
|
noise_ispc(x0, y0, x1, y1, width, height, buf);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minISPC = std::min(minISPC, dt);
|
minISPC = std::min(minISPC, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,10 +114,11 @@ int main() {
|
|||||||
// minimum time.
|
// minimum time.
|
||||||
//
|
//
|
||||||
double minSerial = 1e30;
|
double minSerial = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[1]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
noise_serial(x0, y0, x1, y1, width, height, buf);
|
noise_serial(x0, y0, x1, y1, width, height, buf);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of serial run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minSerial = std::min(minSerial, dt);
|
minSerial = std::min(minSerial, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,27 +96,27 @@ static void writeImage(int *idImage, float *depthImage, int width, int height,
|
|||||||
|
|
||||||
|
|
||||||
static void usage() {
|
static void usage() {
|
||||||
fprintf(stderr, "rt [--scale=<factor>] <scene name base>\n");
|
fprintf(stderr, "rt <scene name base> [--scale=<factor>] [ispc iterations] [tasks iterations] [serial iterations]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
static unsigned int test_iterations[] = {3, 7, 1};
|
||||||
float scale = 1.f;
|
float scale = 1.f;
|
||||||
const char *filename = NULL;
|
const char *filename = NULL;
|
||||||
for (int i = 1; i < argc; ++i) {
|
if (argc < 2) usage();
|
||||||
if (strncmp(argv[i], "--scale=", 8) == 0) {
|
filename = argv[1];
|
||||||
scale = atof(argv[i] + 8);
|
if (argc > 2) {
|
||||||
if (scale == 0.f)
|
if (strncmp(argv[2], "--scale=", 8) == 0) {
|
||||||
usage();
|
scale = atof(argv[2] + 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((argc == 6) || (argc == 5)) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
test_iterations[i] = atoi(argv[argc - 3 + i]);
|
||||||
}
|
}
|
||||||
else if (filename != NULL)
|
|
||||||
usage();
|
|
||||||
else
|
|
||||||
filename = argv[i];
|
|
||||||
}
|
}
|
||||||
if (filename == NULL)
|
|
||||||
usage();
|
|
||||||
|
|
||||||
#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) { \
|
||||||
@@ -211,11 +211,12 @@ int main(int argc, char *argv[]) {
|
|||||||
// Run 3 iterations with ispc + 1 core, record the minimum time
|
// Run 3 iterations with ispc + 1 core, record the minimum time
|
||||||
//
|
//
|
||||||
double minTimeISPC = 1e30;
|
double minTimeISPC = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[0]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
raytrace_ispc(width, height, baseWidth, baseHeight, raster2camera,
|
raytrace_ispc(width, height, baseWidth, baseHeight, raster2camera,
|
||||||
camera2world, image, id, nodes, triangles);
|
camera2world, image, id, nodes, triangles);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minTimeISPC = std::min(dt, minTimeISPC);
|
minTimeISPC = std::min(dt, minTimeISPC);
|
||||||
}
|
}
|
||||||
printf("[rt ispc, 1 core]:\t\t[%.3f] million cycles for %d x %d image\n",
|
printf("[rt ispc, 1 core]:\t\t[%.3f] million cycles for %d x %d image\n",
|
||||||
@@ -230,11 +231,12 @@ int main(int argc, char *argv[]) {
|
|||||||
// Run 3 iterations with ispc + 1 core, record the minimum time
|
// Run 3 iterations with ispc + 1 core, record the minimum time
|
||||||
//
|
//
|
||||||
double minTimeISPCtasks = 1e30;
|
double minTimeISPCtasks = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[1]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
raytrace_ispc_tasks(width, height, baseWidth, baseHeight, raster2camera,
|
raytrace_ispc_tasks(width, height, baseWidth, baseHeight, raster2camera,
|
||||||
camera2world, image, id, nodes, triangles);
|
camera2world, image, id, nodes, triangles);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC + TASKS run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minTimeISPCtasks = std::min(dt, minTimeISPCtasks);
|
minTimeISPCtasks = std::min(dt, minTimeISPCtasks);
|
||||||
}
|
}
|
||||||
printf("[rt ispc + tasks]:\t\t[%.3f] million cycles for %d x %d image\n",
|
printf("[rt ispc + tasks]:\t\t[%.3f] million cycles for %d x %d image\n",
|
||||||
@@ -250,11 +252,12 @@ int main(int argc, char *argv[]) {
|
|||||||
// minimum time.
|
// minimum time.
|
||||||
//
|
//
|
||||||
double minTimeSerial = 1e30;
|
double minTimeSerial = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[2]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
raytrace_serial(width, height, baseWidth, baseHeight, raster2camera,
|
raytrace_serial(width, height, baseWidth, baseHeight, raster2camera,
|
||||||
camera2world, image, id, nodes, triangles);
|
camera2world, image, id, nodes, triangles);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of serial run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minTimeSerial = std::min(dt, minTimeSerial);
|
minTimeSerial = std::min(dt, minTimeSerial);
|
||||||
}
|
}
|
||||||
printf("[rt serial]:\t\t\t[%.3f] million cycles for %d x %d image\n",
|
printf("[rt serial]:\t\t\t[%.3f] million cycles for %d x %d image\n",
|
||||||
|
|||||||
@@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <string.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "../timing.h"
|
#include "../timing.h"
|
||||||
#include "stencil_ispc.h"
|
#include "stencil_ispc.h"
|
||||||
@@ -66,9 +67,25 @@ void InitData(int Nx, int Ny, int Nz, float *A[2], float *vsq) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main() {
|
int main(int argc, char *argv[]) {
|
||||||
int Nx = 256 * 2, Ny = 256 * 2, Nz = 256 * 2;
|
static unsigned int test_iterations[] = {3, 3, 3};//the last two numbers must be equal here
|
||||||
|
int Nx = 256, Ny = 256, Nz = 256;
|
||||||
int width = 4;
|
int width = 4;
|
||||||
|
|
||||||
|
if (argc > 1) {
|
||||||
|
if (strncmp(argv[1], "--scale=", 8) == 0) {
|
||||||
|
float scale = atof(argv[1] + 8);
|
||||||
|
Nx *= scale;
|
||||||
|
Ny *= scale;
|
||||||
|
Nz *= scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((argc == 4) || (argc == 5)) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
test_iterations[i] = atoi(argv[argc - 3 + i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
float *Aserial[2], *Aispc[2];
|
float *Aserial[2], *Aispc[2];
|
||||||
Aserial[0] = new float [Nx * Ny * Nz];
|
Aserial[0] = new float [Nx * Ny * Nz];
|
||||||
Aserial[1] = new float [Nx * Ny * Nz];
|
Aserial[1] = new float [Nx * Ny * Nz];
|
||||||
@@ -79,18 +96,18 @@ int main() {
|
|||||||
float coeff[4] = { 0.5, -.25, .125, -.0625 };
|
float coeff[4] = { 0.5, -.25, .125, -.0625 };
|
||||||
|
|
||||||
InitData(Nx, Ny, Nz, Aispc, vsq);
|
InitData(Nx, Ny, Nz, Aispc, vsq);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Compute the image using the ispc implementation on one core; report
|
// Compute the image using the ispc implementation on one core; report
|
||||||
// the minimum time of three runs.
|
// the minimum time of three runs.
|
||||||
//
|
//
|
||||||
double minTimeISPC = 1e30;
|
double minTimeISPC = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[0]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
loop_stencil_ispc(0, 6, width, Nx - width, width, Ny - width,
|
loop_stencil_ispc(0, 6, width, Nx - width, width, Ny - width,
|
||||||
width, Nz - width, Nx, Ny, Nz, coeff, vsq,
|
width, Nz - width, Nx, Ny, Nz, coeff, vsq,
|
||||||
Aispc[0], Aispc[1]);
|
Aispc[0], Aispc[1]);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minTimeISPC = std::min(minTimeISPC, dt);
|
minTimeISPC = std::min(minTimeISPC, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,12 +120,13 @@ int main() {
|
|||||||
// the minimum time of three runs.
|
// the minimum time of three runs.
|
||||||
//
|
//
|
||||||
double minTimeISPCTasks = 1e30;
|
double minTimeISPCTasks = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[1]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
loop_stencil_ispc_tasks(0, 6, width, Nx - width, width, Ny - width,
|
loop_stencil_ispc_tasks(0, 6, width, Nx - width, width, Ny - width,
|
||||||
width, Nz - width, Nx, Ny, Nz, coeff, vsq,
|
width, Nz - width, Nx, Ny, Nz, coeff, vsq,
|
||||||
Aispc[0], Aispc[1]);
|
Aispc[0], Aispc[1]);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC + TASKS run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minTimeISPCTasks = std::min(minTimeISPCTasks, dt);
|
minTimeISPCTasks = std::min(minTimeISPCTasks, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,12 +139,13 @@ int main() {
|
|||||||
// minimum time.
|
// minimum time.
|
||||||
//
|
//
|
||||||
double minTimeSerial = 1e30;
|
double minTimeSerial = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[2]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
loop_stencil_serial(0, 6, width, Nx-width, width, Ny - width,
|
loop_stencil_serial(0, 6, width, Nx-width, width, Ny - width,
|
||||||
width, Nz - width, Nx, Ny, Nz, coeff, vsq,
|
width, Nz - width, Nx, Ny, Nz, coeff, vsq,
|
||||||
Aserial[0], Aserial[1]);
|
Aserial[0], Aserial[1]);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of serial run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minTimeSerial = std::min(minTimeSerial, dt);
|
minTimeSerial = std::min(minTimeSerial, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -135,10 +135,16 @@ loadVolume(const char *fn, int n[3]) {
|
|||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
if (argc != 3) {
|
static unsigned int test_iterations[] = {3, 7, 1};
|
||||||
fprintf(stderr, "usage: volume <camera.dat> <volume_density.vol>\n");
|
if (argc < 3) {
|
||||||
|
fprintf(stderr, "usage: volume <camera.dat> <volume_density.vol> [ispc iterations] [tasks iterations] [serial iterations]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
if (argc == 6) {
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
test_iterations[i] = atoi(argv[3 + i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Load viewing data and the volume density data
|
// Load viewing data and the volume density data
|
||||||
@@ -156,11 +162,12 @@ int main(int argc, char *argv[]) {
|
|||||||
// time of three runs.
|
// time of three runs.
|
||||||
//
|
//
|
||||||
double minISPC = 1e30;
|
double minISPC = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[0]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
volume_ispc(density, n, raster2camera, camera2world,
|
volume_ispc(density, n, raster2camera, camera2world,
|
||||||
width, height, image);
|
width, height, image);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minISPC = std::min(minISPC, dt);
|
minISPC = std::min(minISPC, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,11 +183,12 @@ int main(int argc, char *argv[]) {
|
|||||||
// tasks; report the minimum time of three runs.
|
// tasks; report the minimum time of three runs.
|
||||||
//
|
//
|
||||||
double minISPCtasks = 1e30;
|
double minISPCtasks = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[1]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
volume_ispc_tasks(density, n, raster2camera, camera2world,
|
volume_ispc_tasks(density, n, raster2camera, camera2world,
|
||||||
width, height, image);
|
width, height, image);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of ISPC + TASKS run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minISPCtasks = std::min(minISPCtasks, dt);
|
minISPCtasks = std::min(minISPCtasks, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,11 +204,12 @@ int main(int argc, char *argv[]) {
|
|||||||
// minimum time.
|
// minimum time.
|
||||||
//
|
//
|
||||||
double minSerial = 1e30;
|
double minSerial = 1e30;
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < test_iterations[2]; ++i) {
|
||||||
reset_and_start_timer();
|
reset_and_start_timer();
|
||||||
volume_serial(density, n, raster2camera, camera2world,
|
volume_serial(density, n, raster2camera, camera2world,
|
||||||
width, height, image);
|
width, height, image);
|
||||||
double dt = get_elapsed_mcycles();
|
double dt = get_elapsed_mcycles();
|
||||||
|
printf("@time of serial run:\t\t\t[%.3f] million cycles\n", dt);
|
||||||
minSerial = std::min(minSerial, dt);
|
minSerial = std::min(minSerial, dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
14
perf.ini
14
perf.ini
@@ -8,26 +8,29 @@
|
|||||||
% #***
|
% #***
|
||||||
% [% comment]
|
% [% comment]
|
||||||
%****************************************************************************************************
|
%****************************************************************************************************
|
||||||
|
% All parameters of iteration number must be at the end of command string. Now all of the, are default (3 7 1).
|
||||||
AOBench
|
AOBench
|
||||||
aobench
|
aobench
|
||||||
3 2048 2048
|
% --scale= from parameters
|
||||||
|
2048 2048
|
||||||
#***
|
#***
|
||||||
Deferred Shading
|
Deferred Shading
|
||||||
deferred
|
deferred
|
||||||
|
% --scale= from data and third parameter
|
||||||
data/pp1280x720.bin
|
data/pp1280x720.bin
|
||||||
#***
|
#***
|
||||||
Mandelbrot Set
|
Mandelbrot Set
|
||||||
mandelbrot
|
mandelbrot
|
||||||
|
--scale=1.0
|
||||||
#***
|
#***
|
||||||
Mandelbrot Set
|
Mandelbrot Set
|
||||||
mandelbrot_tasks
|
mandelbrot_tasks
|
||||||
|
--scale=8.0
|
||||||
^
|
^
|
||||||
#***
|
#***
|
||||||
Perlin Noise Function
|
Perlin Noise Function
|
||||||
noise
|
noise
|
||||||
|
--scale=4.0
|
||||||
#***
|
#***
|
||||||
Binomial Options
|
Binomial Options
|
||||||
options
|
options
|
||||||
@@ -45,10 +48,11 @@ sponza --scale=6.0
|
|||||||
#***
|
#***
|
||||||
3D Stencil
|
3D Stencil
|
||||||
stencil
|
stencil
|
||||||
|
--scale=2.0
|
||||||
#***
|
#***
|
||||||
Volume Rendering
|
Volume Rendering
|
||||||
volume_rendering
|
volume_rendering
|
||||||
|
% --scale= from data
|
||||||
camera.dat density_highres.vol
|
camera.dat density_highres.vol
|
||||||
#***
|
#***
|
||||||
Sort
|
Sort
|
||||||
|
|||||||
21
perf.py
21
perf.py
@@ -99,16 +99,19 @@ def analyse_test(c1, c2, test, b_serial, perf_temp_n):
|
|||||||
j+=1
|
j+=1
|
||||||
if "million cycles" in line:
|
if "million cycles" in line:
|
||||||
if j == c1:
|
if j == c1:
|
||||||
line = line.replace("]","[")
|
if line[0] == '@':
|
||||||
line = line.split("[")
|
print_debug(line, True, perf_log)
|
||||||
number = float(line[3])
|
|
||||||
if "tasks" in line[1]:
|
|
||||||
absolute_tasks.append(number)
|
|
||||||
else:
|
else:
|
||||||
if "ispc" in line[1]:
|
line = line.replace("]","[")
|
||||||
absolute_ispc.append(number)
|
line = line.split("[")
|
||||||
if "serial" in line[1]:
|
number = float(line[3])
|
||||||
serial.append(number)
|
if "tasks" in line[1]:
|
||||||
|
absolute_tasks.append(number)
|
||||||
|
else:
|
||||||
|
if "ispc" in line[1]:
|
||||||
|
absolute_ispc.append(number)
|
||||||
|
if "serial" in line[1]:
|
||||||
|
serial.append(number)
|
||||||
|
|
||||||
if len(ispc) != 0:
|
if len(ispc) != 0:
|
||||||
if len(tasks) != 0:
|
if len(tasks) != 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user