StarPU Handbook
 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
4  * Copyright (C) 2010, 2011, 2012, 2013, 2014 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 
36 {
38  STARPU_CUDA_DEFAULT = STARPU_MAXCPUS,
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");
50  "invalid STARPU_CPU_DEFAULT value");
52  "invalid STARPU_{CUDA,OPENCL}_DEFAULT values");
53 
54 # endif
55 #endif
56 
57 #define STARPU_NARCH_VARIATIONS (STARPU_OPENCL_DEFAULT + STARPU_MAXOPENCLDEVS)
58 
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 
76 {
79 };
80 
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 
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;
116 #ifdef STARPU_MODEL_DEBUG
117  char debug_path[256];
118 #endif
119 };
120 
122 {
128 };
129 
131 {
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 
150 
151 int starpu_perfmodel_load_symbol(const char *symbol, struct starpu_perfmodel *model);
153 
154 void starpu_perfmodel_debugfilepath(struct starpu_perfmodel *model, enum starpu_perfmodel_archtype arch, char *path, size_t maxlen, unsigned nimpl);
155 void starpu_perfmodel_get_arch_name(enum starpu_perfmodel_archtype arch, char *archname, size_t maxlen, unsigned nimpl);
156 
157 double starpu_permodel_history_based_expected_perf(struct starpu_perfmodel *model, enum starpu_perfmodel_archtype arch, uint32_t footprint);
158 int starpu_perfmodel_list(FILE *output);
159 void starpu_perfmodel_print(struct starpu_perfmodel *model, enum starpu_perfmodel_archtype arch, unsigned nimpl, char *parameter, uint32_t *footprint, FILE *output);
160 int starpu_perfmodel_print_all(struct starpu_perfmodel *model, char *arch, char *parameter, uint32_t *footprint, FILE *output);
161 
162 void starpu_perfmodel_directory(FILE *output);
163 
164 void starpu_perfmodel_update_history(struct starpu_perfmodel *model, struct starpu_task *task, enum starpu_perfmodel_archtype arch, unsigned cpuid, unsigned nimpl, double measured);
165 
166 void starpu_bus_print_bandwidth(FILE *f);
167 void starpu_bus_print_affinity(FILE *f);
168 
169 double starpu_transfer_bandwidth(unsigned src_node, unsigned dst_node);
170 double starpu_transfer_latency(unsigned src_node, unsigned dst_node);
171 double starpu_transfer_predict(unsigned src_node, unsigned dst_node, size_t size);
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif /* __STARPU_PERFMODEL_H__ */