Пример #1
0
/* Perform test of combination function */
static void run_test(int bench_index) {
    double cpe;
    char *description = benchmarks[bench_index].description;
    data_t good_result;
    current_benchmark = bench_index;
    setup();
#if 0    
    cpe = find_cpe(run, ASIZE);
#endif
#if USE_UNI
    cpe = find_cpe_full(run, ASIZE, 12, stdout, UNI_SAMPLE, 0.3, 0);
#else /* USE_UNI */
    cpe = find_cpe_full(run, ASIZE, 200, stdout, RAN_SAMPLE, 0.3, 0);
#endif
    benchmarks[bench_index].cfunct(data, data, &combine_result);
    benchmarks[bench_index].checkfunct(data, data, &good_result);
    if (combine_result != good_result) {
	printf("Function %s, Should be %d, Got %d\n",
	       description, (int) good_result, (int) combine_result);
    }
    benchmarks[current_benchmark].cpe = cpe;
    /* print results */
    /* Column Heading */
    printf("%s %s %s:\n", DATA_NAME, OP_NAME, description);
    printf("%.2f cycles/element\n", cpe);
}
Пример #2
0
/* Test and measure polynomial evaluation function.  Set values
   of CPE and CFIX */
void run_poly(peval_fun f, char *descr, double *cpep, double *cfixp)
{
    pfun = f;
    printf("Function %s\n", descr);
    if (test_poly(f, stdout)) {
	double cpe = 
	    find_cpe_full(run_fun, test_degree, 300, 
			  stdout, RAN_SAMPLE, 0.2, 0);
	double fix_time = measure_function(run_fun, FIXDEGREE);
	if (verbose)
	    printf("   CPE = %.2f\tOverhead = %.2f\tC(%d) = %.1f\n", cpe,
		   last_overhead, FIXDEGREE, fix_time);
	else
	    printf("   CPE = %.2f\tC(%d) = %.1f\n", cpe,
		   FIXDEGREE, fix_time);
	if (cpep)
	  *cpep = cpe;
	if (cfixp)
	  *cfixp = fix_time;
    }
}
Пример #3
0
/* Use default parameters */
double find_cpe(elem_fun_t f, int maxcnt)
{
  return find_cpe_full(f, maxcnt, 100, stdout, RAN_SAMPLE, 0.3, 0);
}
Пример #4
0
int main(int argc, char *argv[])
{
    elem_fun_t f = tpsum1;
    int cnt = 1024;
    int i;
    int samples = 8;
    double bias = 0.0;
    int reps = 1;
    int seed = 31415;
    int verbose = 2;
    sample_t smethod = UNI_SAMPLE;
    for (i = 1; i < argc; i++) {
	if (*argv[i] == '-')
	    switch(argv[i][1]) {
	    case 'u':
		f = tpsum2;
		break;
	    case 'a':
		f = tpsum1a;
		break;
	    case 'r':
		smethod = RAN_SAMPLE;
		break;
	    case 'q':
		verbose = 0;
		break;
	    case 'l':
		i++;
		if (i >= argc)
		    usage(argv[0]);
		cnt = atoi(argv[i]);
		if (cnt <= 0 || cnt > MAXCNT)
		    usage(argv[0]);
		break;
	    case 'n':
		i++;
		if (i >= argc)
		    usage(argv[0]);
		reps = atoi(argv[i]);
		if (reps < 0)
		    usage(argv[0]);
		break;
	    case 'k':
		i++;
		if (i >= argc)
		    usage(argv[0]);
		seed = atoi(argv[i]);
		break;
	    case 'b':
		i++;
		if (i >= argc)
		    usage(argv[0]);
		bias = atof(argv[i]);
		if (bias < 0 || bias > 1.0)
		    usage(argv[0]);
		break;
	    case 's':
		i++;
		if (i >= argc)
		    usage(argv[0]);
		samples = atoi(argv[i]);
		if (samples <= 0)
		    usage(argv[0]);
		break;
	    default:
		usage(argv[0]);
		break;
	    }
    }
    setup(cnt);
    if (f != tpsum1)
	check(f, cnt);
    if (samples == 1) {
	double t = measure_function(f, cnt);
	printf("Cycles = %.2f, CPE = %.2f\n",
	       t, t/cnt);
    } else {
	double cpe_full, cpe_def;
	while (reps--) {
	    srandom(seed);
	    cpe_full = find_cpe_full(f, cnt, samples, stdout, smethod, bias, verbose);
	    printf("Full cpe = %.2f\n", cpe_full);
	}
	cpe_def = find_cpe(f, cnt);
	printf("Default cpe = %.2f\n", cpe_def);
    }
    return 0;
}