37 #include <gsl/gsl_statistics_double.h>
61 printf(
"Usage: pmm_comp -a model_a -b model_b\n");
63 printf(
" -a model_a : approximation that will be compared\n");
64 printf(
" -b model_b : base model which will be compared to\n");
87 static struct option long_options[] =
89 {
"approx-model", required_argument, 0,
'a'},
90 {
"base-model", required_argument, 0,
'b'},
91 {
"help", no_argument, 0,
'h'},
97 c = getopt_long(argc, argv,
"a:b:h", long_options, &option_index);
131 fprintf(stderr,
"Error: model files must be specified.\n");
155 double *base_speed, *approx_speed;
168 base_points = malloc(n *
sizeof *base_points);
169 base_speed = malloc(n *
sizeof *base_speed);
171 if(base_speed == NULL || base_points == NULL) {
177 if(oct_data == NULL) {
178 ERRPRINTF(
"Error preparing octave input data.\n");
183 ERRPRINTF(
"Error calcuating triangulation of data.\n");
188 while(b != NULL && c < n) {
192 ERRPRINTF(
"Error getting average of benchmark:\n");
197 base_speed[c] = b_avg->
flops;
207 if(b != NULL && c != n-1) {
208 ERRPRINTF(
"Error, unexpected number of benchmarks\n");
215 if(approx_speed == NULL) {
216 ERRPRINTF(
"Error interpolating approximation\n");
220 correlation = gsl_stats_correlation(base_speed, 1, approx_speed, 1, n);
222 for(j=0; j<base_model->
n_p; j++)
225 printf(
"base_speed approx_speed diff %%diff\n");
229 for(j=0; j<base_model->
n_p; j++)
230 printf(
"%d ", base_points[i][j]);
232 printf(
"%f %f %f %f\n", base_speed[i], approx_speed[i], fabs(base_speed[i]-approx_speed[i]), fabs(base_speed[i]-approx_speed[i])/base_speed[i]);
233 free(base_points[i]);
234 base_points[i] = NULL;
257 struct pmm_model *approx_model, *base_model;
271 if(approx_model == NULL || base_model == NULL) {
272 ERRPRINTF(
"Error allocating new model.\n");
290 ERRPRINTF(
"Error parsing approx model.\n");
300 ERRPRINTF(
"Error base parsing base model.\n");
307 printf(
"model correlation:%f\n", correlation);
308 printf(
"base model points:%d\n", base_model->
completion);
310 printf(
"approx model points:%d\n", approx_model->
completion);