StarPU Handbook

starpu_profiling.h
Go to the documentation of this file.
1/* StarPU --- Runtime system for heterogeneous multicore architectures.
2 *
3 * Copyright (C) 2010-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4 * Copyright (C) 2020 Federal University of Rio Grande do Sul (UFRGS)
5 *
6 * StarPU is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or (at
9 * your option) any later version.
10 *
11 * StarPU is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 *
15 * See the GNU Lesser General Public License in COPYING.LGPL for more details.
16 */
17
18#ifndef __STARPU_PROFILING_H__
19#define __STARPU_PROFILING_H__
20
21#include <starpu.h>
22#include <errno.h>
23#include <time.h>
24
25#ifdef __cplusplus
26 extern "C"
27{
28#endif
29
38#define STARPU_PROFILING_DISABLE 0
42#define STARPU_PROFILING_ENABLE 1
43
48 struct starpu_profiling_task_info
49{
51 struct timespec submit_time;
52
54 struct timespec push_start_time;
56 struct timespec push_end_time;
58 struct timespec pop_start_time;
60 struct timespec pop_end_time;
61
63 struct timespec acquire_data_start_time;
65 struct timespec acquire_data_end_time;
66
68 struct timespec start_time;
70 struct timespec end_time;
71
73 struct timespec release_data_start_time;
75 struct timespec release_data_end_time;
76
78 struct timespec callback_start_time;
80 struct timespec callback_end_time;
81
82 /* TODO add expected length, expected start/end ? */
83
85 int workerid;
86
88 uint64_t used_cycles;
90 uint64_t stall_cycles;
92 double energy_consumed;
93};
94
100 struct starpu_profiling_worker_info
101{
103 struct timespec start_time;
105 struct timespec total_time;
107 struct timespec executing_time;
109 struct timespec sleeping_time;
111 int executed_tasks;
112
114 uint64_t used_cycles;
116 uint64_t stall_cycles;
118 double energy_consumed;
119
120 double flops;
121};
122
123 struct starpu_profiling_bus_info
124{
126 struct timespec start_time;
128 struct timespec total_time;
130 int long long transferred_bytes;
132 int transfer_count;
133};
134
139 void starpu_profiling_init(void);
140
144 void starpu_profiling_set_id(int new_id);
145
156 int starpu_profiling_status_set(int status);
157
162 int starpu_profiling_status_get(void);
163
164#ifdef BUILDING_STARPU
165#include <common/utils.h>
166#ifdef __GNUC__
167 extern int _starpu_profiling;
168#define starpu_profiling_status_get() ({ \
169 int __ret; \
170 ANNOTATE_HAPPENS_AFTER(&_starpu_profiling); \
171 __ret = _starpu_profiling; \
172 ANNOTATE_HAPPENS_BEFORE(&_starpu_profiling); \
173 __ret; \
174})
175#endif
176#endif
177
185 int starpu_profiling_worker_get_info(int workerid, struct starpu_profiling_worker_info *worker_info);
186
190 int starpu_bus_get_count(void);
191
195 int starpu_bus_get_id(int src, int dst);
196
200 int starpu_bus_get_src(int busid);
201
205 int starpu_bus_get_dst(int busid);
206 void starpu_bus_set_direct(int busid, int direct);
207 int starpu_bus_get_direct(int busid);
208 void starpu_bus_set_ngpus(int busid, int ngpus);
209 int starpu_bus_get_ngpus(int busid);
210
215 int starpu_bus_get_profiling_info(int busid, struct starpu_profiling_bus_info *bus_info);
216
217/* Some helper functions to manipulate profiling API output */
218/* Reset timespec */
219 static __starpu_inline void starpu_timespec_clear(struct timespec *tsp)
220{
221 tsp->tv_sec = 0;
222 tsp->tv_nsec = 0;
223}
224
225#define STARPU_NS_PER_S 1000000000
226
227/* Computes result = a + b */
228 static __starpu_inline void starpu_timespec_add(struct timespec *a,
229 struct timespec *b,
230 struct timespec *result)
231{
232 result->tv_sec = a->tv_sec + b->tv_sec;
233 result->tv_nsec = a->tv_nsec + b->tv_nsec;
234
235 if (result->tv_nsec >= STARPU_NS_PER_S)
236 {
237 ++(result)->tv_sec;
238 result->tv_nsec -= STARPU_NS_PER_S;
239 }
240}
241
242/* Computes res += b */
243 static __starpu_inline void starpu_timespec_accumulate(struct timespec *result,
244 struct timespec *a)
245{
246 result->tv_sec += a->tv_sec;
247 result->tv_nsec += a->tv_nsec;
248
249 if (result->tv_nsec >= STARPU_NS_PER_S)
250 {
251 ++(result)->tv_sec;
252 result->tv_nsec -= STARPU_NS_PER_S;
253 }
254}
255
256/* Computes result = a - b */
257 static __starpu_inline void starpu_timespec_sub(const struct timespec *a,
258 const struct timespec *b,
259 struct timespec *result)
260{
261 result->tv_sec = a->tv_sec - b->tv_sec;
262 result->tv_nsec = a->tv_nsec - b->tv_nsec;
263
264 if ((result)->tv_nsec < 0)
265 {
266 --(result)->tv_sec;
267 result->tv_nsec += STARPU_NS_PER_S;
268 }
269}
270
271#define starpu_timespec_cmp(a, b, CMP) \
272 (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_nsec CMP (b)->tv_nsec) : ((a)->tv_sec CMP (b)->tv_sec))
273
277 double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end);
278
282 double starpu_timing_timespec_to_us(struct timespec *ts);
283
289 void starpu_profiling_bus_helper_display_summary(void);
290
296 void starpu_profiling_worker_helper_display_summary(void);
297
304 void starpu_data_display_memory_stats();
305
308#ifdef __cplusplus
309}
310#endif
311
312#endif /* __STARPU_PROFILING_H__ */
starpu_profiling_bus_info::transferred_bytes
int long long transferred_bytes
Definition: starpu_profiling.h:130
starpu_profiling_worker_info::executing_time
struct timespec executing_time
Definition: starpu_profiling.h:107
starpu_profiling_task_info::acquire_data_end_time
struct timespec acquire_data_end_time
Definition: starpu_profiling.h:65
starpu_profiling_task_info::workerid
int workerid
Definition: starpu_profiling.h:85
starpu_profiling_worker_info::stall_cycles
uint64_t stall_cycles
Definition: starpu_profiling.h:116
starpu_profiling_task_info::callback_end_time
struct timespec callback_end_time
Definition: starpu_profiling.h:80
starpu_profiling_bus_info::transfer_count
int transfer_count
Definition: starpu_profiling.h:132
starpu_profiling_task_info::submit_time
struct timespec submit_time
Definition: starpu_profiling.h:51
starpu_profiling_bus_info::total_time
struct timespec total_time
Definition: starpu_profiling.h:128
starpu_profiling_task_info::callback_start_time
struct timespec callback_start_time
Definition: starpu_profiling.h:78
starpu_profiling_worker_info::energy_consumed
double energy_consumed
Definition: starpu_profiling.h:118
starpu_profiling_task_info::pop_start_time
struct timespec pop_start_time
Definition: starpu_profiling.h:58
starpu_profiling_worker_info::used_cycles
uint64_t used_cycles
Definition: starpu_profiling.h:114
starpu_profiling_task_info::push_end_time
struct timespec push_end_time
Definition: starpu_profiling.h:56
starpu_profiling_task_info::energy_consumed
double energy_consumed
Definition: starpu_profiling.h:92
starpu_profiling_worker_info::executed_tasks
int executed_tasks
Definition: starpu_profiling.h:111
starpu_profiling_task_info::stall_cycles
uint64_t stall_cycles
Definition: starpu_profiling.h:90
starpu_profiling_bus_info::start_time
struct timespec start_time
Definition: starpu_profiling.h:126
starpu_profiling_task_info::acquire_data_start_time
struct timespec acquire_data_start_time
Definition: starpu_profiling.h:63
starpu_profiling_task_info::release_data_end_time
struct timespec release_data_end_time
Definition: starpu_profiling.h:75
starpu_profiling_task_info::pop_end_time
struct timespec pop_end_time
Definition: starpu_profiling.h:60
starpu_profiling_task_info::push_start_time
struct timespec push_start_time
Definition: starpu_profiling.h:54
starpu_profiling_worker_info::total_time
struct timespec total_time
Definition: starpu_profiling.h:105
starpu_profiling_task_info::release_data_start_time
struct timespec release_data_start_time
Definition: starpu_profiling.h:73
starpu_profiling_task_info::start_time
struct timespec start_time
Definition: starpu_profiling.h:68
starpu_profiling_worker_info::sleeping_time
struct timespec sleeping_time
Definition: starpu_profiling.h:109
starpu_profiling_task_info::end_time
struct timespec end_time
Definition: starpu_profiling.h:70
starpu_profiling_task_info::used_cycles
uint64_t used_cycles
Definition: starpu_profiling.h:88
starpu_profiling_worker_info::start_time
struct timespec start_time
Definition: starpu_profiling.h:103
starpu_profiling_worker_helper_display_summary
void starpu_profiling_worker_helper_display_summary(void)
starpu_profiling_bus_helper_display_summary
void starpu_profiling_bus_helper_display_summary(void)
starpu_profiling_init
void starpu_profiling_init(void)
starpu_data_display_memory_stats
void starpu_data_display_memory_stats()
starpu_bus_get_profiling_info
int starpu_bus_get_profiling_info(int busid, struct starpu_profiling_bus_info *bus_info)
starpu_bus_get_id
int starpu_bus_get_id(int src, int dst)
starpu_bus_get_src
int starpu_bus_get_src(int busid)
starpu_timing_timespec_to_us
double starpu_timing_timespec_to_us(struct timespec *ts)
starpu_profiling_worker_get_info
int starpu_profiling_worker_get_info(int workerid, struct starpu_profiling_worker_info *worker_info)
starpu_bus_get_count
int starpu_bus_get_count(void)
starpu_bus_get_dst
int starpu_bus_get_dst(int busid)
starpu_profiling_status_set
int starpu_profiling_status_set(int status)
starpu_timing_timespec_delay_us
double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end)
starpu_profiling_set_id
void starpu_profiling_set_id(int new_id)
starpu_profiling_status_get
int starpu_profiling_status_get(void)
starpu_profiling_bus_info
Definition: starpu_profiling.h:124
starpu_profiling_task_info
Definition: starpu_profiling.h:49
starpu_profiling_worker_info
Definition: starpu_profiling.h:101
starpu.h