StarPU Handbook

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
starpu_perfmodel.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2 *
3 * Copyright (C) 2010-2013 Université de Bordeaux 1
4 * Copyright (C) 2010, 2011, 2012, 2013 Centre National de la Recherche Scientifique
5 * Copyright (C) 2011 Télécom-SudParis
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 #include <starpu_util.h>
26
27 #ifdef __cplusplus
28 extern "C"
29 {
30 #endif
31
32 struct starpu_task;
33 struct starpu_data_descr;
34
35 enum starpu_perfmodel_archtype
36 {
37 STARPU_CPU_DEFAULT = 0,
38 STARPU_CUDA_DEFAULT = STARPU_MAXCPUS,
39 STARPU_OPENCL_DEFAULT = STARPU_CUDA_DEFAULT + STARPU_MAXCUDADEVS
40 };
41
42 #ifdef __STDC_VERSION__
43 # if __STDC_VERSION__ > 199901L || STARPU_GNUC_PREREQ(4, 6)
44
45 /* Make sure the following assertions hold, since StarPU relies on it. */
46
47 _Static_assert(STARPU_CPU_DEFAULT == 0,
48 "invalid STARPU_CPU_DEFAULT value");
49 _Static_assert(STARPU_CUDA_DEFAULT > STARPU_CPU_DEFAULT,
50 "invalid STARPU_CPU_DEFAULT value");
51 _Static_assert(STARPU_CUDA_DEFAULT < STARPU_OPENCL_DEFAULT,
52 "invalid STARPU_{CUDA,OPENCL}_DEFAULT values");
53
54 # endif
55 #endif
56
57 #define STARPU_NARCH_VARIATIONS (STARPU_OPENCL_DEFAULT + STARPU_MAXOPENCLDEVS)
58
59 struct starpu_perfmodel_history_entry
60 {
61 double mean;
62 double deviation;
63 double sum;
64 double sum2;
65 unsigned nsample;
66 uint32_t footprint;
67 #ifdef STARPU_HAVE_WINDOWS
68 unsigned size;
69 #else
70 size_t size;
71 #endif
72 double flops;
73 };
74
75 struct starpu_perfmodel_history_list
76 {
77 struct starpu_perfmodel_history_list *next;
78 struct starpu_perfmodel_history_entry *entry;
79 };
80
81 struct starpu_perfmodel_regression_model
82 {
83 double sumlny;
84
85 double sumlnx;
86 double sumlnx2;
87
88 unsigned long minx;
89 unsigned long maxx;
90
91 double sumlnxlny;
92
93 double alpha;
94 double beta;
95 unsigned valid;
96
97 double a, b, c;
98 unsigned nl_valid;
99
100 unsigned nsample;
101 };
102
103 struct starpu_perfmodel_history_table;
104
105 #define starpu_per_arch_perfmodel starpu_perfmodel_per_arch STARPU_DEPRECATED
106
107 struct starpu_perfmodel_per_arch
108 {
109 double (*cost_model)(struct starpu_data_descr *t) STARPU_DEPRECATED;
110 double (*cost_function)(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl);
111 size_t (*size_base)(struct starpu_task *, enum starpu_perfmodel_archtype arch, unsigned nimpl);
112
113 struct starpu_perfmodel_history_table *history;
114 struct starpu_perfmodel_history_list *list;
115 struct starpu_perfmodel_regression_model regression;
116 #ifdef STARPU_MODEL_DEBUG
117 char debug_path[256];
118 #endif
119 };
120
121 enum starpu_perfmodel_type
122 {
123 STARPU_PER_ARCH,
124 STARPU_COMMON,
125 STARPU_HISTORY_BASED,
126 STARPU_REGRESSION_BASED,
127 STARPU_NL_REGRESSION_BASED
128 };
129
130 struct starpu_perfmodel
131 {
132 enum starpu_perfmodel_type type;
133
134 double (*cost_model)(struct starpu_data_descr *) STARPU_DEPRECATED;
135 double (*cost_function)(struct starpu_task *, unsigned nimpl);
136
137 size_t (*size_base)(struct starpu_task *, unsigned nimpl);
138
139 struct starpu_perfmodel_per_arch per_arch[STARPU_NARCH_VARIATIONS][STARPU_MAXIMPLEMENTATIONS];
140
141 const char *symbol;
142
143 unsigned is_loaded;
144 unsigned benchmarking;
145 starpu_pthread_rwlock_t model_rwlock;
146 };
147
148 enum starpu_perfmodel_archtype starpu_worker_get_perf_archtype(int workerid);
149
150 int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
151 int starpu_perfmodel_unload_model(struct starpu_perfmodel *model);
152
153 void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, enum starpu_perfmodel_archtype arch, char *path, size_t maxlen, unsigned nimpl);
154 void starpu_perfmodel_get_arch_name(enum starpu_perfmodel_archtype arch, char *archname, size_t maxlen, unsigned nimpl);
155
156 double starpu_permodel_history_based_expected_perf(struct starpu_perfmodel *model, enum starpu_perfmodel_archtype arch, uint32_t footprint);
157 int starpu_perfmodel_list(FILE *output);
158 void starpu_perfmodel_print(struct starpu_perfmodel *model, enum starpu_perfmodel_archtype arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
159 int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
160
161 void starpu_perfmodel_directory(FILE *output);
162
163 void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned cpuid, unsigned nimpl, double measured);
164
165 void starpu_bus_print_bandwidth(FILE *f);
166 void starpu_bus_print_affinity(FILE *f);
167
168 double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
169 double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
170 double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
171
172 #ifdef __cplusplus
173 }
174 #endif
175
176 #endif /* __STARPU_PERFMODEL_H__ */
starpu_perfmodel_history_entry::footprint
uint32_t footprint
Definition: starpu_perfmodel.h:66
starpu_perfmodel_update_history
void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned cpuid, unsigned nimpl, double measured)
starpu_perfmodel_history_entry::deviation
double deviation
Definition: starpu_perfmodel.h:62
STARPU_PER_ARCH
Definition: starpu_perfmodel.h:123
starpu_perfmodel_history_list::entry
struct starpu_perfmodel_history_entry * entry
Definition: starpu_perfmodel.h:78
starpu_perfmodel::size_base
size_t(* size_base)(struct starpu_task *, unsigned nimpl)
Definition: starpu_perfmodel.h:137
STARPU_OPENCL_DEFAULT
Definition: starpu_perfmodel.h:39
starpu_perfmodel_per_arch
Definition: starpu_perfmodel.h:107
starpu_bus_print_bandwidth
void starpu_bus_print_bandwidth(FILE *f)
starpu_perfmodel::model_rwlock
starpu_pthread_rwlock_t model_rwlock
Definition: starpu_perfmodel.h:145
starpu_perfmodel_regression_model::c
double c
Definition: starpu_perfmodel.h:97
starpu_perfmodel_get_arch_name
void starpu_perfmodel_get_arch_name(enum starpu_perfmodel_archtype arch, char *archname, size_t maxlen, unsigned nimpl)
starpu_perfmodel_per_arch::history
struct starpu_perfmodel_history_table * history
Definition: starpu_perfmodel.h:113
starpu_perfmodel_history_list::next
struct starpu_perfmodel_history_list * next
Definition: starpu_perfmodel.h:77
starpu_perfmodel_per_arch::cost_model
double(* cost_model)(struct starpu_data_descr *t)
Definition: starpu_perfmodel.h:109
starpu_perfmodel_regression_model::valid
unsigned valid
Definition: starpu_perfmodel.h:95
starpu_worker_get_perf_archtype
enum starpu_perfmodel_archtype starpu_worker_get_perf_archtype(int workerid)
starpu_perfmodel_list
int starpu_perfmodel_list(FILE *output)
starpu_perfmodel_history_entry::sum
double sum
Definition: starpu_perfmodel.h:63
starpu_perfmodel_regression_model::beta
double beta
Definition: starpu_perfmodel.h:94
starpu_perfmodel_regression_model::sumlnx
double sumlnx
Definition: starpu_perfmodel.h:85
starpu_perfmodel::is_loaded
unsigned is_loaded
Definition: starpu_perfmodel.h:143
starpu_perfmodel_per_arch::regression
struct starpu_perfmodel_regression_model regression
Definition: starpu_perfmodel.h:115
STARPU_HISTORY_BASED
Definition: starpu_perfmodel.h:125
starpu_perfmodel_type
starpu_perfmodel_type
Definition: starpu_perfmodel.h:121
starpu_perfmodel_history_entry::nsample
unsigned nsample
Definition: starpu_perfmodel.h:65
starpu_perfmodel_per_arch::cost_function
double(* cost_function)(struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned nimpl)
Definition: starpu_perfmodel.h:110
starpu_perfmodel_history_list
Definition: starpu_perfmodel.h:75
starpu_perfmodel::cost_function
double(* cost_function)(struct starpu_task *, unsigned nimpl)
Definition: starpu_perfmodel.h:135
starpu_task
Definition: starpu_task.h:104
starpu_perfmodel::per_arch
struct starpu_perfmodel_per_arch per_arch[STARPU_NARCH_VARIATIONS][STARPU_MAXIMPLEMENTATIONS]
Definition: starpu_perfmodel.h:139
starpu_perfmodel_history_entry::mean
double mean
Definition: starpu_perfmodel.h:61
starpu_perfmodel_regression_model::sumlny
double sumlny
Definition: starpu_perfmodel.h:83
STARPU_CPU_DEFAULT
Definition: starpu_perfmodel.h:37
starpu_transfer_predict
double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size)
starpu_bus_print_affinity
void starpu_bus_print_affinity(FILE *f)
starpu_perfmodel_regression_model::nl_valid
unsigned nl_valid
Definition: starpu_perfmodel.h:98
starpu_perfmodel_regression_model::sumlnx2
double sumlnx2
Definition: starpu_perfmodel.h:86
starpu_perfmodel_history_entry
Definition: starpu_perfmodel.h:59
STARPU_NL_REGRESSION_BASED
Definition: starpu_perfmodel.h:127
STARPU_CUDA_DEFAULT
Definition: starpu_perfmodel.h:38
starpu_perfmodel_directory
void starpu_perfmodel_directory(FILE *output)
starpu_util.h
STARPU_MAXCUDADEVS
#define STARPU_MAXCUDADEVS
Definition: starpu_config.h:72
starpu_perfmodel::benchmarking
unsigned benchmarking
Definition: starpu_perfmodel.h:144
starpu_perfmodel_history_entry::size
size_t size
Definition: starpu_perfmodel.h:70
starpu_perfmodel_regression_model::b
double b
Definition: starpu_perfmodel.h:97
starpu_transfer_bandwidth
double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node)
starpu_perfmodel::symbol
const char * symbol
Definition: starpu_perfmodel.h:141
starpu_perfmodel_debugfilepath
void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, enum starpu_perfmodel_archtype arch, char *path, size_t maxlen, unsigned nimpl)
starpu_perfmodel_print
void starpu_perfmodel_print(struct starpu_perfmodel *model, enum starpu_perfmodel_archtype arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output)
STARPU_REGRESSION_BASED
Definition: starpu_perfmodel.h:126
starpu_perfmodel_history_entry::sum2
double sum2
Definition: starpu_perfmodel.h:64
starpu_perfmodel_regression_model::minx
unsigned long minx
Definition: starpu_perfmodel.h:88
starpu_perfmodel::type
enum starpu_perfmodel_type type
Definition: starpu_perfmodel.h:132
starpu_perfmodel
Definition: starpu_perfmodel.h:130
starpu_perfmodel_archtype
starpu_perfmodel_archtype
Definition: starpu_perfmodel.h:35
starpu_perfmodel_per_arch::list
struct starpu_perfmodel_history_list * list
Definition: starpu_perfmodel.h:114
starpu_perfmodel::cost_model
double(* cost_model)(struct starpu_data_descr *)
Definition: starpu_perfmodel.h:134
starpu_perfmodel_per_arch::size_base
size_t(* size_base)(struct starpu_task *, enum starpu_perfmodel_archtype arch, unsigned nimpl)
Definition: starpu_perfmodel.h:111
starpu_transfer_latency
double starpu_transfer_latency(unsigned src_node, unsigned dst_node)
starpu_perfmodel_load_symbol
int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model)
starpu_perfmodel_regression_model::maxx
unsigned long maxx
Definition: starpu_perfmodel.h:89
starpu_perfmodel_print_all
int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output)
starpu_perfmodel_unload_model
int starpu_perfmodel_unload_model(struct starpu_perfmodel *model)
starpu.h
starpu_data_descr
Definition: starpu_data.h:41
starpu_perfmodel_regression_model::a
double a
Definition: starpu_perfmodel.h:97
starpu_perfmodel_regression_model
Definition: starpu_perfmodel.h:81
starpu_perfmodel_regression_model::nsample
unsigned nsample
Definition: starpu_perfmodel.h:100
STARPU_COMMON
Definition: starpu_perfmodel.h:124
starpu_perfmodel_history_entry::flops
double flops
Definition: starpu_perfmodel.h:72
starpu_perfmodel_regression_model::sumlnxlny
double sumlnxlny
Definition: starpu_perfmodel.h:91
starpu_perfmodel_regression_model::alpha
double alpha
Definition: starpu_perfmodel.h:93