61 c = malloc(
sizeof *c);
65 ERRPRINTF(
"allocation of memory to routine array failed.\n");
102 r = malloc(
sizeof *r);
136 m = malloc(
sizeof *m);
172 bl = malloc(
sizeof *bl);
231 for(i=0; i<pd_set->
n_p; i++) {
249 ERRPRINTF(
"Error inserting end axial point into list.\n");
261 if(all_nonzero_end != 1) {
268 ERRPRINTF(
"Error initialising end parameters.\n");
277 ERRPRINTF(
"Error inserting initial bench into list.\n");
324 b = malloc(
sizeof *b);
339 b->
next = (
void *)NULL;
363 ERRPRINTF(
"Error allocating new zero speed benchmark.\n");
370 ERRPRINTF(
"Error copy parameter array.\n");
408 ERRPRINTF(
"Reallocation of memory to routine array failed.\n");
446 while(
this != NULL) {
451 ERRPRINTF(
"Error inserting bench into list.\n");
470 ERRPRINTF(
"Error inserting bench into list.\n");
494 ERRPRINTF(
"Error inserting bench into list.\n");
527 ERRPRINTF(
"Error inserting bench in bench list\n");
553 ERRPRINTF(
"paramdef array and benchmark param array size mismatch\n");
558 LOGPRINTF(
"b->p[%d]:%d paramdef[%d].start:%d\n", i, b->
p[i], i,
560 if(b->
p[i] != pd_array[i].
start) {
593 ERRPRINTF(
"Mesh model not initialized.\n");
597 if(b->
flops != 0.0) {
709 ERRPRINTF(
"Error copying parameter array.\n");
721 dst->
next = (
void *)NULL;
751 if(*list_first == NULL && *list_last == NULL) {
753 b->
next = (
void *)NULL;
760 ERRPRINTF(
"Insertion before NULL benchmark in non-empty list.\n");
764 else if(before == *list_first) {
805 if(*list_first == NULL && *list_last == NULL) {
807 b->
next = (
void *)NULL;
814 ERRPRINTF(
"Insertion after NULL benchmark in non-empty list.\n");
818 else if(after == *list_last) {
820 b->
next = (
void *)NULL;
854 if(b == *list_first && b == *list_last) {
856 ERRPRINTF(
"benchmark is both first and last of list, but has "
857 "non-NULL next / previous pointers.\n");
865 else if(b == *list_first) {
866 if(b->
next != NULL) {
867 ERRPRINTF(
"benchmark is first in list but has non-NULL next "
879 else if(b == *list_last) {
881 ERRPRINTF(
"benchmark is last in list but has non-NULL previous"
886 *list_last = b->
next;
888 if(b->
next != NULL) {
895 ERRPRINTF(
"benchmark not at start / end of list but has NULL next "
896 "/ previous pointers.\n");
927 ERRPRINTF(
"Error removing benchmark from bench list.\n");
973 #define SEARCH_FORWARDS 0
974 #define SEARCH_BACKWARDS 1
996 struct pmm_benchmark *first_match, *last_match, *ret_b, *tmp_b;
999 &first_match, &last_match);
1001 if(first_match == NULL) {
1004 else if(last_match == NULL) {
1005 ret_b = first_match;
1010 ret_b = first_match;
1011 tmp_b = first_match->
next;
1018 if(tmp_b == last_match) {
1021 tmp_b = tmp_b->
next;
1052 &first_match, &last_match);
1054 if(first_match == NULL) {
1057 else if(last_match == NULL) {
1065 ret_b->
n_p = first_match->
n_p;
1068 if(ret_b->
p == NULL) {
1069 ERRPRINTF(
"Error copying parameter array.\n");
1152 ERRPRINTF(
"Direction of search not set correctly.\n");
1158 switch (direction) {
1162 if(*first == NULL) {
1209 if(*first == NULL) {
1261 ERRPRINTF(
"Could not find b when searching itself.\n");
1303 ERRPRINTF(
"Could not find b when searching itself!\n");
1327 double divisor = 0.0;
1425 ERRPRINTF(
"Divide by negative unsupported.\n");
1461 dst->tv_sec = src->tv_sec;
1462 dst->tv_usec = src->tv_usec;
1475 return tv->tv_sec + tv->tv_usec/1000000.0;
1488 tv->tv_sec = (int)d;
1489 tv->tv_usec = (int)(100000.0* (d - tv->tv_sec));
1503 ts->tv_sec = (int)d;
1504 ts->tv_nsec = (long)(1000000000.0 * (d - ts->tv_sec));
1517 timeval_add(
struct timeval *tv_a,
struct timeval *tv_b,
struct timeval *tv_res)
1519 tv_res->tv_sec = tv_a->tv_sec + tv_b->tv_sec;
1520 tv_res->tv_usec = tv_a->tv_usec + tv_b->tv_usec;
1521 if(tv_res->tv_usec >= 1000000) {
1523 tv_res->tv_usec -= 1000000;
1566 if (a->tv_sec < b->tv_sec) {
1569 else if (a->tv_sec > b->tv_sec) {
1572 else if (a->tv_usec < b->tv_usec) {
1575 else if (a->tv_usec > b->tv_usec) {
1626 if(b1 == NULL || b2 == NULL) {
1702 if(p_aligned == NULL) {
1703 ERRPRINTF(
"Error copying param array.\n");
1761 double *time_spent,
int *num_execs)
1781 else if(last == NULL) {
1854 DBGPRINTF(
"allocating remove_array of %d elemenets of size %lu.\n",
1855 n,
sizeof(*removed_array));
1857 (*removed_array) = malloc(n *
sizeof *(*removed_array));
1858 if((*removed_array) == NULL) {
1859 ERRPRINTF(
"Error allocating memory.\n");
1866 DBGPRINTF(
"removing %p temporarily\n",
this);
1876 DBGPRINTF(
"saving %p at position %d in removed_array %p\n",
1877 this, c, (*removed_array));
1880 (*removed_array)[c] =
this;
1922 for(i=0; i<n_removed; i++) {
1950 #ifdef ENABLE_OCTAVE
1954 ERRPRINTF(
"Cannot interpolate 2D+ models without octave support "
1983 ERRPRINTF(
"1d interpolation cannot use %dd data.\n", bl->
n_p);
1992 ERRPRINTF(
"Error copying parameter array\n");
2001 if(cur->
p[0] < p[0]) {
2005 else if(cur->
p[0] == p[0]) {
2009 DBGPRINTF(
"benchmark at interpolation point: %f\n", b->
flops);
2012 else if(cur->
p[0] > p[0]) {
2045 m = ((double)(y2-y1))/((
double)(x2-x1));
2047 yb = m*((double)(xb-x1)) + (
double)y1;
2051 DBGPRINTF(
"interploated between %d and %d to %f\n",
2063 DBGPRINTF(
"< than first bench, interpolated to:%f\n", b->
flops);
2084 #define MAX_CMP(x,y) (x) > (y) ? (x) : (y)
2085 #define MIN_CMP(x,y) (x) < (y) ? (x) : (y)
2086 #define PMM_PERC 0.05 // percentage threshold for GBBP
2131 DBGPRINTF(
"b1->flops:%f b2->flops:%f\n", b1->
flops, b2->
flops);
2136 DBGPRINTF(
"max:%f min:%f\n", max, min);
2138 DBGPRINTF(
"max/min %f min/max %f\n", max/min, min/max);
2141 if(max/min <= 1+PMM_PERC && min/max >= 1-
PMM_PERC) {
2142 DBGPRINTF(
"b1 contains b2\n");
2146 DBGPRINTF(
"b1 does not contain b2\n");
2203 DBGPRINTF(
"b1->flops:%f b2->flops:%f\n", b1->
flops, b2->
flops);
2208 DBGPRINTF(
"max:%f min:%f\n", max, min);
2210 DBGPRINTF(
"max/min %f min/max %f\n", max/min, min/max);
2212 if(max/min <= 1+PMM_PERC && min/max >= 1-
PMM_PERC) {
2213 DBGPRINTF(
"b1 intersects b2\n");
2217 DBGPRINTF(
"b1 does not intersects b2\n");
2311 return "naive_bisect";
2317 return "gbbp_naive";
2335 switch (condition) {
2418 ts = localtime(&(m->
mtime));
2419 strftime(mtime_str,
sizeof(mtime_str),
"%a %Y-%m-%d %H:%M:%S %Z", ts);
2420 SWITCHPRINTF(output,
"modified time: %s\n", mtime_str);
2482 for(i=0; i<b->
n_p; i++) {
2561 len = strlen(src) + 1;
2565 *dst = malloc(
sizeof(
char)*len);
2568 ERRPRINTF(
"Allocation of memory to string failed.\n");
2588 time_t t, t2, offset = 0;
2593 ERRPRINTF(
"Error date string is null.\n");
2599 memset(tm_p, 0,
sizeof(
struct tm));
2606 pos = (
char *) strptime((
const char *)date,
2607 (
const char *)
"%t%Y-%m-%dT%H:%M%t",
2616 if (isdigit(pos[0]) && !isdigit(pos[1])) {
2617 tm_t.tm_sec = pos[0] -
'0';
2620 else if (isdigit(pos[0]) && isdigit(pos[1])) {
2621 tm_t.tm_sec = 10*(pos[0]-
'0') + pos[1] -
'0';
2628 else if ((*pos ==
'+' || *pos ==
'-') &&
2629 isdigit(pos[1]) && isdigit(pos[2]) &&
2632 offset = (10*(pos[1] -
'0') + (pos[2] -
'0')) * 60 * 60;
2634 if (pos[3] ==
':' && isdigit(pos[4]) && isdigit(pos[5])) {
2635 offset += (10*(pos[4] -
'0') + (pos[5] -
'0')) * 60;
2637 else if (isdigit(pos[3]) && isdigit(pos[4])) {
2638 offset += (10*(pos[3] -
'0') + (pos[4] -
'0')) * 60;
2641 offset *= (pos[0] ==
'+') ? 1 : -1;
2657 if(t != (time_t)(-1)) {
2660 t2 = mktime(gmtime(&t));
2666 ERRPRINTF(
"Time conversion error: mktime failed.\n");
2669 ERRPRINTF(
"Invalid ISO8601 date format.\n");
2689 ERRPRINTF(
"Number of paramaters for routine not set correctly.\n");
2703 ERRPRINTF(
"Priority for routine not set correctly.\n");
2739 for(i=0; i<cfg->
used; i++) {
2754 if((*cfg)->loadhistory != NULL)
2757 for(i=0; i<(*cfg)->used; i++) {
2761 free((*cfg)->routines);
2762 (*cfg)->routines = NULL;
2775 if((*r)->model != NULL)
2782 if((*r)->exe_args != NULL) {
2783 free((*r)->exe_args);
2784 (*r)->exe_args = NULL;
2787 free((*r)->exe_path);
2788 (*r)->exe_path = NULL;
2791 if((*r)->pd_set != NULL)
2805 if((*m)->bench_list != NULL)
2808 if((*m)->interval_list != NULL)
2811 if((*m)->pd_set != NULL)
2814 free((*m)->model_path);
2815 (*m)->model_path = NULL;
2847 while(
this != NULL) {
2867 while(
this != NULL) {