52 #include <sys/types.h>
87 char **plot_title_buf);
90 char **plot_title_buf);
135 printf(
"Error parsing arguments.\n");
150 ERRPRINTF(
"Error: asprintf failed with return code: %d\n", ret);
159 printf(
"Routine list:\n");
160 for(i=0; i<cfg->
used; i++) {
169 models = malloc(options.
n_plots *
sizeof *models);
176 for(i = 0; i < options.
n_plots; i++) {
177 printf(
"Displaying model for routine: %s\n",
186 ERRPRINTF(
"Error: asprintf failed with return code: %d\n",
196 for(j = 0; j < options.
n_plots; j++) {
201 for(i = 0; i < cfg->
used; i++) {
211 if(models[j] == NULL) {
212 printf(
"Failed to find model for routine: %s.\n",
222 for(i = 0; i < options.
n_plots; i++) {
225 if(models[i] == NULL) {
231 ret = asprintf(&(models[i]->
model_path),
"%s",
234 ERRPRINTF(
"Error: asprintf failed with return code: %d\n",
239 printf(
"Displaying model from file: %s\n",
247 for(i = 0; i < options.
n_plots; i++) {
254 ERRPRINTF(
"Error file does not exist:%s\n",
259 ERRPRINTF(
"Error parsing models[%d]: %s.\n",
269 n_p = models[i]->
n_p;
272 printf(
"Cannot plot full models in terms of >2 parameters, "
273 "specify a slice to view.\n");
277 else if(n_p != models[i]->n_p) {
278 ERRPRINTF(
"Cannot plot models with different numbers of "
279 "parameters together");
302 printf(
"specify an extension (.ps or .png) to your "
307 if(strcmp(ext,
".ps") == 0) {
311 "postscript enhanced monochrome font \"Helvetica\" 20");
315 "postscript enhanced color font \"Helvetica\" 20");
318 else if( strcmp(ext,
".eps") == 0) {
321 "postscript eps enhanced monochrome font \"Helvetica\" 20");
325 "postscript enhanced color font \"Helvetica\" 20");
328 else if(strcmp(ext,
".png") == 0) {
332 printf(
"specify an extension (.ps or .png) to your "
339 printf(
"writing to file:%s\n",
350 ERRPRINTF(
"Too many parameteres defined in slice (%d) of "
351 "model with %d parameters.\n",
358 ERRPRINTF(
"Not enough parameters defined in slice (%d) of "
359 "model with %d parameters.\n",
368 ERRPRINTF(
"Slice parameter index %d out of bounds.\n",
372 else if(options.
n_plots != 1) {
373 ERRPRINTF(
"Cannot plot slices for more than 1 model"
380 ERRPRINTF(
"Cannot specify max/min in slice when "
381 "plotting a model file directly (max/min "
382 "only defined in config file.\n");
393 ERRPRINTF(
"Slice value should positive.\n");
413 ERRPRINTF(
"Interpolation plot of multidimensional "
414 "model is not supported");
424 for(i = 0; i < options.
n_plots; i++) {
431 for(i = 0; i < options.
n_plots; i++) {
444 printf(
"press any key to close ...\n");
456 for(i = 0; i < options.
n_plots; i++) {
462 for(i = 0; i < options.
n_plots; i++) {
467 printf(
"replotting in %d secs (minimum).\n",
476 DBGPRINTF(
"models not updated. Sleeping again ...\n");
480 ERRPRINTF(
"Error testing modification of model files\n");
484 for(i = 0; i < options.
n_plots; i++) {
488 ERRPRINTF(
"Error: model file does not exist:%s\n",
503 for(i = 0; i < options.
n_plots; i++) {
542 ERRPRINTF(
"Error testing the mtime of %d-th model file.\n", i);
564 struct stat file_stats;
572 if(m->
mtime < file_stats.st_mtime) {
573 m->
mtime = file_stats.st_mtime;
620 char *plot_title_buf;
633 y = malloc(n *
sizeof *y);
635 ERRPRINTF(
"Error allocating memory y.\n");
639 x = malloc(n *
sizeof *x);
641 ERRPRINTF(
"Error allocating memory to x.\n");
649 while(b != NULL && c < n) {
655 ERRPRINTF(
"Error getting average of benchmark:\n");
665 ERRPRINTF(
"Error getting max of benchmark:\n");
674 x[c] = (double)b->
p[0];
675 y[c] = b_plot->
flops;
677 printf(
"c:%d/%d x:%f y:%f\n", c, n, x[c], y[c]);
696 if(b != NULL && c != n-1) {
697 printf(
"Error, unexpected number of benchmarks\n");
717 free(plot_title_buf);
718 plot_title_buf = NULL;
743 char *plot_title_buf;
754 double *approx_speeds;
763 for(i=0; i<model->
n_p; i++) {
777 ERRPRINTF(
"Found too many free parameters.\n");
784 ERRPRINTF(
"Not found enough free parameters.\n");
802 base_points = malloc(n *
sizeof *base_points);
803 approx_speeds = malloc(n *
sizeof *approx_speeds);
804 x = malloc(n *
sizeof *x);
806 if(x == NULL || base_points == NULL || approx_speeds == NULL) {
807 ERRPRINTF(
"Error allocating memory (n:%d).\n", n);
815 if(oct_data == NULL) {
816 ERRPRINTF(
"Error preparing octave input data.\n");
821 ERRPRINTF(
"Error calculating triangulation of data.\n");
827 base_points[i] = malloc(model->
n_p *
sizeof(
int));
832 x[i] = (double)min + (
double)i*((max-min)/(
double)n);
833 base_points[i][p0] = x[i];
839 if(approx_speeds == NULL) {
840 ERRPRINTF(
"Error interpolating model.\n");
849 ERRPRINTF(
"Error setting plot title.\n");
853 ret = asprintf(&plot_title_buf,
"%s", basename(model->
model_path));
855 ERRPRINTF(
"Error setting plot title.\n");
869 free(plot_title_buf);
870 plot_title_buf = NULL;
876 y = NULL; approx_speeds = NULL;
879 free(base_points[i]);
880 base_points[i] = NULL;
903 char *plot_title_buf;
916 for(i=0; i<model->
n_p; i++) {
930 ERRPRINTF(
"Found too many free parameters.\n");
937 ERRPRINTF(
"Not found enough free parameters.\n");
949 x = malloc(n *
sizeof *x);
950 y = malloc(n *
sizeof *y);
951 if(x == NULL || y == NULL) {
952 ERRPRINTF(
"Error allocating memory (n:%d).\n", n);
980 ERRPRINTF(
"Error getting average of benchmark!\n");
990 ERRPRINTF(
"Error getting max of benchmark:\n");
999 x[c] = (double)b->
p[p0];
1000 y[c] = b_plot->
flops;
1002 printf(
"c:%d/%d x:%f y:%f\n", c, n, x[c], y[c]);
1019 ERRPRINTF(
"No benchmarks found along specified slice.\n");
1032 ERRPRINTF(
"Error setting plot title.\n");
1036 ret = asprintf(&plot_title_buf,
"%s", basename(model->
model_path));
1038 ERRPRINTF(
"Error setting plot title.\n");
1052 free(plot_title_buf);
1053 plot_title_buf = NULL;
1078 char *plot_title_buf;
1089 for(i=0; i<model->
n_p; i++) {
1106 ERRPRINTF(
"Found too many free parameters.\n");
1112 if(p0 < 0 || p1 < 0) {
1113 ERRPRINTF(
"Not found enough free parameters.\n");
1126 x = malloc(n *
sizeof *x);
1127 y = malloc(n *
sizeof *y);
1128 z = malloc(n *
sizeof *z);
1129 if(x == NULL || y == NULL || z == NULL) {
1130 ERRPRINTF(
"Error allocating memory.\n");
1156 if(b_plot == NULL) {
1157 ERRPRINTF(
"Error getting average of benchmark!\n");
1166 if(b_plot == NULL) {
1167 ERRPRINTF(
"Error getting max of benchmark:\n");
1176 x[c] = (double)b->
p[p0];
1177 y[c] = (
double)b->
p[p1];
1178 z[c] = b_plot->
flops;
1180 printf(
"c:%d/%d x:%f y:%f z:%f\n", c, n, x[c], y[c], z[c]);
1197 ERRPRINTF(
"No benchmarks found along specified slice.\n");
1212 ERRPRINTF(
"Error setting plot title.\n");
1216 ret = asprintf(&plot_title_buf,
"%s", basename(model->
model_path));
1218 ERRPRINTF(
"Error setting plot title.\n");
1232 free(plot_title_buf);
1233 plot_title_buf = NULL;
1263 char *plot_title_buf;
1278 x = malloc(n *
sizeof *x);
1279 y = malloc(n *
sizeof *y);
1280 z = malloc(n *
sizeof *z);
1281 if(x == NULL || y == NULL || z == NULL) {
1282 ERRPRINTF(
"Error allocating memory.\n");
1295 if(b_plot == NULL) {
1296 ERRPRINTF(
"Error getting average of benchmark!\n");
1305 if(b_plot == NULL) {
1306 ERRPRINTF(
"Error getting max of benchmark:\n");
1315 x[c] = (double)b->
p[0];
1316 y[c] = (
double)b->
p[1];
1317 z[c] = b_plot->
flops;
1319 printf(
"c:%d/%d x:%f y:%f z:%f\n", c, n, x[c], y[c], z[c]);
1356 free(plot_title_buf);
1357 plot_title_buf = NULL;
1380 char **plot_title_buf)
1397 ERRPRINTF(
"Error setting plot title.\n");
1402 ret = asprintf(plot_title_buf,
"%s", basename(model->
model_path));
1404 ERRPRINTF(
"Error setting plot title.\n");
1423 char **plot_title_buf)
1447 ERRPRINTF(
"Error setting plot title.\n");
1451 ret = asprintf(plot_title_buf,
"%s", basename(model->
model_path));
1453 ERRPRINTF(
"Error setting plot title.\n");
1481 gnuplot_cmd(plot_handle,
"set label \'point\' at screen 0.1,0.10 right");
1482 gnuplot_cmd(plot_handle,
"set label \' \' at screen 0.2,0.10 point ps 1");
1483 gnuplot_cmd(plot_handle,
"set label \'empty\' at screen 0.1,0.08 right");
1484 gnuplot_cmd(plot_handle,
"set arrow from screen 0.2,0.08 to "
1487 gnuplot_cmd(plot_handle,
"set label \'climb\' at screen 0.1,0.06 right");
1488 gnuplot_cmd(plot_handle,
"set arrow from screen 0.2,0.06 to "
1491 gnuplot_cmd(plot_handle,
"set label \'bisect\' at screen 0.1,0.04 right");
1492 gnuplot_cmd(plot_handle,
"set arrow from screen 0.2,0.04 to "
1495 gnuplot_cmd(plot_handle,
"set label \'inflect\' at screen 0.1,0.02 right");
1496 gnuplot_cmd(plot_handle,
"set arrow from screen 0.2,0.02 to "
1500 while(interval != NULL) {
1503 switch(interval->
type) {
1506 gnuplot_cmd(plot_handle,
"set label \' \' at %f,%f "
1508 (
double)interval->
start[0],
1517 gnuplot_cmd(plot_handle,
"set arrow from %f,%f to "
1518 "%f,%f nohead ls %d",
1519 (
double)interval->
start[0],
1521 (
double)interval->
end[0],
1559 gnuplot_cmd(plot_handle,
"set label \'point\' at screen 0.1,0.10 right");
1560 gnuplot_cmd(plot_handle,
"set label \' \' at screen 0.2,0.10 point ps 1");
1561 gnuplot_cmd(plot_handle,
"set label \'empty\' at screen 0.1,0.08 right");
1562 gnuplot_cmd(plot_handle,
"set arrow from screen 0.2,0.08 to "
1565 gnuplot_cmd(plot_handle,
"set label \'climb\' at screen 0.1,0.06 right");
1566 gnuplot_cmd(plot_handle,
"set arrow from screen 0.2,0.06 to "
1569 gnuplot_cmd(plot_handle,
"set label \'bisect\' at screen 0.1,0.04 right");
1570 gnuplot_cmd(plot_handle,
"set arrow from screen 0.2,0.04 to "
1573 gnuplot_cmd(plot_handle,
"set label \'inflect\' at screen 0.1,0.02 right");
1574 gnuplot_cmd(plot_handle,
"set arrow from screen 0.2,0.02 to "
1578 while(interval != NULL) {
1581 switch(interval->
type) {
1584 gnuplot_cmd(plot_handle,
"set label \' \' at %f,%f,%f "
1586 (
double)interval->
start[0],
1587 (
double)interval->
start[1],
1596 gnuplot_cmd(plot_handle,
"set arrow from %f,%f,%f to "
1597 "%f,%f,%f nohead ls %d",
1598 (
double)interval->
start[0],
1599 (
double)interval->
start[1],
1601 (
double)interval->
end[0],
1602 (
double)interval->
end[1],
1634 DBGPRINTF(
"i:%d slice_i_arr[i]:%d b-p[]:%d slice_val:%d\n",