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-2014,2016 Inria
4  * Copyright (C) 2009-2019 Université de Bordeaux
5  * Copyright (C) 2010-2017, 2019 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 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31 
37 struct starpu_task;
38 struct starpu_data_descr;
39 
40 #define STARPU_NARCH STARPU_ANY_WORKER
41 
46 {
48  int devid;
49  int ncores;
50 };
51 
56 {
57  int ndevices;
59 };
60 
61 
63 {
64  double mean;
65  double deviation;
66  double sum;
67  double sum2;
68  unsigned nsample;
69  unsigned nerror;
70  uint32_t footprint;
71  size_t size;
72  double flops;
74  double duration;
75  starpu_tag_t tag;
76  double *parameters;
77 };
78 
80 {
81  struct starpu_perfmodel_history_list *next;
82  struct starpu_perfmodel_history_entry *entry;
83 };
84 
89 {
90  double sumlny;
92  double sumlnx;
93  double sumlnx2;
95  unsigned long minx;
96  unsigned long maxx;
98  double sumlnxlny;
100  double alpha;
101  double beta;
102  unsigned valid;
104  double a;
105  double b;
106  double c;
107  unsigned nl_valid;
109  unsigned nsample;
111  double *coeff;
112  unsigned ncoeff;
113  unsigned multi_valid;
114 };
115 
116 struct starpu_perfmodel_history_table;
117 
118 #define starpu_per_arch_perfmodel starpu_perfmodel_per_arch STARPU_DEPRECATED
119 
120 typedef double (*starpu_perfmodel_per_arch_cost_function)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
121 typedef size_t (*starpu_perfmodel_per_arch_size_base)(struct starpu_task *task, struct starpu_perfmodel_arch* arch, unsigned nimpl);
122 
127 {
134  starpu_perfmodel_per_arch_cost_function cost_function;
139  starpu_perfmodel_per_arch_size_base size_base;
140 
145  struct starpu_perfmodel_history_table *history;
160 
161  char debug_path[256];
162 };
163 
168 {
169  STARPU_PERFMODEL_INVALID=0,
177 };
178 
179 struct _starpu_perfmodel_state;
180 typedef struct _starpu_perfmodel_state* starpu_perfmodel_state_t;
181 
191 {
224 
229  double (*cost_function)(struct starpu_task *, unsigned nimpl);
235  double (*arch_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch * arch, unsigned nimpl);
236 
243  size_t (*size_base)(struct starpu_task *, unsigned nimpl);
250  uint32_t (*footprint)(struct starpu_task *);
251 
257  const char *symbol;
258 
263  unsigned is_loaded;
267  unsigned benchmarking;
271  unsigned is_init;
272 
273  void (*parameters)(struct starpu_task * task, double *parameters);
279  const char **parameters_names;
284  unsigned nparameters;
290  unsigned **combinations;
296  unsigned ncombinations;
300  starpu_perfmodel_state_t state;
301 };
302 
307 void starpu_perfmodel_init(struct starpu_perfmodel *model);
308 
313 int starpu_perfmodel_load_file(const char *filename, struct starpu_perfmodel *model);
314 
322 int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
323 
329 
335 void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxlen);
336 
340 void starpu_perfmodel_dump_xml(FILE *output, struct starpu_perfmodel *model);
341 
349 
353 struct starpu_perfmodel_arch *starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id);
354 
355 int starpu_perfmodel_get_narch_combs(void);
356 int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device* devices);
357 int starpu_perfmodel_arch_comb_get(int ndevices, struct starpu_perfmodel_device *devices);
358 struct starpu_perfmodel_arch *starpu_perfmodel_arch_comb_fetch(int comb);
359 
360 struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_arch(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned impl);
361 struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_devices(struct starpu_perfmodel *model, int impl, ...);
362 
363 int starpu_perfmodel_set_per_devices_cost_function(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_cost_function func, ...);
364 int starpu_perfmodel_set_per_devices_size_base(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_size_base func, ...);
365 
369 void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl);
370 
371 char* starpu_perfmodel_get_archtype_name(enum starpu_worker_archtype archtype);
372 
376 void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl);
377 
381 double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch* arch, uint32_t footprint);
382 
386 void starpu_perfmodel_initialize(void);
387 
391 int starpu_perfmodel_list(FILE *output);
392 
393 void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
394 int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
395 int starpu_perfmodel_print_estimations(struct starpu_perfmodel *model, uint32_t footprint, FILE *output);
396 
397 int starpu_perfmodel_list_combs(FILE *output, struct starpu_perfmodel *model);
398 
407 void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured);
408 
412 void starpu_perfmodel_directory(FILE *output);
413 
417 void starpu_bus_print_bandwidth(FILE *f);
418 
422 void starpu_bus_print_affinity(FILE *f);
423 
427 void starpu_bus_print_filenames(FILE *f);
428 
432 double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
433 
437 double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
438 
442 double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
443 
448 
451 #ifdef __cplusplus
452 }
453 #endif
454 
455 #endif /* __STARPU_PERFMODEL_H__ */
int ndevices
Definition: starpu_perfmodel.h:57
void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxlen)
double sumlny
Definition: starpu_perfmodel.h:90
Definition: starpu_perfmodel.h:126
Definition: starpu_perfmodel.h:45
unsigned ncombinations
Definition: starpu_perfmodel.h:296
void starpu_bus_print_bandwidth(FILE *f)
Definition: starpu_perfmodel.h:173
void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl)
Definition: starpu_perfmodel.h:175
void starpu_bus_print_filenames(FILE *f)
int starpu_perfmodel_list(FILE *output)
struct starpu_perfmodel_arch * starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id)
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:109
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:93
starpu_worker_archtype
Definition: starpu_worker.h:61
Definition: starpu_perfmodel.h:172
unsigned long minx
Definition: starpu_perfmodel.h:95
double flops
Definition: starpu_perfmodel.h:72
unsigned nl_valid
Definition: starpu_perfmodel.h:107
double a
Definition: starpu_perfmodel.h:104
struct starpu_perfmodel_device * devices
Definition: starpu_perfmodel.h:58
double * coeff
Definition: starpu_perfmodel.h:111
starpu_perfmodel_type
Definition: starpu_perfmodel.h:167
unsigned is_loaded
Definition: starpu_perfmodel.h:263
uint32_t footprint
Definition: starpu_perfmodel.h:70
double sum
Definition: starpu_perfmodel.h:66
struct starpu_perfmodel_history_list * list
Definition: starpu_perfmodel.h:152
Definition: starpu_perfmodel.h:79
Definition: starpu_perfmodel.h:171
uint64_t starpu_tag_t
Definition: starpu_task_dep.h:129
void starpu_perfmodel_init(struct starpu_perfmodel *model)
unsigned multi_valid
Definition: starpu_perfmodel.h:113
Definition: starpu_task.h:548
double sum2
Definition: starpu_perfmodel.h:67
Definition: starpu_perfmodel.h:170
void starpu_perfmodel_directory(FILE *output)
double c
Definition: starpu_perfmodel.h:106
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:102
int ncores
Definition: starpu_perfmodel.h:49
Definition: starpu_perfmodel.h:55
Definition: starpu_perfmodel.h:62
unsigned long maxx
Definition: starpu_perfmodel.h:96
double sumlnxlny
Definition: starpu_perfmodel.h:98
unsigned nparameters
Definition: starpu_perfmodel.h:284
unsigned ncoeff
Definition: starpu_perfmodel.h:112
double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node)
struct starpu_perfmodel starpu_perfmodel_nop
struct starpu_perfmodel_history_table * history
Definition: starpu_perfmodel.h:145
double deviation
Definition: starpu_perfmodel.h:65
Definition: starpu_perfmodel.h:190
void starpu_perfmodel_initialize(void)
double starpu_transfer_latency(unsigned src_node, unsigned dst_node)
Definition: starpu_perfmodel.h:174
const char * symbol
Definition: starpu_perfmodel.h:257
int devid
Definition: starpu_perfmodel.h:48
int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model)
double b
Definition: starpu_perfmodel.h:105
enum starpu_worker_archtype type
Definition: starpu_perfmodel.h:47
double alpha
Definition: starpu_perfmodel.h:100
unsigned nsample
Definition: starpu_perfmodel.h:68
size_t size
Definition: starpu_perfmodel.h:71
double mean
Definition: starpu_perfmodel.h:64
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_unload_model(struct starpu_perfmodel *model)
const char ** parameters_names
Definition: starpu_perfmodel.h:279
Definition: starpu_task.h:533
Definition: starpu_perfmodel.h:88
double sumlnx
Definition: starpu_perfmodel.h:92
double beta
Definition: starpu_perfmodel.h:101
void starpu_perfmodel_dump_xml(FILE *output, struct starpu_perfmodel *model)
unsigned ** combinations
Definition: starpu_perfmodel.h:290