StarPU Handbook
starpu_perfmodel.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2011-2013 Inria
4  * Copyright (C) 2009-2018 Université de Bordeaux
5  * Copyright (C) 2010-2017 CNRS
6  * Copyright (C) 2013 Thibaut Lambert
7  * Copyright (C) 2011 Télécom-SudParis
8  *
9  * StarPU is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or (at
12  * your option) any later version.
13  *
14  * StarPU is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17  *
18  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
19  */
20 
21 #ifndef __STARPU_PERFMODEL_H__
22 #define __STARPU_PERFMODEL_H__
23 
24 #include <starpu.h>
25 #include <stdio.h>
26 
27 #include <starpu_util.h>
28 #include <starpu_worker.h>
29 
30 #ifdef __cplusplus
31 extern "C"
32 {
33 #endif
34 
35 struct starpu_task;
36 struct starpu_data_descr;
37 
38 #define STARPU_NARCH STARPU_ANY_WORKER
39 
41 {
43  int devid;
44  int ncores;
45 };
46 
48 {
49  int ndevices;
51 };
52 
53 
55 {
56  double mean;
57  double deviation;
58  double sum;
59  double sum2;
60  unsigned nsample;
61  unsigned nerror;
62  uint32_t footprint;
63  size_t size;
64  double flops;
65 };
66 
68 {
71 };
72 
74 {
75  double sumlny;
76 
77  double sumlnx;
78  double sumlnx2;
79 
80  unsigned long minx;
81  unsigned long maxx;
82 
83  double sumlnxlny;
84 
85  double alpha;
86  double beta;
87  unsigned valid;
88 
89  double a, b, c;
90  unsigned nl_valid;
91 
92  unsigned nsample;
93 };
94 
95 struct starpu_perfmodel_history_table;
96 
97 #define starpu_per_arch_perfmodel starpu_perfmodel_per_arch STARPU_DEPRECATED
98 
99 typedef double (*starpu_perfmodel_per_arch_cost_function)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
100 typedef size_t (*starpu_perfmodel_per_arch_size_base)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
101 
103 {
104  starpu_perfmodel_per_arch_cost_function cost_function;
105  starpu_perfmodel_per_arch_size_base size_base;
106 
107  struct starpu_perfmodel_history_table *history;
110 
111  char debug_path[256];
112 };
113 
115 {
116  STARPU_PERFMODEL_INVALID=0,
122 };
123 
124 struct _starpu_perfmodel_state;
125 typedef struct _starpu_perfmodel_state* starpu_perfmodel_state_t;
126 
128 {
130 
131  double (*cost_function)(struct starpu_task *, unsigned nimpl);
132  double (*arch_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch * arch, unsigned nimpl);
133 
134  size_t (*size_base)(struct starpu_task *, unsigned nimpl);
135  uint32_t (*footprint)(struct starpu_task *);
136 
137  const char *symbol;
138 
139  unsigned is_loaded;
140  unsigned benchmarking;
141  unsigned is_init;
142 
143  starpu_perfmodel_state_t state;
144 };
145 
146 void starpu_perfmodel_init(struct starpu_perfmodel *model);
147 int starpu_perfmodel_load_file(const char *filename, struct starpu_perfmodel *model);
148 int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
150 void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxlen);
151 
153 
154 struct starpu_perfmodel_arch *starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id);
155 int starpu_perfmodel_get_narch_combs();
156 int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device* devices);
157 int starpu_perfmodel_arch_comb_get(int ndevices, struct starpu_perfmodel_device *devices);
158 struct starpu_perfmodel_arch *starpu_perfmodel_arch_comb_fetch(int comb);
159 
160 struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_arch(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned impl);
161 struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_devices(struct starpu_perfmodel *model, int impl, ...);
162 
163 int starpu_perfmodel_set_per_devices_cost_function(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_cost_function func, ...);
164 int starpu_perfmodel_set_per_devices_size_base(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_size_base func, ...);
165 
166 void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl);
168 void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl);
169 
170 double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, uint32_t footprint);
171 void starpu_perfmodel_initialize(void);
172 int starpu_perfmodel_list(FILE *output);
173 void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
174 int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
175 int starpu_perfmodel_print_estimations(struct starpu_perfmodel *model, uint32_t footprint, FILE *output);
176 
177 int starpu_perfmodel_list_combs(FILE *output, struct starpu_perfmodel *model);
178 
179 void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured);
180 void starpu_perfmodel_directory(FILE *output);
181 
182 void starpu_bus_print_bandwidth(FILE *f);
183 void starpu_bus_print_affinity(FILE *f);
184 void starpu_bus_print_filenames(FILE *f);
185 
186 double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
187 double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
188 double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
189 
190 #ifdef __cplusplus
191 }
192 #endif
193 
194 #endif /* __STARPU_PERFMODEL_H__ */
int ndevices
Definition: starpu_perfmodel.h:49
Definition: starpu_perfmodel.h:117
double sumlny
Definition: starpu_perfmodel.h:75
Definition: starpu_perfmodel.h:102
Definition: starpu_perfmodel.h:40
void starpu_bus_print_bandwidth(FILE *f)
void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl)
void starpu_bus_print_filenames(FILE *f)
unsigned is_init
Definition: starpu_perfmodel.h:141
int starpu_perfmodel_list(FILE *output)
void starpu_perfmodel_free_sampling_directories(void)
int starpu_perfmodel_load_file(const char *filename, struct starpu_perfmodel *model)
unsigned nsample
Definition: starpu_perfmodel.h:92
void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl)
double sumlnx2
Definition: starpu_perfmodel.h:78
starpu_worker_archtype
Definition: starpu_worker.h:31
struct starpu_perfmodel_history_list * list
Definition: starpu_perfmodel.h:108
unsigned long minx
Definition: starpu_perfmodel.h:80
double flops
Definition: starpu_perfmodel.h:64
unsigned nl_valid
Definition: starpu_perfmodel.h:90
Definition: starpu_perfmodel.h:119
starpu_perfmodel_type
Definition: starpu_perfmodel.h:114
struct starpu_perfmodel_history_entry * entry
Definition: starpu_perfmodel.h:70
unsigned is_loaded
Definition: starpu_perfmodel.h:139
uint32_t footprint
Definition: starpu_perfmodel.h:62
struct starpu_perfmodel_history_table * history
Definition: starpu_perfmodel.h:107
double sum
Definition: starpu_perfmodel.h:58
Definition: starpu_perfmodel.h:67
void starpu_perfmodel_init(struct starpu_perfmodel *model)
Definition: starpu_task.h:129
struct starpu_perfmodel_arch * starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id)
double sum2
Definition: starpu_perfmodel.h:59
void starpu_perfmodel_directory(FILE *output)
double c
Definition: starpu_perfmodel.h:89
double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size)
double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, uint32_t footprint)
void starpu_bus_print_affinity(FILE *f)
unsigned valid
Definition: starpu_perfmodel.h:87
Definition: starpu_perfmodel.h:47
Definition: starpu_perfmodel.h:54
Definition: starpu_perfmodel.h:121
unsigned long maxx
Definition: starpu_perfmodel.h:81
double sumlnxlny
Definition: starpu_perfmodel.h:83
double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node)
Definition: starpu_perfmodel.h:120
int starpu_perfmodel_print_estimations(struct starpu_perfmodel *model, uint32_t footprint, FILE *output)
double deviation
Definition: starpu_perfmodel.h:57
Definition: starpu_perfmodel.h:127
void starpu_perfmodel_initialize(void)
double starpu_transfer_latency(unsigned src_node, unsigned dst_node)
int devid
Definition: starpu_perfmodel.h:43
int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model)
enum starpu_worker_archtype type
Definition: starpu_perfmodel.h:42
double alpha
Definition: starpu_perfmodel.h:85
unsigned nsample
Definition: starpu_perfmodel.h:60
char * starpu_perfmodel_get_archtype_name(enum starpu_worker_archtype archtype)
size_t size
Definition: starpu_perfmodel.h:63
void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output)
double mean
Definition: starpu_perfmodel.h:56
void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured)
int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output)
int starpu_perfmodel_unload_model(struct starpu_perfmodel *model)
Definition: starpu_data.h:48
Definition: starpu_perfmodel.h:73
Definition: starpu_perfmodel.h:118
double sumlnx
Definition: starpu_perfmodel.h:77
const char * symbol
Definition: starpu_perfmodel.h:137
double beta
Definition: starpu_perfmodel.h:86
struct starpu_perfmodel_device * devices
Definition: starpu_perfmodel.h:50
struct starpu_perfmodel_history_list * next
Definition: starpu_perfmodel.h:69