Cyclops Tensor Framework
parallel arithmetic on multidimensional arrays
model.h
Go to the documentation of this file.
1 #ifndef __MODEL_H__
2 #define __MODEL_H__
3 
4 #include <mpi.h>
5 #include "init_models.h"
6 
7 #include <fstream>
8 #include <sstream>
9 
10 
11 namespace CTF_int {
12  class Model {
13  public:
14  virtual void update(MPI_Comm cm){};
15  virtual void print(){};
16  virtual void print_uo(){};
17  virtual void load_coeff(std::string file_name){};
18  virtual void write_coeff(std::string file_name){};
19  virtual void dump_data(std::string path){};
20  };
21 
22  void update_all_models(MPI_Comm cm);
23  void print_all_models();
24  void load_all_models(std::string file_name);
25  void write_all_models(std::string file_name);
27 
31  template <int nparam>
32  class LinModel : Model {
33  private:
35  int64_t nobs;
38  int mat_lda;
40  bool is_tuned;
42  double tot_time;
44  double over_time;
46  double under_time;
48  double avg_tot_time;
50  double avg_over_time;
52  double avg_under_time;
54  bool is_active;
55 
56  public:
58  int hist_size;
62  double * time_param_mat;
64  double coeff_guess[nparam];
65 
66  //double regularization[nparam];
67 
69  char * name;
70 
77  LinModel(double const * init_guess, char const * name, int hist_size=32768);
78 
79  LinModel();
80  ~LinModel();
81 
86  void update(MPI_Comm cm);
87 
92  void observe(double const * time_param);
93 
98  bool should_observe(double const * time_param);
99 
105  double est_time(double const * param);
106 
110  void print();
111 
115  void print_uo();
116 
120  double* get_coeff();
121 
126  void load_coeff(std::string file_name);
127 
132  void write_coeff(std::string file_name);
133 
137  void dump_data(std::string path);
138  };
139 
143  template <int nparam>
144  class CubicModel : Model {
145  private:
146  LinModel<nparam*(nparam+1)*(nparam+2)/6+nparam*(nparam+1)/2+nparam> lmdl;
147 
148  public:
155  CubicModel(double const * init_guess, char const * name, int hist_size=8192);
156 
157  ~CubicModel();
158 
163  void update(MPI_Comm cm);
164 
169  void observe(double const * time_param);
170 
175  bool should_observe(double const * time_param);
176 
182  double est_time(double const * param);
183 
187  void print();
188 
192  void print_uo();
193 
197  double* get_coeff();
198 
203  void load_coeff(std::string file_name);
204 
209  void write_coeff(std::string file_name);
210 
215  void dump_data(std::string path);
216 
217  };
218 
219 }
220 
221 #endif
virtual void write_coeff(std::string file_name)
Definition: model.h:18
void load_all_models(std::string file_name)
Definition: model.cxx:34
char * name
name of model
Definition: model.h:69
void update_all_models(MPI_Comm comm)
Definition: model.cxx:15
virtual void load_coeff(std::string file_name)
Definition: model.h:17
void write_all_models(std::string file_name)
Definition: model.cxx:42
virtual void print_uo()
Definition: model.h:16
string
Definition: core.pyx:456
void print_all_models()
Definition: model.cxx:23
Cubic performance models, which given measurements, provides new model guess.
Definition: model.h:144
virtual void dump_data(std::string path)
Definition: model.h:19
virtual void print()
Definition: model.h:15
virtual void update(MPI_Comm cm)
Definition: model.h:14
Linear performance models, which given measurements, provides new model guess.
Definition: model.h:32
void dump_all_models(std::string path)
Definition: model.cxx:50
Definition: apsp.cxx:11
double * time_param_mat
matrix containing parameter/time obervations, with hist_size columns and nmat_lda rows...
Definition: model.h:62
int hist_size
the number of latest observations we want to consider when updating the model
Definition: model.h:58