changing of examples
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
#include <algorithm>
|
||||
#include "../timing.h"
|
||||
#include "noise_ispc.h"
|
||||
#include <string.h>
|
||||
using namespace ispc;
|
||||
|
||||
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() {
|
||||
unsigned int width = 768 * 4;
|
||||
unsigned int height = 768 * 4;
|
||||
int main(int argc, char *argv[]) {
|
||||
static unsigned int test_iterations[] = {3, 1};
|
||||
unsigned int width = 768;
|
||||
unsigned int height = 768;
|
||||
float x0 = -10;
|
||||
float x1 = 10;
|
||||
float y0 = -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];
|
||||
|
||||
//
|
||||
@@ -80,10 +94,11 @@ int main() {
|
||||
// time of three runs.
|
||||
//
|
||||
double minISPC = 1e30;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int i = 0; i < test_iterations[0]; ++i) {
|
||||
reset_and_start_timer();
|
||||
noise_ispc(x0, y0, x1, y1, width, height, buf);
|
||||
double dt = get_elapsed_mcycles();
|
||||
printf("@time of ISPC run:\t\t\t[%.3f] million cycles\n", dt);
|
||||
minISPC = std::min(minISPC, dt);
|
||||
}
|
||||
|
||||
@@ -99,10 +114,11 @@ int main() {
|
||||
// minimum time.
|
||||
//
|
||||
double minSerial = 1e30;
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int i = 0; i < test_iterations[1]; ++i) {
|
||||
reset_and_start_timer();
|
||||
noise_serial(x0, y0, x1, y1, width, height, buf);
|
||||
double dt = get_elapsed_mcycles();
|
||||
printf("@time of serial run:\t\t\t[%.3f] million cycles\n", dt);
|
||||
minSerial = std::min(minSerial, dt);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user