pmm  1.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
pmm_param.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008-2010 Robert Higgins
3  Author: Robert Higgins <robert.higgins@ucd.ie>
4 
5  This file is part of PMM.
6 
7  PMM is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  PMM is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with PMM. If not, see <http://www.gnu.org/licenses/>.
19 */
20 /*!
21  * @file pmm_param.h
22  * @brief data structures for model/benchmark parameters
23  *
24  */
25 #ifndef PMM_PARAM_H_
26 #define PMM_PARAM_H_
27 
28 #if HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31 
32 #ifdef HAVE_MUPARSER
33 //#include "pmm_muparse.h"
34 #endif
35 
36 #ifdef HAVE_MUPARSER
37 struct pmm_param_constraint_muparser; //< forward declaration
38 #endif
39 /*!
40  * Structure defining a parameter of a routine
41  */
42 typedef struct pmm_paramdef {
43  /*
44  * TODO allow definition of a mathematical sequence to govern permissable
45  * parameters. At present stride and offset allow a sequence equvilent
46  * to: a*x + b where a = stride and b = offset
47  */
48  char *name; /*!< name of parameter */
49  int type; /*!< */
50  int order; /*!< order in the sequence of parameters passed to
51  benchmarking routine */
52  int nonzero_end; /*!< toggle assumtion of zero speed at parameter end
53  value */
54  int end; /*!< ending value of parameter range */
55  int start; /*!< starting value of parameter range */
56  int stride; /*!< stride to use traversing parameter range */
57  int offset; /*!< offset from starting value to use traversing
58  parameter range */
59 } PMM_Paramdef;
60 
61 /*!
62  * structure describing a set of parameters and a formula in terms of
63  * those parameters which may be constrained (i.e. parameters a, b, formula:a*b,
64  * constraint on formula < 1000)
65  */
66 typedef struct pmm_paramdef_set {
67  int n_p; /*!< number of parameters in set */
68  struct pmm_paramdef *pd_array; /*!< array of parameter definitions */
69  char *pc_formula; /*!< formula for parameter constraint */
70  int pc_max; /*!< max of parameter constraint */
71  int pc_min; /*< min of parameter constraint */
72 
73 #ifdef HAVE_MUPARSER
74  struct pmm_param_constraint_muparser *pc_parser; /*!< muparser structure
75  used for parameter
76  constraint */
77 #endif
78 
80 
81 struct pmm_paramdef_set*
83 
84 int*
86 int*
88 
89 void
90 set_param_array_start(int *p, struct pmm_paramdef_set *pds);
91 void
92 set_param_array_end(int *p, struct pmm_paramdef_set *pds);
93 
94 int
95 copy_paramdef(struct pmm_paramdef *dst, struct pmm_paramdef *src);
96 
97 int*
98 init_param_array_copy(int *src, int n);
99 void
100 set_param_array_copy(int *dst, int *src, int n);
101 
102 int params_cmp(int *p1, int *p2, int n);
103 
104 void
105 align_params(int *params, struct pmm_paramdef_set *pd_set);
106 int
107 align_param(int param, struct pmm_paramdef *pd);
108 int*
109 init_aligned_params(int *p, struct pmm_paramdef_set *pd_set);
110 
111 int
112 param_on_axis(int *p,
113  int n,
114  struct pmm_paramdef *pd_array);
115 
116 int
117 params_within_paramdefs(int *p, int n, struct pmm_paramdef *pd_array);
118 int
120 
121 int
123  struct pmm_paramdef_set *pds_b);
124 int
125 isequal_paramdef_array(struct pmm_paramdef *pd_array_a,
126  struct pmm_paramdef *pd_array_b, int n_p);
127 int
128 isequal_paramdef(struct pmm_paramdef *a, struct pmm_paramdef *b);
129 
130 int
131 set_params_step_between_params(int *params, int *start, int *end,
132  int step, struct pmm_paramdef_set *pd_set);
133 
134 void print_params(const char *output, int *p, int n);
135 void print_paramdef_set(const char *output, struct pmm_paramdef_set *pd_set);
136 void print_paramdef_array(const char *output, struct pmm_paramdef *pd_array, int n);
137 void print_paramdef(const char *output, struct pmm_paramdef *pd);
138 
139 void free_paramdef_set(struct pmm_paramdef_set **pd_set);
140 void free_paramdef_array(struct pmm_paramdef **pd_array, int n_p);
141 
142 #endif /*PMM_PARAM_H_*/
143