79 if(read_top_interval(r->model->interval_list, i) == 0) {
80 printf("[gbbp_select_new_bench]: Error reading interval from stack.\n");
84 // return new benchmark based on that interval
85 return gbbp_bench_from_interval(r, i);
211 DBGPRINTF(
"Interval list is empty, initialising new interval list.\n");
218 if(new_i->
start == NULL) {
219 ERRPRINTF(
"Error initialising start parameter array.\n");
230 while(i != new_i->
n_p ) {
233 new_i->
start, &pc) < 0)
235 ERRPRINTF(
"Error evalutating parameter constraint.\n");
272 if(i == new_i->
n_p) {
273 ERRPRINTF(
"Could not initialise naive start point given pc "
274 "min/max restrictions.\n");
281 ERRPRINTF(
"muParser not enabled at configure.\n");
295 ERRPRINTF(
"Error reading interval from head of list\n");
299 DBGPRINTF(
"Choosing benchmark based on following interval:\n");
302 switch(top_i->
type) {
305 DBGPRINTF(
"assigning copy of interval 'point'.\n");
309 ERRPRINTF(
"Error copying interval parameter point.\n");
342 ERRPRINTF(
"Error inserting benchmark.\n");
351 DBGPRINTF(
"total time spent benchmarking point: %f\n", time_spend);
352 DBGPRINTF(
"total number executions at benchmarking point: %d\n", num_execs);
361 ERRPRINTF(
"Error proccessing intervals, inserting bench anyway\n");
368 DBGPRINTF(
"benchmarking threshold not exceeded.\n");
451 if(aligned_params == NULL) {
452 ERRPRINTF(
"Error initialising aligned param array.\n");
460 LOGPRINTF(
"unexpected benchmark ... expected:\n");
474 while(i != interval->
n_p ) {
477 interval->
start, &pc) < 0)
479 ERRPRINTF(
"Error evalutating parameter constraint.\n");
496 if(pc < r->pd_set->pc_min) {
514 ERRPRINTF(
"muParser not enabled at configure.\n");
525 if(i==interval->
n_p) {
527 LOGPRINTF(
"Naive construction complete.\n");
538 ERRPRINTF(
"Expected empty construction interval list but found:\n");
563 for(i=0; i<interval->
n_p; i++) {
622 ERRPRINTF(
"Error, Naive 1D Bisection method cannot be used to construct"
623 " for multi-dimensional problem.\n");
632 DBGPRINTF(
"Interval list is empty, initializing new interval list.\n");
637 ERRPRINTF(
"Error initialising new construction intervals.\n");
643 params = malloc(r->
pd_set->
n_p *
sizeof *params);
650 ERRPRINTF(
"Error reading interval from head of list\n");
658 DBGPRINTF(
"Choosing benchmark based on following interval:\n");
661 switch(top_i->
type) {
664 DBGPRINTF(
"Applying step of GBBP to benchmark selection.\n");
673 DBGPRINTF(
"Benchmarking at point ...\n");
679 ERRPRINTF(
"Invalid interval type: %s (%d)\n",
721 if(bisect_i->
start == NULL || bisect_i->
end == NULL) {
722 ERRPRINTF(
"Error initializing start/end parameter array.\n");
741 DBGPRINTF(
"Interval not divisible, not adding.\n");
754 if(point_i->
start == NULL) {
755 ERRPRINTF(
"Error initialising parameter array copy.\n");
768 if(point_i->
start == NULL) {
769 ERRPRINTF(
"Error initialising parameter array copy.\n");
804 params = malloc(r->
pd_set->
n_p *
sizeof *params);
870 return (
int)(rand()%(max-min))+min;
902 DBGPRINTF(
"Interval list is empty, initializing new interval list.\n");
905 ERRPRINTF(
"Error initialising new construction intervals.\n");
910 params = malloc(r->
pd_set->
n_p *
sizeof *params);
917 ERRPRINTF(
"Error reading interval from head of list\n");
925 DBGPRINTF(
"Choosing benchmark based on following interval:\n");
928 switch(top_i->
type) {
934 DBGPRINTF(
"Applying step of GBBP to benchmark selection.\n");
943 DBGPRINTF(
"Benchmarking at point ...\n");
949 ERRPRINTF(
"Invalid interval type: %s (%d)\n",
992 step_params = malloc(r->
pd_set->
n_p *
sizeof *step_params);
993 if(step_params == NULL) {
1006 if(diag_i->
start == NULL || diag_i->
end == NULL) {
1007 ERRPRINTF(
"Error initializing start/end parameter array.\n");
1041 if(proj_i == NULL) {
1042 ERRPRINTF(
"Error creating projection interval.\n");
1061 if(proj_i->
start[j] != proj_i->
end[j] &&
1064 DBGPRINTF(
"adding interval:\n");
1070 DBGPRINTF(
"Interval not divisible, not adding.\n");
1084 if(point_i == NULL) {
1085 ERRPRINTF(
"Error creating new point interval.\n");
1089 DBGPRINTF(
"Adding non zero end interval naive projection\n");
1095 else if(proj_i != NULL)
1099 if(zero_b == NULL) {
1100 ERRPRINTF(
"Error allocating new benchmark.\n");
1106 ERRPRINTF(
"Error inserting a zero benchmark.\n");
1118 ERRPRINTF(
"Error stepping along diagonal interval.\n");
1169 DBGPRINTF(
"Interval list is empty, initializing new interval list.\n");
1172 ERRPRINTF(
"Error initialising new construction intervals.\n");
1177 params = malloc(r->
pd_set->
n_p *
sizeof *params);
1178 if(params == NULL) {
1179 ERRPRINTF(
"Error allocating memory.\n");
1184 ERRPRINTF(
"Error reading interval from head of list\n");
1192 DBGPRINTF(
"Choosing benchmark based on following interval:\n");
1195 switch(top_i->
type) {
1201 DBGPRINTF(
"Applying step of GBBP to benchmark selection.\n");
1209 DBGPRINTF(
"GBBP stage of construction complete. Meshing ...\n");
1217 ERRPRINTF(
"Error projecting new intervals from diagonal\n");
1227 ERRPRINTF(
"Error reading interval from head of list\n");
1235 DBGPRINTF(
"Meshing complete, fetching benchmark ...\n");
1241 ERRPRINTF(
"Invalid IT_BOUNDARY_COMPLETE in 1 param model.\n");
1246 LOGPRINTF(
"Multidensional Diagonal GBBP Construction "
1264 DBGPRINTF(
"Benchmarking at point ...\n");
1270 ERRPRINTF(
"Invalid interval type: %s (%d)\n",
1308 int all_nonzero_end;
1335 if(diag_i->
start == NULL) {
1336 ERRPRINTF(
"Error initialising start parameter array.\n");
1342 if(diag_i->
end == NULL) {
1343 ERRPRINTF(
"Error initialising end parameter array.\n");
1361 DBGPRINTF(
"Interval not divisible, not adding.\n");
1378 all_nonzero_end = 1;
1387 if(new_i->
start == NULL) {
1388 ERRPRINTF(
"Error initialising start parameter array.\n");
1398 all_nonzero_end = 0;
1407 if(all_nonzero_end == 1 && diag_i != NULL) {
1408 DBGPRINTF(
"nonzero end on all params\n");
1416 if(new_i->
start == NULL) {
1417 ERRPRINTF(
"Error initialising end point parameter array.\n");
1425 else if(diag_i != NULL) {
1432 if(zero_b == NULL) {
1433 ERRPRINTF(
"Error allocating new benchmark.\n");
1439 ERRPRINTF(
"Error inserting a zero benchmark.\n");
1447 DBGPRINTF(
"New Intervals initialized:\n");
1466 #ifdef HAVE_MUPARSER
1468 double pp, start_pc, end_pc;
1480 ERRPRINTF(
"Error evaluating parameter constraint.\n");
1486 ERRPRINTF(
"Error evaluating parameter constraint.\n");
1490 if(start_pc < pd_set->pc_min && end_pc < pd_set->pc_min) {
1491 ERRPRINTF(
"Interval cannot be adjusted to fit parameter product "
1495 else if(start_pc < pd_set->pc_min) {
1497 else if(end_pc < pd_set->pc_min) {
1500 DBGPRINTF(
"Interval already satisfies parameter product constraint.\n");
1503 pc_min_params = malloc(pd_set->
n_p *
sizeof *pc_min_params);
1504 if(pc_min_params == NULL) {
1505 ERRPRINTF(
"Error allocating memory.\n");
1515 if(start_pc < pd_set->pc_min) {
1533 ERRPRINTF(
"Error evaluating parameter constraint.\n");
1535 free(pc_min_params);
1536 pc_min_params = NULL;
1541 DBGPRINTF(
"param product:%f, param_product_min:%d\n", pp,
1546 if(pp >= pd_set->
pc_min) {
1556 DBGPRINTF(
"Parameter product was not exceeded by interval.\n");
1561 if(start_pc < pd_set->pc_min) {
1572 free(pc_min_params);
1573 pc_min_params = NULL;
1579 ERRPRINTF(
"muParser not enabled at configure.\n");
1599 #ifdef HAVE_MUPARSER
1601 double pp, start_pc, end_pc;
1616 ERRPRINTF(
"Error evaluating parameter constraint.\n");
1622 ERRPRINTF(
"Error evaluating parameter constraint.\n");
1626 if(start_pc > pd_set->
pc_max && end_pc > pd_set->
pc_max) {
1627 ERRPRINTF(
"Interval cannot be adjusted to fit parameter product "
1631 else if(start_pc > pd_set->
pc_max) {
1633 else if(end_pc > pd_set->
pc_max) {
1636 DBGPRINTF(
"Interval already satisfies parameter product constraint.\n");
1639 pc_max_params = malloc(pd_set->
n_p *
sizeof *pc_max_params);
1640 if(pc_max_params == NULL) {
1641 ERRPRINTF(
"Error allocating memory.\n");
1650 if(start_pc > pd_set->
pc_max) {
1667 ERRPRINTF(
"Error evaluating parameter constraint.\n");
1669 free(pc_max_params);
1670 pc_max_params = NULL;
1675 DBGPRINTF(
"param product:%f, param_product_max%d\n", pp,
1679 if(nonzero_end == 1) {
1683 if(pp > pd_set->
pc_max) {
1694 if(pp >= pd_set->
pc_max) {
1705 DBGPRINTF(
"Parameter product was not exceeded by interval.\n");
1709 if(start_pc > pd_set->
pc_max) {
1720 free(pc_max_params);
1721 pc_max_params = NULL;
1728 ERRPRINTF(
"muParser not enabled at configure.\n");
1758 int all_nonzero_end;
1760 all_nonzero_end = 1;
1762 for(j=0; j<pd_set->
n_p; j++) {
1767 all_nonzero_end = 0;
1774 return all_nonzero_end;
1811 zero_list_head = NULL;
1826 }
while(b != NULL && b->
flops == 0.0);
1831 for(j=0; j<m->
n_p; j++) {
1837 ERRPRINTF(
"Error creating new projection interval.\n");
1853 DBGPRINTF(
"Adding diagonal projection interval.\n");
1858 DBGPRINTF(
"Interval not divisible, not adding.\n");
1869 ERRPRINTF(
"Error creating new point interval.\n");
1873 DBGPRINTF(
"Adding nonzero end interval in diagonal "
1885 if(zero_b == NULL) {
1886 ERRPRINTF(
"Error allocating new benchmark.\n");
1897 if(zero_list_head == NULL) {
1898 zero_list_head = zero_b;
1901 zero_list_head->
next = zero_b;
1903 zero_list_head = zero_b;
1921 }
while(b != NULL && b->
flops == 0.0);
1926 zero_b = zero_list_head;
1927 while(zero_b != NULL) {
1931 DBGPRINTF(
"Inserting zero benchmark from saved list:\n");
1934 ERRPRINTF(
"Error inserting a zero benchmark.\n");
1973 ERRPRINTF(
"Error creating new interval structure.\n");
1981 if(new_i->
start == NULL) {
1982 ERRPRINTF(
"Error initialising interval start parameter.\n");
1989 if(new_i->
end == NULL) {
1990 ERRPRINTF(
"Error initialising interval end parameter.\n");
2045 DBGPRINTF(
"Interval list is empty, initializing new interval list.\n");
2048 ERRPRINTF(
"Error initialising new construction intervals.\n");
2053 params = malloc(r->
pd_set->
n_p *
sizeof *params);
2054 if(params == NULL) {
2055 ERRPRINTF(
"Error allocating memory.\n");
2060 ERRPRINTF(
"Error reading interval from head of list\n");
2068 DBGPRINTF(
"Choosing benchmark based on following interval:\n");
2071 switch(top_i->
type) {
2077 DBGPRINTF(
"Applying step of GBBP to benchmark selection.\n");
2085 DBGPRINTF(
"GBBP stage of construction complete. Meshing ...\n");
2096 ERRPRINTF(
"Error reading interval from head of list\n");
2104 DBGPRINTF(
"Meshing complete, fetching benchmark ...\n");
2110 ERRPRINTF(
"Invalid IT_BOUNDARY_COMPLETE in 1 param model.\n");
2115 LOGPRINTF(
"GBBP Construction complete.\n");
2132 DBGPRINTF(
"Benchmarking at point ...\n");
2138 ERRPRINTF(
"Invalid interval type: %s (%d)\n",
2191 DBGPRINTF(
"nonzero_end on param:%d\n", j);
2201 if(new_i->
start == NULL) {
2202 ERRPRINTF(
"Error initialising start parameter array.\n");
2208 if(new_i->
end == NULL) {
2209 ERRPRINTF(
"Error initialising start parameter array.\n");
2219 DBGPRINTF(
"Interval not divisible, not adding.\n");
2231 if(new_i->
start == NULL) {
2232 ERRPRINTF(
"Error initialising start parameter array.\n");
2252 if(new_i->
start == NULL) {
2253 ERRPRINTF(
"Error initialising start parameter array.\n");
2259 if(new_i->
end == NULL) {
2260 ERRPRINTF(
"Error initialising start parameter array.\n");
2270 DBGPRINTF(
"Interval not divisible, not adding.\n");
2299 LOGPRINTF(
"1 parameter models have no mesh.\n");
2303 params = malloc(n_p *
sizeof *params);
2304 if(params == NULL) {
2305 ERRPRINTF(
"Error allocating memory.\n");
2402 DBGPRINTF(
"benchmark params:\n");
2406 ERRPRINTF(
"Error inserting benchmark.\n");
2415 DBGPRINTF(
"total time spent benchmarking point: %f\n", time_spend);
2416 DBGPRINTF(
"total number executions at benchmarking point: %d\n", num_execs);
2425 ERRPRINTF(
"Error searching intervals.\n");
2429 if(interval != NULL) {
2433 midpoint = malloc(interval->
n_p *
sizeof *midpoint);
2434 if(midpoint == NULL) {
2435 ERRPRINTF(
"Error allocating memory.\n");
2443 interval->
start, midpoint);
2445 ERRPRINTF(
"Error initialising new interval.\n");
2454 DBGPRINTF(
"Interval not divisible, not adding.\n");
2461 midpoint, interval->
end);
2463 ERRPRINTF(
"Error initialising new interval.\n");
2472 DBGPRINTF(
"Interval not divisible, not adding.\n");
2488 ERRPRINTF(
"Unexpected interval type.\n");
2493 DBGPRINTF(
"interval list now empty.\n");
2504 DBGPRINTF(
"benchmarking threshold not exceeded.\n");
2565 DBGPRINTF(
"benchmark params:\n");
2569 ERRPRINTF(
"Error inserting benchmark.\n");
2578 DBGPRINTF(
"total time spent benchmarking point: %f\n", time_spend);
2579 DBGPRINTF(
"total number executions at benchmarking point: %d\n", num_execs);
2586 ERRPRINTF(
"Error proccessing intervals, inserting bench anyway\n");
2591 DBGPRINTF(
"benchmarking threshold not exceeded.\n");
2631 temp_params = malloc(r->
pd_set->
n_p *
sizeof *temp_params);
2632 if(temp_params == NULL) {
2633 ERRPRINTF(
"Error allocating memory.\n");
2638 while(i != NULL && !done) {
2647 ERRPRINTF(
"Error getting benchmark from interval.\n");
2659 DBGPRINTF(
"Interval found:\n");
2711 temp_params = malloc(r->
pd_set->
n_p *
sizeof *temp_params);
2712 if(temp_params == NULL) {
2713 ERRPRINTF(
"Error allocating memory.\n");
2718 while(i != NULL && !done) {
2727 ERRPRINTF(
"Error getting benchmark from interval.\n");
2739 DBGPRINTF(
"Interval found:\n");
2746 ERRPRINTF(
"Error processing interval.\n");
2861 DBGPRINTF(
"Interval not divisible, removing.\n");
2895 struct pmm_benchmark *b_avg, *b_left_0, *b_left_1, *b_left_2;
2905 DBGPRINTF(
"not enough points to test climbing, keep climbing...\n");
2911 DBGPRINTF(
"Interval not divisible, removing.\n");
2920 ERRPRINTF(
"No benchmark found for current point.\n");
2927 tmp_params = malloc(b->
n_p *
sizeof *tmp_params);
2928 if(tmp_params == NULL) {
2929 ERRPRINTF(
"Error allocating parameter array.\n");
2949 if(b_left_0 == NULL || b_left_1 == NULL || b_left_2 == NULL) {
2950 ERRPRINTF(
"Error, no benchmark @ a previous climb point\n");
2954 if(b_left_0 != NULL)
2956 if(b_left_1 != NULL)
2958 if(b_left_2 != NULL)
2967 DBGPRINTF(
"b_left_0:\n");
2969 DBGPRINTF(
"b_left_1\n");
2971 DBGPRINTF(
"b_left_2:\n");
2989 DBGPRINTF(
"performance no longer climbing\n");
2990 DBGPRINTF(
"previous bench speeds:\n");
2991 DBGPRINTF(
"%f@%d %f@%d %f@%d\n",
2996 DBGPRINTF(
"this bench:\n");
3003 ERRPRINTF(
"Error initialising new interval.\n");
3011 DBGPRINTF(
"Interval not divisible, not adding.\n");
3022 DBGPRINTF(
"performance still climbing\n");
3023 DBGPRINTF(
"previous bench speeds:\n");
3024 DBGPRINTF(
"%f@%d %f@%d %f@%d\n",
3028 DBGPRINTF(
"this bench:\n");
3035 DBGPRINTF(
"Interval not divisible, removing.\n");
3051 DBGPRINTF(
"interval list now empty.\n");
3138 struct pmm_benchmark *b_avg, *b_oldapprox, *b_left, *b_right;
3140 int intersects_left, intersects_right;
3150 midpoint = malloc(i->
n_p *
sizeof *midpoint);
3151 if(midpoint == NULL) {
3152 ERRPRINTF(
"Error allocating memory.\n");
3160 if(b_left == NULL) {
3161 ERRPRINTF(
"Error, no benchmark @ interval start\n");
3172 if(b_right == NULL) {
3173 ERRPRINTF(
"Error, no benchmark @ interval end\n");
3188 if(intersects_left == 1 && intersects_right == 1) {
3195 DBGPRINTF(
"finished building from:\n");
3202 else if(intersects_left == 1 && intersects_right != 1) {
3213 ERRPRINTF(
"Error initialising new interval.\n");
3221 DBGPRINTF(
"Interval not divisible, not adding.\n");
3226 DBGPRINTF(
"finished building from:\n");
3234 else if(intersects_right == 1 && intersects_left != 1) {
3243 i->
start, midpoint);
3245 ERRPRINTF(
"Error initialising new interval.\n");
3253 DBGPRINTF(
"Interval not divisible, not adding.\n");
3258 DBGPRINTF(
"finished building from:\n");
3267 DBGPRINTF(
"intersects neither left or right of"
3268 " interval, finding old approximation.\n");
3272 if(b_oldapprox == NULL) {
3273 ERRPRINTF(
"Error finding old approximation.\n");
3285 DBGPRINTF(
"new bench intersects old approx.\n");
3288 i->
start, midpoint);
3290 ERRPRINTF(
"Error initialising new interval.\n");
3298 DBGPRINTF(
"Interval not divisible, not adding.\n");
3306 ERRPRINTF(
"Error initialising new interval.\n");
3314 DBGPRINTF(
"Interval not divisible, not adding.\n");
3329 DBGPRINTF(
"does not intersect left/right or "
3330 "old approximation, splitting...\n");
3333 i->
start, midpoint);
3335 ERRPRINTF(
"Error initialising new interval.\n");
3343 DBGPRINTF(
"Interval not divisible, not adding.\n");
3351 ERRPRINTF(
"Error initialising new interval.\n");
3359 DBGPRINTF(
"Interval not divisible, not adding.\n");
3367 if(b_oldapprox != NULL) {
3377 if(b_left != NULL) {
3380 if(b_right != NULL) {
3385 DBGPRINTF(
"interval list now empty.\n");
3436 struct pmm_benchmark *b_avg, *b_left, *b_right, *b_oldapprox;
3438 int intersects_left, intersects_right;
3449 if(b_oldapprox == NULL) {
3450 ERRPRINTF(
"Error finding old approximation.\n");
3457 midpoint = malloc(i->
n_p *
sizeof *midpoint);
3458 if(midpoint == NULL) {
3459 ERRPRINTF(
"Error allocating memory.\n");
3468 if(b_left == NULL) {
3469 ERRPRINTF(
"Error, no benchmark @ interval start\n");
3481 if(b_right == NULL) {
3482 ERRPRINTF(
"Error, no benchmark @ interval end\n");
3508 if(intersects_left == 1 && intersects_right == 1) {
3511 else if(intersects_left == 1) {
3523 ERRPRINTF(
"Error initialising new interval.\n");
3539 DBGPRINTF(
"Interval not divisible, not adding.\n");
3546 else if(intersects_right == 1) {
3551 i->
start, midpoint);
3554 ERRPRINTF(
"Error initialising new interval.\n");
3570 DBGPRINTF(
"Interval not divisible, not adding.\n");
3583 i->
start, midpoint);
3586 ERRPRINTF(
"Error initialising new interval.\n");
3602 DBGPRINTF(
"Interval not divisible, not adding.\n");
3611 ERRPRINTF(
"Error initialising new interval.\n");
3627 DBGPRINTF(
"Interval not divisible, not adding.\n");
3641 if(b_oldapprox != NULL) {
3644 if(b_left != NULL) {
3647 if(b_right != NULL) {
3652 DBGPRINTF(
"interval list now empty.\n");
3688 DBGPRINTF(
"interval list now empty.\n");
3724 int *start_aligned, *end_aligned;
3735 params = malloc(r->
pd_set->
n_p *
sizeof *params);
3738 if(params == NULL || start_aligned == NULL || end_aligned == NULL) {
3739 ERRPRINTF(
"Error allocating memory.\n");
3749 ERRPRINTF(
"Error getting GBBP bench point from interval.\n");
3751 free(start_aligned);
3752 start_aligned = NULL;
3767 free(start_aligned);
3768 start_aligned = NULL;
3777 free(start_aligned);
3778 start_aligned = NULL;
3835 switch (interval->
type) {
3838 DBGPRINTF(
"assigning start problem size.\n");
3846 DBGPRINTF(
"assigning increment on interval start point.\n");
3865 DBGPRINTF(
"assigned midpoint of interval from start:\n");
3867 DBGPRINTF(
"to end:\n");
3876 DBGPRINTF(
"assigning copy of interval 'point'.\n");
3888 ERRPRINTF(
"Invalid interval type: %s\n",
3912 DBGPRINTF(
"i->n_p:%d\n", i->
n_p);
3914 for(j=0; j<i->
n_p; j++) {
3917 p[j] = ((i->
start[j]+i->
end[j])+1)/2;