StarPU Handbook - StarPU Introduction
starpu_perfmodel.h
Go to the documentation of this file.
1/* StarPU --- Runtime system for heterogeneous multicore architectures.
2 *
3 * Copyright (C) 2009-2025 University of Bordeaux, CNRS (LaBRI UMR 5800), Inria
4 * Copyright (C) 2013-2013 Thibaut Lambert
5 * Copyright (C) 2011-2011 Télécom Sud Paris
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#include <starpu.h>
20
21#ifndef __STARPU_PERFMODEL_H__
22#define __STARPU_PERFMODEL_H__
23
24#include <stdio.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
35struct starpu_task;
37
42{
44 int devid;
45 int ncores;
46};
47
52{
55};
56
61{
62 double mean;
63 double deviation;
64 double sum;
65 double sum2;
66 unsigned nsample;
67 unsigned nerror;
68 uint32_t footprint;
69 size_t size;
70 double flops;
72 double duration;
73 starpu_tag_t tag;
74 double *parameters;
75};
76
81{
84};
85
90{
91 double sumlny;
93 double sumlnx;
94 double sumlnx2;
96 unsigned long minx;
97 unsigned long maxx;
99 double sumlnxlny;
101 double alpha;
102 double beta;
103 unsigned valid;
105 double a;
106 double b;
107 double c;
108 unsigned nl_valid;
110 unsigned nsample;
112 double *coeff;
113 unsigned ncoeff;
114 unsigned multi_valid;
115};
116
117struct starpu_perfmodel_history_table;
118
119#define starpu_per_arch_perfmodel starpu_perfmodel_per_arch STARPU_DEPRECATED
120
121typedef double (*starpu_perfmodel_per_arch_cost_function)(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl);
122typedef size_t (*starpu_perfmodel_per_arch_size_base)(struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned nimpl);
123
128{
135 starpu_perfmodel_per_arch_cost_function cost_function;
140 starpu_perfmodel_per_arch_size_base size_base;
141
146 struct starpu_perfmodel_history_table *history;
161
162 char debug_path[256];
163};
164
169{
170 STARPU_PERFMODEL_INVALID = 0,
180
181struct _starpu_perfmodel_state;
182typedef struct _starpu_perfmodel_state *starpu_perfmodel_state_t;
183
193{
226
231 double (*cost_function)(struct starpu_task *, unsigned nimpl);
237 double (*arch_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch *arch, unsigned nimpl);
243 double (*worker_cost_function)(struct starpu_task *, unsigned workerid, unsigned nimpl);
244
251 size_t (*size_base)(struct starpu_task *, unsigned nimpl);
258 uint32_t (*footprint)(struct starpu_task *);
259
265 const char *symbol;
266
271 char *path;
272
277 unsigned is_loaded;
281 unsigned benchmarking;
285 unsigned is_init;
286
287 void (*parameters)(struct starpu_task *task, double *parameters);
293 const char **parameters_names;
298 unsigned nparameters;
304 unsigned **combinations;
314 starpu_perfmodel_state_t state;
315};
316
322
329
339
352int starpu_energy_stop(struct starpu_perfmodel *model, struct starpu_task *task, unsigned nimpl, unsigned ntasks, int workerid, enum starpu_worker_archtype archi);
353
358int starpu_perfmodel_load_file(const char *filename, struct starpu_perfmodel *model);
359
367int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
368
374
379
385void starpu_perfmodel_get_model_path(const char *symbol, char *path, size_t maxlen);
386
391void starpu_perfmodel_dump_xml(FILE *output, struct starpu_perfmodel *model);
392
400
404struct starpu_perfmodel_arch *starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id);
405
406int starpu_perfmodel_get_narch_combs(void);
407int starpu_perfmodel_arch_comb_add(int ndevices, struct starpu_perfmodel_device *devices);
408int starpu_perfmodel_arch_comb_get(int ndevices, struct starpu_perfmodel_device *devices);
409struct starpu_perfmodel_arch *starpu_perfmodel_arch_comb_fetch(int comb);
410
411struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_arch(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned impl);
412struct starpu_perfmodel_per_arch *starpu_perfmodel_get_model_per_devices(struct starpu_perfmodel *model, int impl, ...);
413
414int starpu_perfmodel_set_per_devices_cost_function(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_cost_function func, ...);
415int starpu_perfmodel_set_per_devices_size_base(struct starpu_perfmodel *model, int impl, starpu_perfmodel_per_arch_size_base func, ...);
416
420void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, char *path, size_t maxlen, unsigned nimpl);
421
422const char *starpu_perfmodel_get_archtype_name(enum starpu_worker_archtype archtype);
423
427void starpu_perfmodel_get_arch_name(struct starpu_perfmodel_arch *arch, char *archname, size_t maxlen, unsigned nimpl);
428
432double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, uint32_t footprint);
433
438
442int starpu_perfmodel_list(FILE *output);
443
444void starpu_perfmodel_print(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
445int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
446int starpu_perfmodel_print_estimations(struct starpu_perfmodel *model, uint32_t footprint, FILE *output);
447
448int starpu_perfmodel_list_combs(FILE *output, struct starpu_perfmodel *model);
449
468void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, struct starpu_perfmodel_arch *arch, unsigned cpuid, unsigned nimpl, double measured);
469
476void 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);
477
481void starpu_perfmodel_directory(FILE *output);
482
487
492
497
502double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
503
508double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
509
514double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
515
520
523#ifdef __cplusplus
524}
525#endif
526
527#endif /* __STARPU_PERFMODEL_H__ */
unsigned workerid
Definition: starpu_task.h:1228
Definition: starpu_task.h:674
Definition: starpu_task.h:689
uint64_t starpu_tag_t
Definition: starpu_task_dep.h:134
double sum2
Definition: starpu_perfmodel.h:65
const char * symbol
Definition: starpu_perfmodel.h:265
starpu_perfmodel_per_arch_cost_function cost_function
Definition: starpu_perfmodel.h:135
double(* cost_function)(struct starpu_task *, unsigned nimpl)
Definition: starpu_perfmodel.h:231
struct starpu_perfmodel_regression_model regression
Definition: starpu_perfmodel.h:160
struct starpu_perfmodel_history_list * list
Definition: starpu_perfmodel.h:153
unsigned valid
Definition: starpu_perfmodel.h:103
size_t size
Definition: starpu_perfmodel.h:69
double deviation
Definition: starpu_perfmodel.h:63
unsigned ncombinations
Definition: starpu_perfmodel.h:310
struct starpu_perfmodel_device * devices
Definition: starpu_perfmodel.h:54
uint32_t(* footprint)(struct starpu_task *)
Definition: starpu_perfmodel.h:258
double(* arch_cost_function)(struct starpu_task *, struct starpu_perfmodel_arch *arch, unsigned nimpl)
Definition: starpu_perfmodel.h:237
double sumlnx2
Definition: starpu_perfmodel.h:94
unsigned ** combinations
Definition: starpu_perfmodel.h:304
int ncores
Definition: starpu_perfmodel.h:45
unsigned ncoeff
Definition: starpu_perfmodel.h:113
int devid
Definition: starpu_perfmodel.h:44
unsigned long minx
Definition: starpu_perfmodel.h:96
double sumlny
Definition: starpu_perfmodel.h:91
size_t(* size_base)(struct starpu_task *, unsigned nimpl)
Definition: starpu_perfmodel.h:251
double mean
Definition: starpu_perfmodel.h:62
unsigned nl_valid
Definition: starpu_perfmodel.h:108
double sumlnxlny
Definition: starpu_perfmodel.h:99
unsigned nparameters
Definition: starpu_perfmodel.h:298
unsigned nsample
Definition: starpu_perfmodel.h:66
const char ** parameters_names
Definition: starpu_perfmodel.h:293
double beta
Definition: starpu_perfmodel.h:102
starpu_perfmodel_per_arch_size_base size_base
Definition: starpu_perfmodel.h:140
double sum
Definition: starpu_perfmodel.h:64
double a
Definition: starpu_perfmodel.h:105
enum starpu_worker_archtype type
Definition: starpu_perfmodel.h:43
char * path
Definition: starpu_perfmodel.h:271
double(* worker_cost_function)(struct starpu_task *, unsigned workerid, unsigned nimpl)
Definition: starpu_perfmodel.h:243
double c
Definition: starpu_perfmodel.h:107
double sumlnx
Definition: starpu_perfmodel.h:93
unsigned nsample
Definition: starpu_perfmodel.h:110
unsigned long maxx
Definition: starpu_perfmodel.h:97
uint32_t footprint
Definition: starpu_perfmodel.h:68
int ndevices
Definition: starpu_perfmodel.h:53
unsigned is_loaded
Definition: starpu_perfmodel.h:277
struct starpu_perfmodel_history_table * history
Definition: starpu_perfmodel.h:146
unsigned multi_valid
Definition: starpu_perfmodel.h:114
double * coeff
Definition: starpu_perfmodel.h:112
double flops
Definition: starpu_perfmodel.h:70
double b
Definition: starpu_perfmodel.h:106
double alpha
Definition: starpu_perfmodel.h:101
enum starpu_perfmodel_type type
Definition: starpu_perfmodel.h:225
double starpu_perfmodel_history_based_expected_perf(struct starpu_perfmodel *model, struct starpu_perfmodel_arch *arch, uint32_t footprint)
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)
struct starpu_perfmodel_arch * starpu_worker_get_perf_archtype(int workerid, unsigned sched_ctx_id)
starpu_perfmodel_type
Definition: starpu_perfmodel.h:169
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:176
@ STARPU_PER_WORKER
Definition: starpu_perfmodel.h:171
@ STARPU_MULTIPLE_REGRESSION_BASED
Definition: starpu_perfmodel.h:177
@ STARPU_REGRESSION_BASED
Definition: starpu_perfmodel.h:175
@ STARPU_COMMON
Definition: starpu_perfmodel.h:173
@ STARPU_PER_ARCH
Definition: starpu_perfmodel.h:172
@ STARPU_HISTORY_BASED
Definition: starpu_perfmodel.h:174
Definition: starpu_perfmodel.h:193
Definition: starpu_perfmodel.h:52
Definition: starpu_perfmodel.h:42
Definition: starpu_perfmodel.h:61
Definition: starpu_perfmodel.h:81
Definition: starpu_perfmodel.h:128
Definition: starpu_perfmodel.h:90
starpu_worker_archtype
Definition: starpu_worker.h:66