pmm  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Typedefs | Enumerations | Functions
pmm_model.h File Reference

general PMM data structures More...

#include <sys/time.h>
#include "pmm_interval.h"
#include "pmm_param.h"
#include "pmm_load.h"

Go to the source code of this file.

Data Structures

struct  pmm_config
struct  pmm_benchmark
struct  pmm_bench_list
struct  pmm_model
struct  pmm_routine

Typedefs

typedef enum
pmm_construction_condition 
PMM_Construction_Condition
typedef struct pmm_config PMM_Config
typedef enum
pmm_construction_method 
PMM_Construction_Method
typedef struct pmm_benchmark PMM_Benchmark
typedef struct pmm_bench_list PMM_Bench_List
typedef struct pmm_model PMM_Model
typedef struct pmm_routine PMM_Routine

Enumerations

enum  pmm_construction_condition {
  CC_INVALID, CC_NOW, CC_UNTIL, CC_PERIODIC,
  CC_IDLE, CC_NOUSERS
}
enum  pmm_construction_method {
  CM_NAIVE, CM_NAIVE_BISECT, CM_RAND, CM_GBBP,
  CM_GBBP_NAIVE, CM_INVALID
}

Functions

char * construction_method_to_string (enum pmm_construction_method method)
char * construction_condition_to_string (enum pmm_construction_condition condition)
char * interval_type_to_string (enum pmm_interval_type type)
struct pmm_confignew_config ()
struct pmm_routinenew_routine ()
struct pmm_modelnew_model ()
struct pmm_benchmarknew_benchmark ()
struct pmm_bench_listnew_bench_list (struct pmm_model *m, int n_p)
int init_bench_list (struct pmm_model *m, struct pmm_paramdef_set *pd_set)
struct pmm_benchmarkinit_zero_benchmark (int *params, int n_p)
int isempty_model (struct pmm_model *m)
int add_routine (struct pmm_config *c, struct pmm_routine *r)
int insert_bench (struct pmm_model *m, struct pmm_benchmark *b)
int remove_benchmarks_at_param (struct pmm_model *m, int *p, struct pmm_benchmark ***removed_array)
int copy_benchmark (struct pmm_benchmark *dst, struct pmm_benchmark *src)
void add_bench (struct pmm_benchmark *a, struct pmm_benchmark *b, struct pmm_benchmark *res)
void div_bench (struct pmm_benchmark *b, double d, struct pmm_benchmark *res)
int sum_bench_list (struct pmm_benchmark *start, struct pmm_benchmark *end, struct pmm_benchmark *sum)
void avg_bench_list (struct pmm_benchmark *start, struct pmm_benchmark *end, struct pmm_benchmark *avg_b)
void copy_timeval (struct timeval *src, struct timeval *dst)
double timeval_to_double (struct timeval *tv)
void double_to_timeval (double d, struct timeval *tv)
void double_to_timespec (double d, struct timespec *ts)
void timeval_add (struct timeval *tv_a, struct timeval *tv_b, struct timeval *tv_res)
void timeval_div (struct timeval *tv, double d)
int count_benchmarks_in_model (struct pmm_model *m)
int count_benchmarks_in_bench_list (struct pmm_bench_list *bl)
int count_unique_benchmarks_in_sorted_list (struct pmm_benchmark *first)
int insert_bench_into_sorted_list (struct pmm_benchmark **list_start, struct pmm_benchmark **list_end, struct pmm_benchmark *b)
int insert_bench_into_sorted_list_before (struct pmm_benchmark **list_first, struct pmm_benchmark **list_last, struct pmm_benchmark *before, struct pmm_benchmark *b)
int insert_bench_into_sorted_list_after (struct pmm_benchmark **list_first, struct pmm_benchmark **list_last, struct pmm_benchmark *after, struct pmm_benchmark *b)
int insert_bench_into_list (struct pmm_bench_list *bl, struct pmm_benchmark *b)
int remove_bench_from_sorted_list (struct pmm_benchmark **list_first, struct pmm_benchmark **list_last, struct pmm_benchmark *b)
int remove_bench_from_bench_list (struct pmm_bench_list *bl, struct pmm_benchmark *b)
int benchmark_on_axis (struct pmm_model *m, struct pmm_benchmark *b)
int is_benchmark_at_origin (int n, struct pmm_paramdef *paramdef_array, struct pmm_benchmark *b)
int isequal_benchmarks (struct pmm_benchmark *b1, struct pmm_benchmark *b2)
struct pmm_benchmarkget_avg_aligned_bench (struct pmm_model *m, int *param)
struct pmm_benchmarkget_avg_bench (struct pmm_model *m, int *param)
struct pmm_benchmarkget_avg_bench_from_sorted_bench_list (struct pmm_benchmark *start, int *param)
struct pmm_benchmarkfind_max_bench_in_sorted_bench_list (struct pmm_benchmark *start, int *param)
int search_sorted_bench_list (int direction, struct pmm_benchmark *start, int *param, int n_p, struct pmm_benchmark **first, struct pmm_benchmark **last)
struct pmm_benchmarkget_next_different_bench (struct pmm_benchmark *b)
struct pmm_benchmarkget_previous_different_bench (struct pmm_benchmark *b)
struct pmm_benchmarkget_first_bench (struct pmm_model *m, int *param)
struct pmm_benchmarkget_first_bench_from_bench_list (struct pmm_bench_list *bl, int *p)
void calc_bench_exec_stats (struct pmm_model *m, int *param, double *time_spent, int *num_execs)
double calc_model_stats (struct pmm_model *m)
struct pmm_benchmarkfind_oldapprox (struct pmm_model *m, int *p)
struct pmm_benchmarklookup_model (struct pmm_model *m, int *p)
struct pmm_benchmarkinterpolate_1d_model (struct pmm_bench_list *bl, int *p)
int bench_cut_contains (struct pmm_loadhistory *h, struct pmm_benchmark *b1, struct pmm_benchmark *b2)
int bench_cut_intersects (struct pmm_loadhistory *h, struct pmm_benchmark *b1, struct pmm_benchmark *b2)
int bench_cut_greater (struct pmm_loadhistory *h, struct pmm_benchmark *b1, struct pmm_benchmark *b2)
int bench_cut_less (struct pmm_loadhistory *h, struct pmm_benchmark *b1, struct pmm_benchmark *b2)
void print_routine (const char *output, struct pmm_routine *r)
void print_model (const char *output, struct pmm_model *m)
void print_bench_list (const char *output, struct pmm_bench_list *bl)
void print_benchmark (const char *output, struct pmm_benchmark *b)
int set_str (char **dst, char *src)
time_t parseISO8601Date (char *date)
int check_routine (struct pmm_routine *r)
void print_config (const char *output, struct pmm_config *cfg)
void free_model (struct pmm_model **m)
void free_bench_list (struct pmm_bench_list **bl)
void free_benchmark_list_backwards (struct pmm_benchmark **first_b)
void free_benchmark_list_forwards (struct pmm_benchmark **last_b)
void free_benchmark (struct pmm_benchmark **b)
void free_routine (struct pmm_routine **r)
void free_config (struct pmm_config **cfg)
void free_loadhistory (struct pmm_loadhistory **h)

Detailed Description

general PMM data structures

Data structures representing models, routines and the benchmarking server configuration are described here, along with functions that operate on them.

Definition in file pmm_model.h.

Typedef Documentation

structure describing a list of benchmarks

Benchmarks are doubly linked.

typedef struct pmm_benchmark PMM_Benchmark

Benchmark structure, storing information routine tests.

Details the on the parameters and execution results of a benchmark execution. Also pointers to next/previous benchmarks should the one in question is a member of a list.

typedef struct pmm_config PMM_Config

structure to hold the configuration of the benchmarking server

enumeration fo different model construction conditions that must be satisified to conduct benchmarking

enumeration of different model construction methods

typedef struct pmm_model PMM_Model

functional performance model of a routine

typedef struct pmm_routine PMM_Routine

structure describing a routine to be benchmarked by pmm

Enumeration Type Documentation

enumeration fo different model construction conditions that must be satisified to conduct benchmarking

Enumerator:
CC_INVALID 
CC_NOW 
CC_UNTIL 
CC_PERIODIC 
CC_IDLE 
CC_NOUSERS 

Definition at line 47 of file pmm_model.h.

enumeration of different model construction methods

Enumerator:
CM_NAIVE 

construct by testing every problem size from start to finish

CM_NAIVE_BISECT 

construct by testing every problem size but use bisection of problem size range to get quicker coverage

CM_RAND 

construct using random sampling

CM_GBBP 

construct using optimised Geometric Bisection Building Procedure

CM_GBBP_NAIVE 

construct using GPPB but with a naive initial period

CM_INVALID 

invalid construction method

Definition at line 94 of file pmm_model.h.

Function Documentation

void add_bench ( struct pmm_benchmark a,
struct pmm_benchmark b,
struct pmm_benchmark res 
)

Adds performance data of one benchmark to another (a+b) storing result in res. Parameters added are: flops, seconds, wall_t, used_t.

Parameters
apointer to first benchmark to add
bpointer to second benchmark to add
respointer to benchmark where result of addition is stored
Precondition
all benchmarks are non-NULL
all benchmarks have non-performance data identical (param array, etc).

Definition at line 1391 of file pmm_model.c.

int add_routine ( struct pmm_config c,
struct pmm_routine r 
)

This function adds a pmm_routine structure to the routines array of the pmm_config structure. The array is reallocated as required, adding space for 5 routines at a time to prevent frequent reallocation.

Parameters
cpointer to the config structure
rpointer to the routine
Returns
0 on success, -1 on failure

Definition at line 393 of file pmm_model.c.

void avg_bench_list ( struct pmm_benchmark start,
struct pmm_benchmark end,
struct pmm_benchmark avg_b 
)

Averages the flops and execution times of a sequence of benchmarks and copies this information into a benchmark structure pointed to by b

Parameters
startpointer to the first benchmark in the sequence
endpointer to the last benchmark in the sequence
avg_bpointer to the benchmark where the average is to be stored
Precondition
benchmarks in the sequence defined by start & end are all at the same point, i.e. the values in their p array are identical
b is a non-NULL allocated structure

Definition at line 1324 of file pmm_model.c.

int bench_cut_contains ( struct pmm_loadhistory h,
struct pmm_benchmark b1,
struct pmm_benchmark b2 
)

This function determines if the 'cut' of the model at a specific benchmarked point, b1, contains the range of execution speeds that are defined by the cut of the model at a second benchmark point, b2.

The cut is defined as range of speeds between the maximum and minimum speeds as predicted by the model. If C_b1 contains C_b2, then b1_max > b2_max and b1_min < b2_min. As illustrated by the diagram below.

i.e.

*  |           b1_max
* s|           +               b2_max
* p|        ...|...............+....
* e|   cut@b1- |               | -cut@b2
* e|           |               |
* d|        ...|...............+....
*  |           +               b2_min
*  |           b1_min
* -+------------------------------------------
*  |           ^     size      ^
*              b1              b2
* 
Parameters
hpointer to the load history
b1pointer to first benchmark point
b2pointer to second benchmark point
Returns
1 if the values of the model at b1 contain the values of the model at b2, 0 otherwise

Definition at line 2120 of file pmm_model.c.

int bench_cut_greater ( struct pmm_loadhistory h,
struct pmm_benchmark b1,
struct pmm_benchmark b2 
)

This function determines if the 'cut' of the model at a specific benchmarked point, b1, has no overlap on the range of execution speeds that are defined o by the cut of the model at a second benchmark point, b2. And further, that the cut of b1 lies higher

The cut is defined as range of speeds between the maximum and minimum speeds as predicted by the model. If C_b1 is greater than C_b2, then b1_min > b2_max . As illustrated by the diagram below.

* i.e.
*  |           b1_max
* s|           +
* p|           |
* e|   cut@b1- |
* e|        ...|
* d|           |
*  |           +
*  |           b1_min          b2_max
*  |                     ......+...
*  |                           | -cut@b2
*  |                     ......+...
*  |                           b2_min
* -+------------------------------------------
*  |           ^     size      ^
*              b1              b2
* 
Parameters
hpointer to the load history
b1pointer to first benchmark point
b2pointer to second benchmark point
Returns
1 if the values of the model at b1 are greater than the values of the model at b2, 0 otherwise

Definition at line 2259 of file pmm_model.c.

int bench_cut_intersects ( struct pmm_loadhistory h,
struct pmm_benchmark b1,
struct pmm_benchmark b2 
)

This function determines if the 'cut' of the model at a specific benchmarked point, b1, overlaps the range of execution speeds that are defined by the cut of the model at a second benchmark point, b2.

The cut is defined as range of speeds between the maximum and minimum speeds as predicted by the model. If C_b1 intersects C_b2, then b1_max > b2_max and b1_min < b2_max or, b1_max > b2_min and b1_min < b2_min. As illustrated by the diagram below.

* i.e.
*  |           b1_max
* s|           +
* p|           |
* e|   cut@b1- |               b2_max
* e|        ...|...............+...
* d|           |               | -cut@b2
*  |           +               |
*  |           b1_min     .....+...
*  |                           b2_min
* -+------------------------------------------
*  |           ^     size      ^
*              b1              b2
* 
Parameters
hpointer to the load history
b1pointer to first benchmark point
b2pointer to second benchmark point
Returns
1 if values of model at b1 intersect values of model at b2, 0 otherwise

Definition at line 2194 of file pmm_model.c.

int bench_cut_less ( struct pmm_loadhistory h,
struct pmm_benchmark b1,
struct pmm_benchmark b2 
)

This function performs the inverse of of bench_cut_greater

Parameters
hpointer to the load history
b1pointer to first benchmark point
b2pointer to second benchmark point
Returns
1 if the values of the model at b1 are less than the values of the model at b2, 0 otherwise

Definition at line 2283 of file pmm_model.c.

int benchmark_on_axis ( struct pmm_model m,
struct pmm_benchmark b 
)

Test if a benchmark is on one of the parameter axes of the model (i.e. all but one parameter is at a start),

Parameters
mpointer to the model the benchmark belongs to
bpointer to the benchmark
Returns
the plane index of the axis the benchmark belongs to or -1 if on all boundaries (i.e. at origin), or -2 if on no boundaries

Definition at line 683 of file pmm_model.c.

void calc_bench_exec_stats ( struct pmm_model m,
int *  param,
double *  time_spent,
int *  num_execs 
)

Calculate some statistics about the benchmarking of a particular point in the model, as described by the param parameter array. (Each point stored in a model may have multiple benchmarks, essentially, the sum of the time used by these benchmarks and the number of benchmarks are calculated.

Parameters
mpointer to the model
parampointer to an array of parameter values that
time_spentpointer to double where the time spent is stored
num_execspointer to int where number of executions is stored
Returns
double that is the number of secounds spent benchmarking the point described by param

Definition at line 1760 of file pmm_model.c.

double calc_model_stats ( struct pmm_model m)

Calculate some basic statistics about a model

Parameters
mpointer to the model
Returns
time spend executing benchmarks in model

Definition at line 1806 of file pmm_model.c.

int check_routine ( struct pmm_routine r)

Function checks the routine structure for misconfigurations

Parameters
rpointer to routine
Returns
1 if routine is OK, 0 if routine is BAD

Definition at line 2684 of file pmm_model.c.

char* construction_condition_to_string ( enum pmm_construction_condition  condition)

convert a construction condition enum to a char array description

Parameters
conditionthe construction method
Returns
pointer to a character array describing the condition

Definition at line 2333 of file pmm_model.c.

char* construction_method_to_string ( enum pmm_construction_method  method)

convert a construction method enum to a char array description

Parameters
methodthe construction method
Returns
pointer to a character array describing the method

Definition at line 2305 of file pmm_model.c.

int copy_benchmark ( struct pmm_benchmark dst,
struct pmm_benchmark src 
)

Copy a benchmark from one pointer to another. next and previous elments of the benchmark structure are not copied however. The copy exists outside of any benchmark list that the source might belong to.

Parameters
dstpointer to destination benchmark
srcpointer to source benchmark
Returns
-1 on failure, 0 on success
Precondition
dst structure is non NULL, but it's p array element is NULL

Definition at line 702 of file pmm_model.c.

void copy_timeval ( struct timeval *  dst,
struct timeval *  src 
)

Copies timeval structures

Parameters
dstpointer to the timeval to copy to
srcpointer to the timeval to copy from
Precondition
src and dst are non-NULL

Definition at line 1459 of file pmm_model.c.

int count_benchmarks_in_bench_list ( struct pmm_bench_list bl)

Count the number of benchmarks in a list (this manually counts, does not return the size variable of the list).

Parameters
blpointer to the bench list to count
Returns
number of benchmarks in the list

Definition at line 633 of file pmm_model.c.

int count_benchmarks_in_model ( struct pmm_model m)

count the number of benchmarks in a model

Parameters
mpointer to model
Returns
number of benchmarks

Definition at line 614 of file pmm_model.c.

int count_unique_benchmarks_in_sorted_list ( struct pmm_benchmark first)

Count the number of unique benchmark points in a sorted list of benchmarks.

Parameters
firstpointer the first benchmark in the list
Returns
number of unqiue benchmarks in the list

Definition at line 656 of file pmm_model.c.

void div_bench ( struct pmm_benchmark b,
double  d,
struct pmm_benchmark res 
)

Divides a the performance data fields of a benchmark by some float. Relevant parameters are flops, seconds, wall_t and used_t.

Parameters
bpointer to the benchmark to be divided
dthe devisor as a double
respointer to the location to store the result
Precondition
all benchmarks are non-NULL
divisor is non-zero and positive
all benchmarks have identical non-performance data (param array, etc).

Definition at line 1417 of file pmm_model.c.

void double_to_timespec ( double  d,
struct timespec *  ts 
)

Convert a double to a timespec

Parameters
ddouble value to convert
tspointer to timespec

Definition at line 1501 of file pmm_model.c.

void double_to_timeval ( double  d,
struct timeval *  tv 
)

Converts a double to a timeval

Parameters
ddouble value to convert from
tvpointer to timeval

Definition at line 1486 of file pmm_model.c.

struct pmm_benchmark* find_max_bench_in_sorted_bench_list ( struct pmm_benchmark start,
int *  param 
)
read

Searches a sorted bench list for the fastest instance of a benchmark with matching parameters and returns a pointer to that benchmark

Parameters
startpointer to start bench to commence search
paramthe parameter array to search for
Returns
pointer to the fastest benchmark in the list, in place, or NULL on error
Precondition
start must point to a benchmark that is positioned in the sorted list before, or as the very first instance of a benchmark matching the target parameters, otherwise the max returned may not be correct

Definition at line 992 of file pmm_model.c.

struct pmm_benchmark* find_oldapprox ( struct pmm_model m,
int *  p 
)
read

find_oldapprox will find the approximation of performance at a target point in a model, ignoring any data points that happen to be at that target point. The main use of this function is to find what the approximation of a model was before a data point was added to the model.

Parameters
mpointer to the model
ppointer to a parameter array describing the target point
Returns
a pointer to a newly allocated benchmark that gives an approximation of the model at the target point, ignoring any data at the exact point or NULL on error

Definition at line 1904 of file pmm_model.c.

void free_bench_list ( struct pmm_bench_list **  bl)

frees a benchmark list structure and members it contains

Parameters
blpointer to address of the benchmark list

Definition at line 2826 of file pmm_model.c.

void free_benchmark ( struct pmm_benchmark **  b)

frees a benchmark

Parameters
bpointer to address of the benchmark

Definition at line 2881 of file pmm_model.c.

void free_benchmark_list_backwards ( struct pmm_benchmark **  first_b)

frees a benchmark list structure and members it contains by progressing backwards through the list

Parameters
first_bpointer to address of the benchmark

Definition at line 2862 of file pmm_model.c.

void free_benchmark_list_forwards ( struct pmm_benchmark **  last_b)

frees a benchmark list structure and members it contains by progressing forwards through the list

Parameters
last_bpointer to address of the benchmark

Definition at line 2841 of file pmm_model.c.

void free_config ( struct pmm_config **  cfg)

frees a configure structure and members it contains

Parameters
cfgpointer to address of config structure

Definition at line 2751 of file pmm_model.c.

void free_loadhistory ( struct pmm_loadhistory **  h)

frees a load history structure and all of its members

Parameters
hpointer to address of the load history structure

Definition at line 243 of file pmm_load.c.

void free_model ( struct pmm_model **  m)

frees a model structure and members it contains

Parameters
mpointer to address of the model structure

Definition at line 2803 of file pmm_model.c.

void free_routine ( struct pmm_routine **  r)

frees a routine structure and members it contains

Parameters
rpointer to address of routine structure

Definition at line 2773 of file pmm_model.c.

struct pmm_benchmark* get_avg_aligned_bench ( struct pmm_model m,
int *  param 
)
read

Returns pointer to the a newly allocated benchmark that represents the average of any benchmarks found in the model with parameters matching an aligned version of those described by param, or null if no benchmark exists with matching parameters

Parameters
mpointer to the model
parampointer to the first element of the target parameter array
Returns
pointer to a newly allocated benchmark that is an average of all benchmarks with matching aligned parameters or NULL on error
Precondition
the parameter array has the same size as the number of parameters the model has been built in terms of

Definition at line 1694 of file pmm_model.c.

struct pmm_benchmark* get_avg_bench ( struct pmm_model m,
int *  p 
)
read

Returns pointer to the a newly allocated benchmark that represents the average of any benchmarks found in the model that have the same parameters as those described by param, or null if no benchmark exists with matching parameters

Parameters
mpointer to the model
ppointer to the target parameter array
Returns
pointer to a newly allocated benchmark that is an average of all benchmarks with matching parameters
Precondition
the parameter array has the same size as the number of parameters the model has been built in terms of

Definition at line 1733 of file pmm_model.c.

struct pmm_benchmark* get_avg_bench_from_sorted_bench_list ( struct pmm_benchmark start,
int *  param 
)
read

Searches a sorted bench list for multiple instances of a benchmark with matching parameters and returns a newly allocated benchmark that represents an average of the search hits.

Parameters
startpointer to start bench to commence search
paramthe parameter array to search for
Returns
pointer to a newly allocated benchmark that is an average of any benchmarks found in the boundary model with matching parameters or NULL if no benchmark with matching parameters is found
Precondition
start must point to a benchmark that is positioned in the sorted list before, or as the very first instance of a benchmark matching the target parameters, otherwise the average returned will not be accurate

Definition at line 1046 of file pmm_model.c.

struct pmm_benchmark* get_first_bench ( struct pmm_model m,
int *  p 
)
read

Returns pointer to the first instance of benchmark from the model that has the same parameters as those requested, or null if no benchmark exists with matching parameters

Parameters
mpointer to the model
ppointer to the target parameter array
Returns
pointer to the first instance of a benchmark with parameters matching the param array
Precondition
the parameter array has the same size as the number of parameters the model has been built in terms of

Definition at line 1665 of file pmm_model.c.

struct pmm_benchmark* get_first_bench_from_bench_list ( struct pmm_bench_list bl,
int *  p 
)
read

Searches a benchmark list for the first occurance of a benchmark and returns a pointer to that benchmark or NULL if no benchmark is found

Parameters
blbench list to search
pthe parameter array to search for
Returns
pointer to the first occurance of a benchmark with matching parameters or NULL if no such benchmark is found
Precondition
the number of parameters of the param array and the list model are equal

Definition at line 1596 of file pmm_model.c.

struct pmm_benchmark* get_next_different_bench ( struct pmm_benchmark b)
read

find the next benchmark in a sorted list that does not have identical parameters to b. As models may have more than one benchmark for the same point, looking at the ->next element of a benchmark may give us a second benchmark at the exact same point. Hence the need for this function

Parameters
bpointer to a benchmark that is in a sorted list
Returns
pointer to the next benchmark in the list (that b belongs to), which has a different set of parameters associated with it. This may be null if the benchmark b is the last benchmark in the list

Definition at line 1245 of file pmm_model.c.

struct pmm_benchmark* get_previous_different_bench ( struct pmm_benchmark b)
read

find the previous benchmark in a sorted list that does not have identical parameters to b. As models may have more than one benchmark for the same point, looking at the ->previous element of a benchmark may give us a second benchmark at the exact same point. Hence the need for this function

Parameters
bpointer to a benchmark that is in a sorted list
Returns
pointer to the previous benchmark in the list (that b belongs to), which has a different set of parameters associated with it. This may be NULL if the benchmark b is the first benchmark in the list.

Definition at line 1288 of file pmm_model.c.

int init_bench_list ( struct pmm_model m,
struct pmm_paramdef_set pd_set 
)

Initialise the model benchmark list with zero speed benchmarks at relevant points. For each parameter definition if the end value of a parameter is defined as having a zero speed (i.e. it is not a 'nonzero_end'), then create zero speed benchmarks at the end point on that parameter axis, i.e. for parameter i create a zero speed benchmark at at:

start_0,start_1,...,end_i,...,start_n-1,start_n.

The, if any parameter has a zero speed end defined, assume we cannot ever benchmark at end_0,end_1,...,end_n and set a zero speed benchmark at this point also.

Parameters
mpointer to the model that the bench list belongs to
pd_setpointer to the parameter definition set of the model
Returns
0 on success, -1 on failure

Definition at line 207 of file pmm_model.c.

struct pmm_benchmark* init_zero_benchmark ( int *  params,
int  n_p 
)
read

Initialize and return a benchmark structure with zero speed in a position described by the parameter array argument (params).

Parameters
paramspointer to parameter array describing benchmark position
n_pnumber of parameters
Returns
pointer to a newly allocated benchmark structure with zero speed in given position

Definition at line 356 of file pmm_model.c.

int insert_bench ( struct pmm_model m,
struct pmm_benchmark b 
)

Add benchmark to a model in the appropriate substructure of the model

Parameters
mpointer to the model
bpointer to the benchmark
Postcondition
parameter b becomes part of the model and must not be freed until the model itself is freed or it is removed from the model explicitly
Returns
0 on success, -1 on failure

Definition at line 521 of file pmm_model.c.

int insert_bench_into_list ( struct pmm_bench_list bl,
struct pmm_benchmark b 
)
Returns
0 on success, -1 on failure

Definition at line 485 of file pmm_model.c.

int insert_bench_into_sorted_list ( struct pmm_benchmark **  list_start,
struct pmm_benchmark **  list_end,
struct pmm_benchmark b 
)

Insert benchmark between two benchmarks in a sorted list

Parameters
list_startpointer to a reference for the beginning of the list
list_endpointer to a reference for the end of the list
bpointer to the benchmark to insert
Returns
0 on success if benchmark was not unique to the list, 1 on success if the benchmark was unique to the list, -1 on failure

Definition at line 434 of file pmm_model.c.

int insert_bench_into_sorted_list_after ( struct pmm_benchmark **  list_first,
struct pmm_benchmark **  list_last,
struct pmm_benchmark after,
struct pmm_benchmark b 
)

Insert benchmark into a sorted list in a position directly after a certain benchmark.

Parameters
list_firstpointer to the first benchmark in the list
list_lastpointer to the last benchmark in the list
afterpointer to the benchmark after which we will insert
bpointer to the benchmark we will insert
Precondition
the benchmark b has parameter value higher than the benchmark 'after'
after is NULL pointer only if list is empty
Returns
0 on success, -1 on failure

Definition at line 797 of file pmm_model.c.

int insert_bench_into_sorted_list_before ( struct pmm_benchmark **  list_first,
struct pmm_benchmark **  list_last,
struct pmm_benchmark before,
struct pmm_benchmark b 
)

Insert benchmark into a sorted list in a position directly before a certain benchmark.

Parameters
list_firstpointer to the first benchmark in the list
list_lastpointer to the last benchmark in the list
beforepointer to the benchmark before which we will insert
bpointer to the benchmark we will insert
Precondition
the benchmark b has parameter value lower than the benchmark 'before'
after is NULL pointer only if list is empty
Returns
0 on success, -1 on failure

Definition at line 743 of file pmm_model.c.

struct pmm_benchmark* interpolate_1d_model ( struct pmm_bench_list bl,
int *  p 
)
read

Find the speed approximation given by a 1-D or single parameter model at a point described by the parameter array p (size of 1!).

Parameters
blpointer to the bench list
ppointer to parameter array
Returns
pointer to a newly allocated benchmark structure which describes the flops performance at the point p.

TODO this does not use the average of benchmarks with the same parameters

Definition at line 1977 of file pmm_model.c.

char* interval_type_to_string ( enum pmm_interval_type  type)

map interval type to string for printing

Parameters
typeinterval type
Returns
char string describing interval

Definition at line 400 of file pmm_interval.c.

int is_benchmark_at_origin ( int  n,
struct pmm_paramdef pd_array,
struct pmm_benchmark b 
)

test if a benchmark is at the starting point of a model (not 0,0)

Parameters
nnumber of parameters defintions
pd_arraypointer to parameter defintions array
bpointer to benchmark
Returns
0 if benchmark is not at the origin of the model (all start values)
1 if benchmark is at the origin of the model
-1 if there is a mismatch between number of parameters

Definition at line 547 of file pmm_model.c.

int isempty_model ( struct pmm_model m)

An empty model is defined as one that has no experimentally obtained benchmark points in it. Thus:

The bench list may only have: points at the end parameter values on each parameter axis, e.g. [0,0,end] for the 3rd axis of a 3 parameter model, and a single point at the end parameter value of all boundaries, i.e. [end,end,end] of a 3 parameter model

This is slightly complicated to test however, another property of non- experimental points in the model is that they all have zero speed. Just test that!

Parameters
mpointer to the model to test
Returns
0 if model is not empty, 1 if model is empty

Definition at line 586 of file pmm_model.c.

int isequal_benchmarks ( struct pmm_benchmark b1,
struct pmm_benchmark b2 
)

test if the data elements of benchmarks are equal (i.e. everything but the pointers)

Parameters
b1pointer to first benchmark
b2pointer to second benchmark
Returns
0 if benchmarks are not equal, 1 if benchmarks are equal

Definition at line 1624 of file pmm_model.c.

struct pmm_benchmark* lookup_model ( struct pmm_model m,
int *  p 
)
read

Call the appropriate lookup function to find value of model given a set of parameters

Parameters
mpointer to model
parray of parameters
Returns
newly allocated benchmark describing performance at p or NULL on failure

Definition at line 1940 of file pmm_model.c.

struct pmm_bench_list* new_bench_list ( struct pmm_model m,
int  n_p 
)
read

Create an empty benchmark list

Parameters
mpointer to the parent model
n_pnumber of parameters of the benchmarks in the list
Returns
pointer to newly allocated pmm_bench_list

Definition at line 167 of file pmm_model.c.

struct pmm_benchmark* new_benchmark ( )
read

Allocate and return a benchmark structure with values set to invalids, with the parameter array p still unallocated and next/previous pointers set to NULL

Returns
pointer to a newly allocated benchmark structure

Definition at line 320 of file pmm_model.c.

struct pmm_config* new_config ( )
read

Allocates memory for the pmm_config structure. Sets some default values in the config.

Returns
pointer to newly allocated pmm_config structure or NULL on failure

Definition at line 58 of file pmm_model.c.

struct pmm_model* new_model ( )
read

Create a new model structure. Note pmm_bench_list member will not yet be allocated.

Returns
pointer to newly allocated pmm_model structure

Definition at line 132 of file pmm_model.c.

struct pmm_routine* new_routine ( )
read

Allocates memory for a new routine and sets some default values

Returns
pointer to newly allocated routine structure

Definition at line 98 of file pmm_model.c.

time_t parseISO8601Date ( char *  date)

converts a ISO 8601 time string to a time_t value

Parameters
datepointer to charater string representing a date
Returns
date converted to a time_t value

Definition at line 2585 of file pmm_model.c.

void print_bench_list ( const char *  output,
struct pmm_bench_list bl 
)

Print a pmm_bench_list structure to the log

Parameters
outputoutput stream to print two
blpointer to the pmm_bench_list structure

Definition at line 2447 of file pmm_model.c.

void print_benchmark ( const char *  output,
struct pmm_benchmark b 
)

print a benchmark

Parameters
outputoutput stream to print to
bpointer to benchmark

Definition at line 2478 of file pmm_model.c.

void print_config ( const char *  output,
struct pmm_config cfg 
)

prints the elements of the pmm_config structure for debugging

Parameters
outputpointer to output stream
cfgpointer to config structure

Definition at line 2717 of file pmm_model.c.

void print_model ( const char *  output,
struct pmm_model m 
)

prints the linked list of benchmark points in a pmm_model

Parameters
outputoutput stream to print to
mmodel to print

Definition at line 2410 of file pmm_model.c.

void print_routine ( const char *  output,
struct pmm_routine r 
)

prints the elements of a pmm_routine structure

Parameters
outputoutput stream to print to
rpointer to routine

Definition at line 2506 of file pmm_model.c.

int remove_bench_from_bench_list ( struct pmm_bench_list bl,
struct pmm_benchmark b 
)

Remove a benchmark from a bench list

Parameters
blpointer to the bench list
bpointer to the benchmark to remove from the model
Returns
0 on success, -1 on failure
Precondition
b is part of the bench list
Postcondition
b is removed from the list but still allocated (having next/previous pointers set to NULL

Definition at line 922 of file pmm_model.c.

int remove_bench_from_sorted_list ( struct pmm_benchmark **  list_first,
struct pmm_benchmark **  list_last,
struct pmm_benchmark b 
)

Remove a benchmark from a sorted benchmark list

Parameters
list_firstpointer to the first bench in the list
list_lastpointer to the last bench in the list
bpointer to the benchmark to remove from the list
Returns
0 on success, -1 on failure
Precondition
b is part of the list
Postcondition
b is removed from the list but still allocated (having next/previous pointers set to NULL

Definition at line 849 of file pmm_model.c.

int remove_benchmarks_at_param ( struct pmm_model m,
int *  p,
struct pmm_benchmark ***  removed_array 
)

Function removes benchmarks from a model that have parameters that match a target set. Removed benchmarks are all not deallocated, their addresses are stored in an array passed to the function as removed_array

Parameters
mpointer to the model
ppointer to an array of parameters
removed_arraypointer to unallocated array of benchmarks
Returns
the number of benchmarks found and removed from the model or -1 on error
Precondition
removed_array is unallocated
Postcondition
removed_array is allocated with a size matching the number of benchmarks found and removed

Definition at line 1840 of file pmm_model.c.

int search_sorted_bench_list ( int  direction,
struct pmm_benchmark start,
int *  param,
int  n_p,
struct pmm_benchmark **  first,
struct pmm_benchmark **  last 
)

Finds the first and last positions of a sequence of benchmarks with matching parameters that are part of a sorted benchmark list, search from start

Parameters
directionuse SEARCH_[BACK|FOR]WARDS macros
startpointer to search start point in the list
parampointer to array of parameters to search for
n_pthe number of parameters in the param array
firstpointer to first matching bench in the model
lastpointer to last matching bench in the model
Returns
number of benchmarks found or <0 on error
Precondition
parameter array param has the same number of parameters as the benchmarks in the list and the list is sorted properly
benchmark list mst be sorted
Postcondition
first and last are NULL if no matching benchmark is found, first is non-NULL and last is NULL if only one matching benchmark is found, finally first and last are non-NULL if a sequence of matching benchmarks are found. They do not depend on the search direction, i.e. first and last are not reordered if the search direction is reversed, they will always be presented in the order that occurs in the model.

Definition at line 1137 of file pmm_model.c.

int set_str ( char **  dst,
char *  src 
)

function is used to set string variables of the pmm_routine structure and other string variables. Takes a pointer to the destination char* and the source char* and then allocates enough memory to copy the source into the destination.

Parameters
dstpointer to location fo destination string
srcpointer to string to set
Returns
0 on failure, 1 on success

Definition at line 2546 of file pmm_model.c.

int sum_bench_list ( struct pmm_benchmark start,
struct pmm_benchmark end,
struct pmm_benchmark sum 
)

Summates the data of benchmarks in a list marked by start and end into an empty benchmark sum

Parameters
startpointer to the first benchmark in the list of benchmarks to be summed
endpointer to the last benchmark in thet list of benchmarks to be summed
sumpointer to the benchmark where the summed data is to be stored
Returns
the number of benchmarks added to the sum as an integer
Precondition
all benchmarks are allocated and non NULL. sum is initialized with zero data values

Definition at line 1355 of file pmm_model.c.

void timeval_add ( struct timeval *  tv_a,
struct timeval *  tv_b,
struct timeval *  tv_res 
)

Add two timevals, to another, tv_res = tv_a + tv_b

Parameters
tv_afirst timeval to add
tv_bsecond timeval to add
tv_respointer to timeval to store result

Definition at line 1517 of file pmm_model.c.

void timeval_div ( struct timeval *  tv,
double  d 
)

Divide timeval by a double

Parameters
tvthe timeval
dthe divisor as a double
Precondition
divisor should be non zero

Definition at line 1538 of file pmm_model.c.

double timeval_to_double ( struct timeval *  tv)

Converts timeval to a double in seconds units

Parameters
tvpointer to a timeval structure
Returns
value of the timeval in seconds as a double

Definition at line 1473 of file pmm_model.c.