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

data structures for model/benchmark parameters More...

Go to the source code of this file.

Data Structures

struct  pmm_paramdef
struct  pmm_paramdef_set

Typedefs

typedef struct pmm_paramdef PMM_Paramdef
typedef struct pmm_paramdef_set PMM_Paramdef_Set

Functions

struct pmm_paramdef_setnew_paramdef_set ()
int * init_param_array_start (struct pmm_paramdef_set *pds)
int * init_param_array_end (struct pmm_paramdef_set *pds)
void set_param_array_start (int *p, struct pmm_paramdef_set *pds)
void set_param_array_end (int *p, struct pmm_paramdef_set *pds)
int copy_paramdef (struct pmm_paramdef *dst, struct pmm_paramdef *src)
int * init_param_array_copy (int *src, int n)
void set_param_array_copy (int *dst, int *src, int n)
int params_cmp (int *p1, int *p2, int n)
void align_params (int *params, struct pmm_paramdef_set *pd_set)
int align_param (int param, struct pmm_paramdef *pd)
int * init_aligned_params (int *p, struct pmm_paramdef_set *pd_set)
int param_on_axis (int *p, int n, struct pmm_paramdef *pd_array)
int params_within_paramdefs (int *p, int n, struct pmm_paramdef *pd_array)
int param_within_paramdef (int p, struct pmm_paramdef *pd_array)
int isequal_paramdef_set (struct pmm_paramdef_set *pds_a, struct pmm_paramdef_set *pds_b)
int isequal_paramdef_array (struct pmm_paramdef *pd_array_a, struct pmm_paramdef *pd_array_b, int n_p)
int isequal_paramdef (struct pmm_paramdef *a, struct pmm_paramdef *b)
int set_params_step_between_params (int *params, int *start, int *end, int step, struct pmm_paramdef_set *pd_set)
void print_params (const char *output, int *p, int n)
void print_paramdef_set (const char *output, struct pmm_paramdef_set *pd_set)
void print_paramdef_array (const char *output, struct pmm_paramdef *pd_array, int n)
void print_paramdef (const char *output, struct pmm_paramdef *pd)
void free_paramdef_set (struct pmm_paramdef_set **pd_set)
void free_paramdef_array (struct pmm_paramdef **pd_array, int n_p)

Detailed Description

data structures for model/benchmark parameters

Definition in file pmm_param.h.

Typedef Documentation

typedef struct pmm_paramdef PMM_Paramdef

Structure defining a parameter of a routine

structure describing a set of parameters and a formula in terms of those parameters which may be constrained (i.e. parameters a, b, formula:a*b, constraint on formula < 1000)

Function Documentation

int align_param ( int  param,
struct pmm_paramdef pd 
)

Align a parameter according to stride and offset defined in corresponding paramdef.

Parameters
paramthe value of the parameter we are aligning
pdthe corresponding parameter definition
Returns
the aligned parameter
Postcondition
the return value is aligned as closely as possible to the passed param. In cases where the aligned parameter is greater than the end, the parameter is decremented by the stride until it is within the end bound. If nonzero en is set, the end point is considered a valid point and the parameter is aligned to this, regardless if it is within the stride & offset describing the parameter sequence. If the aligned parameter is less than the start it is set to the start value, regardless of whether this is within the stride & offset describing the parameter sequence.

Definition at line 351 of file pmm_param.c.

void align_params ( int *  params,
struct pmm_paramdef_set pd_set 
)

align an array of parameters

Parameters
[in,out]paramspointer to the array of parameters to align
[in]pd_setpointer to the corresponding parameter definition array

Definition at line 441 of file pmm_param.c.

int copy_paramdef ( struct pmm_paramdef dst,
struct pmm_paramdef src 
)

Copy a parameter definition structure from src to dst

Parameters
srcpointer to the paramdef to copy
dstpointer to the paramdef to copy into
Returns
0 on success, -1 on failure
Precondition
src and dst point to allocated structures

Definition at line 215 of file pmm_param.c.

void free_paramdef_array ( struct pmm_paramdef **  pd_array,
int  n_p 
)

frees a parameter definition array

Parameters
pd_arraypointer to address of parameter definition array
n_pnumber of parameter definitions in array

Definition at line 893 of file pmm_param.c.

void free_paramdef_set ( struct pmm_paramdef_set **  pd_set)

frees a parameter definition set structure and members it contains

Parameters
pd_setpointer to address of parameter definition structure

Definition at line 873 of file pmm_param.c.

int* init_aligned_params ( int *  p,
struct pmm_paramdef_set pd_set 
)

initialized a set of align a set of parameters based on a set of unaligned parameters and parameter definitions

Parameters
ppointer to unaligned parameter array
pd_setpointer to corresponding parameter definitions
Returns
allocated array of aligned parameters or NULL on failure

Definition at line 465 of file pmm_param.c.

int* init_param_array_copy ( int *  src,
int  n 
)

Copy a parameter array into a newly allocated parameter array

Parameters
srcpointer to the first element of the source parameter array
nnumber of parameters in the source parameter array
Returns
pointer to copied parameter array or NULL on failure

Definition at line 164 of file pmm_param.c.

int* init_param_array_end ( struct pmm_paramdef_set pd_set)

Initialise a parameter array to all end values, as descripted by the parameter definitions

Parameters
pd_setpointer to parameter definition set structure
Returns
pointer to an array of parameters with all end values of size n

Definition at line 94 of file pmm_param.c.

int* init_param_array_start ( struct pmm_paramdef_set pd_set)

Initialise a parameter array to all start values, as descripted by the parameter definitions

Parameters
pd_setpointer to parameter definition set
Returns
pointer to an array of parameters with all start values of size n

Definition at line 70 of file pmm_param.c.

int isequal_paramdef ( struct pmm_paramdef a,
struct pmm_paramdef b 
)

Check if two parameter definitions are identical

Parameters
apointer to first parameter definition
bpointer to second parameter definition
Returns
0 if not identical, 1 if identical

Definition at line 552 of file pmm_param.c.

int isequal_paramdef_array ( struct pmm_paramdef pd_array_a,
struct pmm_paramdef pd_array_b,
int  n_p 
)

Check if two parameter definition arrays are equal.

Parameters
pd_array_apointer to first parameter array
pd_array_bpointer to second parameter array
n_pnumber of parameters in the array
Returns
0 if arrays contain different parameter definitions, 1 if they are identical

Definition at line 529 of file pmm_param.c.

int isequal_paramdef_set ( struct pmm_paramdef_set pds_a,
struct pmm_paramdef_set pds_b 
)

Check if two parameter definition sets are identical

Parameters
pds_apointer to first parameter definition set
pds_bpointer to second parameter definition set
Returns
0 if not identical, 1 if identical

Definition at line 489 of file pmm_param.c.

struct pmm_paramdef_set* new_paramdef_set ( )
read

Create an empty parameter definition set structure. Note pd_array will not yet be allocated

Returns
pointer to newly allocated structure

Definition at line 46 of file pmm_param.c.

int param_on_axis ( int *  p,
int  n,
struct pmm_paramdef pd_array 
)

Test if a set of parameters lies on one of the parameter axes of the model, i.e. all but one parameter is at a start or all parameters are start (i.e. at the origin).

Parameters
ppointer to the parameter array
nnumber of elements in the parameter array
pd_arraypointer to the parameter defintions array
Returns
the plane index of the parameter axis the benchmark belongs to or -1 if on all axes (i.e. at origin), or -2 if on no boundaries

Definition at line 246 of file pmm_param.c.

int param_within_paramdef ( int  p,
struct pmm_paramdef pd 
)

Test if a single parameter is within the limits defined by a parameter definition

Parameters
pthe parameter
pdpointer to the parameter definition
Returns
1 if parameter is within the parameter space defined by the parameter defintion. I.e. it is between the start and end points

Definition at line 316 of file pmm_param.c.

int params_cmp ( int *  p1,
int *  p2,
int  n 
)

Compare two parameter arrays in terms of their elements. Arrays are equal if all elements are equal, otherwise the most significant non-equal element determines which is greater.

Parameters
p1pointer to first element of array 1
p2pointer to first element of array 2
nnumber of elements in arrays
Returns
>0 if array p1 is 'greater' than p2, <0 if p1 is 'less' than 'p2' or 0 of p1 is equal to p2.
Precondition
arrays must be of the same length and not NULL

Definition at line 586 of file pmm_param.c.

int params_within_paramdefs ( int *  p,
int  n,
struct pmm_paramdef pd_array 
)

Test if a set of parameters is within the limits defined by the parameter definitions or outside them

Parameters
ppointer to parameter array
nnumber of parameters
pd_arraypointer to parameter definition array
Returns
1 if parameter p is within the parameter space defined by the parameter definitions, 0 if it is not

Definition at line 291 of file pmm_param.c.

void print_paramdef ( const char *  output,
struct pmm_paramdef pd 
)

print a parameter definition

Parameters
outputoutput stream to print to
pdpointer to parameter definition

Definition at line 830 of file pmm_param.c.

void print_paramdef_array ( const char *  output,
struct pmm_paramdef pd_array,
int  n 
)

print a parameter definition array

Parameters
outputoutput stream to print to
pd_arraypointer to parameter definition array
nnumber of elements in array

Definition at line 813 of file pmm_param.c.

void print_paramdef_set ( const char *  output,
struct pmm_paramdef_set pd_set 
)

print a parameter definition set

Parameters
outputoutput stream to print to
pd_setpointer to parameter definition set

Definition at line 852 of file pmm_param.c.

void print_params ( const char *  output,
int *  p,
int  n 
)

Print a parameter array

Parameters
outputoutput stream to print to
ppointer to the parameter array
nsize of the parameter array

Definition at line 796 of file pmm_param.c.

void set_param_array_copy ( int *  dst,
int *  src,
int  n 
)

Copy from one parameter array to another

Parameters
dstpointer to the destination array
srcpointer tot the source array
nnumber of elements in each array
Returns
0 on success, -1 on failure
Precondition
src and dst arrays are of the same size (n)

Definition at line 193 of file pmm_param.c.

void set_param_array_end ( int *  p,
struct pmm_paramdef_set pd_set 
)

Set a parameter array to all end values, as described by the parameter definitions

Parameters
ppointer to an array of parameters
pd_setpointer to parameter definitions set structure
Precondition
p must be a pointer to allocated memory, the number of elements in the p array must be identical to the number of parameter definitions

Definition at line 142 of file pmm_param.c.

void set_param_array_start ( int *  p,
struct pmm_paramdef_set pd_set 
)

Set a parameter array to all start values, as described by the parameter definitions

Parameters
ppointer to an array of parameters
pd_setpointer to parameter definitions set structure
Precondition
p must be a pointer to allocated memory, the number of elements in the p array must be identical to the number of parameter definitions

Definition at line 120 of file pmm_param.c.

int set_params_step_between_params ( int *  params,
int *  start,
int *  end,
int  step,
struct pmm_paramdef_set pd_set 
)

Step between two points, according to a minimum step size defined in the parameter definitions.

Parameters
paramspointer to an array to store the parameters at the n-th step between the start and end points
startpointer to array describing the start point
endpointer to array describing the start point
stepnumber of steps to take along the interval (- to step backwards, + to step forwards)
pd_setpointer to the parameter definition set
Returns
0 on success, -1 if the step will exceed the end-point of the interval or -2 on error

Definition at line 623 of file pmm_param.c.