Пример #1
0
int pc_prism_vt_4(void)
{
    struct VT_Engine vt_eng;

    RET_ON_ERR(check_smooth(&vt_eng.smooth));
    RET_ON_ERR(run_vt(&vt_eng));

    return
        bpx_unify(bpx_get_call_arg(1,4), bpx_build_integer(vt_eng.iterate   )) &&
        bpx_unify(bpx_get_call_arg(2,4), bpx_build_float  (vt_eng.lambda    )) &&
        bpx_unify(bpx_get_call_arg(3,4), bpx_build_float  (vt_eng.likelihood)) &&
        bpx_unify(bpx_get_call_arg(4,4), bpx_build_integer(vt_eng.smooth    )) ;
}
Пример #2
0
int pc_prism_em_6(void)
{
    struct EM_Engine em_eng;

    RET_ON_ERR(check_smooth(&em_eng.smooth));
    RET_ON_ERR(run_em(&em_eng));
    release_num_sw_vals();

    return
        bpx_unify(bpx_get_call_arg(1,6), bpx_build_integer(em_eng.iterate   )) &&
        bpx_unify(bpx_get_call_arg(2,6), bpx_build_float  (em_eng.lambda    )) &&
        bpx_unify(bpx_get_call_arg(3,6), bpx_build_float  (em_eng.likelihood)) &&
        bpx_unify(bpx_get_call_arg(4,6), bpx_build_float  (em_eng.bic       )) &&
        bpx_unify(bpx_get_call_arg(5,6), bpx_build_float  (em_eng.cs        )) &&
        bpx_unify(bpx_get_call_arg(6,6), bpx_build_integer(em_eng.smooth    )) ;
}
Пример #3
0
void test_smooth(int bench_index) 
{
  int i;
  int test_num;
  char *description = benchmarks_smooth[bench_index].description;
  
  for(test_num=0; test_num < DIM_CNT; test_num++) {
    int dim;

    /* Check correctness for odd (non power of two dimensions */
    create(ODD_DIM);
    run_smooth_benchmark(bench_index, ODD_DIM);
    if (check_smooth(ODD_DIM)) {
      printf("Benchmark \"%s\" failed correctness check for dimension %d.\n",
	     benchmarks_smooth[bench_index].description, ODD_DIM);
      return;
    }

    /* Create a test image of the required dimension */
    dim = test_dim_smooth[test_num];
    create(dim);

#ifdef DEBUG
    printf("DEBUG: Running benchmark \"%s\"\n", benchmarks_smooth[bench_index].description);
#endif
    /* Check that the code works */
    run_smooth_benchmark(bench_index, dim);
    if (check_smooth(dim)) {
      printf("Benchmark \"%s\" failed correctness check for dimension %d.\n",
	     benchmarks_smooth[bench_index].description, dim);
      return;
    }

    /* Measure CPE */
    {
      double num_cycles, cpe;
      int tmpdim = dim;
      void *arglist[4];
      double dimension = (double) dim;
      double work = dimension*dimension;
#ifdef DEBUG
      printf("DEBUG: dimension=%.1f\n",dimension);
      printf("DEBUG: work=%.1f\n",work);
#endif
      arglist[0] = (void *) benchmarks_smooth[bench_index].tfunct;
      arglist[1] = (void *) &tmpdim;
      arglist[2] = (void *) orig;
      arglist[3] = (void *) result;
        
      create(dim);
      num_cycles = fcyc_v((test_funct_v)&func_wrapper, arglist); 
      cpe = num_cycles/work;
      benchmarks_smooth[bench_index].cpes[test_num] = cpe;
    }
  }

  /* Print results as a table */
  printf("Smooth: Version = %s:\n", description);
  printf("Dim\t");
  for (i = 0; i < DIM_CNT; i++)
    printf("\t%d", test_dim_smooth[i]);
  printf("\tMean\n");
  
  printf("Your CPEs");
  for (i = 0; i < DIM_CNT; i++) {
    printf("\t%.1f", benchmarks_smooth[bench_index].cpes[i]);
  }
  printf("\n");

  printf("Baseline CPEs");
  for (i = 0; i < DIM_CNT; i++) {
    printf("\t%.1f", smooth_baseline_cpes[i]);
  }
  printf("\n");

  /* Compute speedup */
  {
    double prod, ratio, mean;
    prod = 1.0; /* Geometric mean */
    printf("Speedup\t");
    for (i = 0; i < DIM_CNT; i++) {
      if (benchmarks_smooth[bench_index].cpes[i] > 0.0) {
	ratio = smooth_baseline_cpes[i]/
	  benchmarks_smooth[bench_index].cpes[i];
      }
      else {
	printf("Fatal Error: Non-positive CPE value...\n");
	exit(EXIT_FAILURE);
      }
      prod *= ratio;
      printf("\t%.1f", ratio);
    }
    /* Geometric mean */
    mean = pow(prod, 1.0/(double) DIM_CNT);
    printf("\t%.1f", mean);
    printf("\n\n");
    if (mean > smooth_maxmean) {
      smooth_maxmean = mean;
      smooth_maxmean_desc = benchmarks_smooth[bench_index].description;
    }
  }

  return;  
}