StarPU Handbook - StarPU Basics
starpu_perfmodel.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2009-2023 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4  * Copyright (C) 2011 Télécom-SudParis
5  * Copyright (C) 2013 Thibaut Lambert
6  *
7  * StarPU is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation; either version 2.1 of the License, or (at
10  * your option) any later version.
11  *
12  * StarPU is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  *
16  * See the GNU Lesser General Public License in COPYING.LGPL for more details.
17  */
18 
19 #ifndef __STARPU_PERFMODEL_H__
20 #define __STARPU_PERFMODEL_H__
21 
22 #include <starpu.h>
23 #include <stdio.h>
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
34 struct starpu_task;
35 struct starpu_data_descr;
36 
41 {
43  int devid;
44  int ncores;
45 };
46 
51 {
52  int ndevices;
54 };
55 
57 {
58  double mean;
59  double deviation;
60  double sum;
61  double sum2;
62  unsigned nsample;
63  unsigned nerror;
64  uint32_t footprint;
65  size_t size;
66  double flops;
68  double duration;
69  starpu_tag_t tag;
70  double *parameters;
71 };
72 
74 {
75  struct starpu_perfmodel_history_list *next;
76  struct starpu_perfmodel_history_entry *entry;
77 };
78 
83 {
84  double sumlny;
86  double sumlnx;
87  double sumlnx2;
89  unsigned long minx;
90  unsigned long maxx;
92  double sumlnxlny;
94  double alpha;
95  double beta;
96  unsigned valid;
98  double a;
99  double b;
100  double c;
101  unsigned nl_valid;
103  unsigned nsample;
105  double *coeff;
106  unsigned ncoeff;
107  unsigned multi_valid;
108 };
109 
110 struct starpu_perfmodel_history_table;
111 
112 #define starpu_per_arch_perfmodel starpu_perfmodel_per_arch STARPU_DEPRECATED
113 
114 typedef double (*starpu_perfmodel_per_arch_cost_function)(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl);
115 typedef size_t (*starpu_perfmodel_per_arch_size_base)(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl);
116 
121 {
128  starpu_perfmodel_per_arch_cost_function cost_function;
133  starpu_perfmodel_per_arch_size_base size_base;
134 
139  struct starpu_perfmodel_history_table *history;
154 
155  char debug_path[256];
156 };
157 
162 {
163  STARPU_PERFMODEL_INVALID = 0,
172 };
173 
174 struct _starpu_perfmodel_state;
175 typedef struct _starpu_perfmodel_state *starpu_perfmodel_state_t;
176 
186 {
219 
224  double (*cost_function)(struct starpu_task *, unsigned nimpl);
230  double (*arch_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch *arch, unsigned nimpl);
236  double (*worker_cost_function)(struct starpu_task *, unsigned workerid, unsigned nimpl);
237 
244  size_t (*size_base)(struct starpu_task *, unsigned nimpl);
251  uint32_t (*footprint)(struct starpu_task *);
252 
258  const char *symbol;
259 
264  char *path;
265 
270  unsigned is_loaded;
274  unsigned benchmarking;
278  unsigned is_init;
279 
280  void (*parameters)(struct starpu_task *task, double *parameters);
286  const char **parameters_names;
291  unsigned nparameters;
297  unsigned **combinations;
303  unsigned ncombinations;
307  starpu_perfmodel_state_t state;
308 };
309 
315 
322 
332 
345 int starpu_energy_stop(struct starpu_perfmodel *model, struct starpu_task *task, unsigned nimpl, unsigned ntasks, int workerid, enum starpu_worker_archtype archi);
346 
351 int starpu_perfmodel_load_file(const char *filename, struct starpu_perfmodel *model);
352 
360 int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
361 
367 
372 
378 void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxlen);
379 
384 void starpu_perfmodel_dump_xml(FILE *output, struct starpu_perfmodel *model);
385 
393 
397 struct starpu_perfmodel_arch *starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id);
398 
399 int starpu_perfmodel_get_narch_combs(void);
400 int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device *devices);
401 int starpu_perfmodel_arch_comb_get(int ndevices, struct starpu_perfmodel_device *devices);
402 struct starpu_perfmodel_arch *starpu_perfmodel_arch_comb_fetch(int comb);
403 
404 struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_arch(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned impl);
405 struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_devices(struct starpu_perfmodel *model, int impl, ...);
406 
407 int starpu_perfmodel_set_per_devices_cost_function(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_cost_function func, ...);
408 int starpu_perfmodel_set_per_devices_size_base(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_size_base func, ...);
409 
413 void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl);
414 
415 const char *starpu_perfmodel_get_archtype_name(enum starpu_worker_archtype archtype);
416 
420 void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl);
421 
425 double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, uint32_t footprint);
426 
431 
435 int starpu_perfmodel_list(FILE *output);
436 
437 void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
438 int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
439 int starpu_perfmodel_print_estimations(struct starpu_perfmodel *model, uint32_t footprint, FILE *output);
440 
441 int starpu_perfmodel_list_combs(FILE *output, struct starpu_perfmodel *model);
442 
461 void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured);
462 
469 void starpu_perfmodel_update_history_n(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double average_measured, unsigned number);
470 
474 void starpu_perfmodel_directory(FILE *output);
475 
480 
485 
490 
495 double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
496 
501 double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
502 
507 double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
508 
513 
516 #ifdef __cplusplus
517 }
518 #endif
519 
520 #endif /* __STARPU_PERFMODEL_H__ */
unsigned workerid
Definition: starpu_task.h:1186
Definition: starpu_task.h:647
Definition: starpu_task.h:662
uint64_t starpu_tag_t
Definition: starpu_task_dep.h:133
double sum2
Definition: starpu_perfmodel.h:61
const char * symbol
Definition: starpu_perfmodel.h:258
starpu_perfmodel_per_arch_cost_function cost_function
Definition: starpu_perfmodel.h:128
double(* cost_function)(struct starpu_task *, unsigned nimpl)
Definition: starpu_perfmodel.h:224
struct starpu_perfmodel_regression_model regression
Definition: starpu_perfmodel.h:153
struct starpu_perfmodel_history_list * list
Definition: starpu_perfmodel.h:146
unsigned valid
Definition: starpu_perfmodel.h:96
size_t size
Definition: starpu_perfmodel.h:65
double deviation
Definition: starpu_perfmodel.h:59
unsigned ncombinations
Definition: starpu_perfmodel.h:303
struct starpu_perfmodel_device * devices
Definition: starpu_perfmodel.h:53
uint32_t(* footprint)(struct starpu_task *)
Definition: starpu_perfmodel.h:251
double(* arch_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch *arch, unsigned nimpl)
Definition: starpu_perfmodel.h:230
double sumlnx2
Definition: starpu_perfmodel.h:87
unsigned ** combinations
Definition: starpu_perfmodel.h:297
int ncores
Definition: starpu_perfmodel.h:44
unsigned ncoeff
Definition: starpu_perfmodel.h:106
int devid
Definition: starpu_perfmodel.h:43
unsigned long minx
Definition: starpu_perfmodel.h:89
double sumlny
Definition: starpu_perfmodel.h:84
size_t(* size_base)(struct starpu_task *, unsigned nimpl)
Definition: starpu_perfmodel.h:244
double mean
Definition: starpu_perfmodel.h:58
unsigned nl_valid
Definition: starpu_perfmodel.h:101
double sumlnxlny
Definition: starpu_perfmodel.h:92
unsigned nparameters
Definition: starpu_perfmodel.h:291
unsigned nsample
Definition: starpu_perfmodel.h:62
const char ** parameters_names
Definition: starpu_perfmodel.h:286
double beta
Definition: starpu_perfmodel.h:95
starpu_perfmodel_per_arch_size_base size_base
Definition: starpu_perfmodel.h:133
double sum
Definition: starpu_perfmodel.h:60
double a
Definition: starpu_perfmodel.h:98
enum starpu_worker_archtype type
Definition: starpu_perfmodel.h:42
char * path
Definition: starpu_perfmodel.h:264
double(* worker_cost_function)(struct starpu_task *, unsigned workerid, unsigned nimpl)
Definition: starpu_perfmodel.h:236
double c
Definition: starpu_perfmodel.h:100
double sumlnx
Definition: starpu_perfmodel.h:86
unsigned nsample
Definition: starpu_perfmodel.h:103
unsigned long maxx
Definition: starpu_perfmodel.h:90
uint32_t footprint
Definition: starpu_perfmodel.h:64
int ndevices
Definition: starpu_perfmodel.h:52
unsigned is_loaded
Definition: starpu_perfmodel.h:270
struct starpu_perfmodel_history_table * history
Definition: starpu_perfmodel.h:139
unsigned multi_valid
Definition: starpu_perfmodel.h:107
double * coeff
Definition: starpu_perfmodel.h:105
double flops
Definition: starpu_perfmodel.h:66
double b
Definition: starpu_perfmodel.h:99
double alpha
Definition: starpu_perfmodel.h:94
enum starpu_perfmodel_type type
Definition: starpu_perfmodel.h:218
double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, uint32_t footprint)
struct starpu_perfmodel_arch * starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id)
void starpu_perfmodel_init(struct starpu_perfmodel *model)
void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl)
void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxlen)
struct starpu_perfmodel starpu_perfmodel_nop
int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model)
void starpu_bus_print_affinity(FILE *f)
void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl)
int starpu_perfmodel_list(FILE *output)
double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node)
double starpu_transfer_latency(unsigned src_node, unsigned dst_node)
void starpu_bus_print_filenames(FILE *f)
int starpu_energy_start(int workerid, enum starpu_worker_archtype archi)
int starpu_energy_stop(struct starpu_perfmodel *model, struct starpu_task *task, unsigned nimpl, unsigned ntasks, int workerid, enum starpu_worker_archtype archi)
void starpu_perfmodel_free_sampling(void)
int starpu_perfmodel_unload_model(struct starpu_perfmodel *model)
double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size)
void starpu_save_history_based_model(struct starpu_perfmodel *model)
void starpu_perfmodel_initialize(void)
void starpu_perfmodel_dump_xml(FILE *output, struct starpu_perfmodel *model)
void starpu_bus_print_bandwidth(FILE *f)
int starpu_perfmodel_deinit(struct starpu_perfmodel *model)
starpu_perfmodel_type
Definition: starpu_perfmodel.h:162
void starpu_perfmodel_update_history_n(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double average_measured, unsigned number)
void starpu_perfmodel_directory(FILE *output)
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_load_file(const char *filename, struct starpu_perfmodel *model)
@ STARPU_NL_REGRESSION_BASED
Definition: starpu_perfmodel.h:169
@ STARPU_PER_WORKER
Definition: starpu_perfmodel.h:164
@ STARPU_MULTIPLE_REGRESSION_BASED
Definition: starpu_perfmodel.h:170
@ STARPU_REGRESSION_BASED
Definition: starpu_perfmodel.h:168
@ STARPU_COMMON
Definition: starpu_perfmodel.h:166
@ STARPU_PER_ARCH
Definition: starpu_perfmodel.h:165
@ STARPU_HISTORY_BASED
Definition: starpu_perfmodel.h:167
Definition: starpu_perfmodel.h:186
Definition: starpu_perfmodel.h:51
Definition: starpu_perfmodel.h:41
Definition: starpu_perfmodel.h:57
Definition: starpu_perfmodel.h:74
Definition: starpu_perfmodel.h:121
Definition: starpu_perfmodel.h:83
starpu_worker_archtype
Definition: starpu_worker.h:66