Modify rt example to also do a set of runs with tasks + SPMD together.

This commit is contained in:
Matt Pharr
2011-08-17 13:14:32 +01:00
parent d7662b3eb9
commit 60bdf1ef8a
7 changed files with 643 additions and 19 deletions

View File

@@ -134,6 +134,9 @@ int main(int argc, char *argv[]) {
ensureTargetISAIsSupported();
extern void TasksInit();
TasksInit();
#define READ(var, n) \
if (fread(&(var), sizeof(var), n, f) != (unsigned int)n) { \
fprintf(stderr, "Unexpected EOF reading scene file\n"); \
@@ -215,7 +218,7 @@ int main(int argc, char *argv[]) {
}
fclose(f);
// round image resolution up to multiple of 4 to makethings easy for
// round image resolution up to multiple of 4 to make things easy for
// the code that assigns pixels to ispc program instances
height = (height + 3) & ~3;
width = (width + 3) & ~3;
@@ -226,19 +229,42 @@ int main(int argc, char *argv[]) {
float *image = new float[width*height];
//
// Run 3 iterations with ispc, record the minimum time
// Run 3 iterations with ispc + 1 core, record the minimum time
//
double minTimeISPC = 1e30;
for (int i = 0; i < 3; ++i) {
reset_and_start_timer();
raytrace(width, height, raster2camera, camera2world,
image, id, nodes, triangles);
raytrace_ispc(width, height, raster2camera, camera2world,
image, id, nodes, triangles);
double dt = get_elapsed_mcycles();
minTimeISPC = std::min(dt, minTimeISPC);
}
printf("[rt ispc]:\t\t\t[%.3f] million cycles for %d x %d image\n", minTimeISPC, width, height);
printf("[rt ispc, 1 core]:\t\t[%.3f] million cycles for %d x %d image\n",
minTimeISPC, width, height);
writeImage(id, image, width, height, "rt-ispc.ppm");
writeImage(id, image, width, height, "rt-ispc-1core.ppm");
memset(id, 0, width*height*sizeof(int));
memset(image, 0, width*height*sizeof(float));
//
// Run 3 iterations with ispc + 1 core, record the minimum time
//
double minTimeISPCtasks = 1e30;
for (int i = 0; i < 3; ++i) {
reset_and_start_timer();
raytrace_ispc_tasks(width, height, raster2camera, camera2world,
image, id, nodes, triangles);
double dt = get_elapsed_mcycles();
minTimeISPCtasks = std::min(dt, minTimeISPCtasks);
}
printf("[rt ispc + tasks]:\t\t[%.3f] million cycles for %d x %d image\n",
minTimeISPCtasks, width, height);
writeImage(id, image, width, height, "rt-ispc-tasks.ppm");
memset(id, 0, width*height*sizeof(int));
memset(image, 0, width*height*sizeof(float));
//
// And 3 iterations with the serial implementation, reporting the
@@ -254,7 +280,8 @@ int main(int argc, char *argv[]) {
}
printf("[rt serial]:\t\t\t[%.3f] million cycles for %d x %d image\n",
minTimeSerial, width, height);
printf("\t\t\t\t(%.2fx speedup from ISPC)\n", minTimeSerial / minTimeISPC);
printf("\t\t\t\t(%.2fx speedup from ISPC, %.2f from ISPC + tasks)\n",
minTimeSerial / minTimeISPC, minTimeSerial / minTimeISPCtasks);
writeImage(id, image, width, height, "rt-serial.ppm");