StarPU Handbook - StarPU Applications
Loading...
Searching...
No Matches
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#include <starpu_config.h>
26
27#ifdef STARPU_PAPI
28#include <papi.h>
29#endif
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
43#define STARPU_PROFILING_DISABLE 0
47#define STARPU_PROFILING_ENABLE 1
48
54{
56 struct timespec submit_time;
57
59 struct timespec push_start_time;
61 struct timespec push_end_time;
63 struct timespec pop_start_time;
65 struct timespec pop_end_time;
66
68 struct timespec acquire_data_start_time;
70 struct timespec acquire_data_end_time;
71
73 struct timespec start_time;
75 struct timespec end_time;
76
78 struct timespec release_data_start_time;
80 struct timespec release_data_end_time;
81
83 struct timespec callback_start_time;
85 struct timespec callback_end_time;
86
87 /* TODO add expected length, expected start/end ? */
88
91
93 uint64_t used_cycles;
95 uint64_t stall_cycles;
98
99#ifdef STARPU_PAPI
101 long long int papi_values[PAPI_MAX_HWCTRS];
102 int papi_event_set;
103#endif
104};
105
117{
119 struct timespec start_time;
121 struct timespec total_time;
122
124 struct timespec executing_time;
127 struct timespec callback_time;
131 struct timespec waiting_time;
135 struct timespec sleeping_time;
139 struct timespec scheduling_time;
140
143 struct timespec all_executing_time;
146 struct timespec all_callback_time;
149 struct timespec all_waiting_time;
152 struct timespec all_sleeping_time;
155 struct timespec all_scheduling_time;
156
159
161 uint64_t used_cycles;
163 uint64_t stall_cycles;
166
167 /* TODO: add wasted time due to failed tasks */
168
169 double flops;
170};
171
173{
175 struct timespec start_time;
177 struct timespec total_time;
179 int long long transferred_bytes;
182};
183
190
195void starpu_profiling_set_id(int new_id);
196
209
216
217#ifdef BUILDING_STARPU
218#include <common/utils.h>
219#ifdef __GNUC__
220extern int _starpu_profiling;
221#define starpu_profiling_status_get() ( \
222 { \
223 int __ret; \
224 ANNOTATE_HAPPENS_AFTER(&_starpu_profiling); \
225 __ret = _starpu_profiling; \
226 ANNOTATE_HAPPENS_BEFORE(&_starpu_profiling); \
227 __ret; \
228 })
229#endif
230#endif
231
241
247
252int starpu_bus_get_id(int src, int dst);
253
258int starpu_bus_get_src(int busid);
259
264int starpu_bus_get_dst(int busid);
268void starpu_bus_set_direct(int busid, int direct);
276void starpu_bus_set_ngpus(int busid, int ngpus);
280int starpu_bus_get_ngpus(int busid);
281
288
289/* Some helper functions to manipulate profiling API output */
290/* Reset timespec */
291static __starpu_inline void starpu_timespec_clear(struct timespec *tsp)
292{
293 tsp->tv_sec = 0;
294 tsp->tv_nsec = 0;
295}
296
297#define STARPU_NS_PER_S 1000000000
298
299/* Computes result = a + b */
300static __starpu_inline void starpu_timespec_add(struct timespec *a,
301 struct timespec *b,
302 struct timespec *result)
303{
304 result->tv_sec = a->tv_sec + b->tv_sec;
305 result->tv_nsec = a->tv_nsec + b->tv_nsec;
306
307 if (result->tv_nsec >= STARPU_NS_PER_S)
308 {
309 ++(result)->tv_sec;
310 result->tv_nsec -= STARPU_NS_PER_S;
311 }
312}
313
314/* Computes res += b */
315static __starpu_inline void starpu_timespec_accumulate(struct timespec *result,
316 struct timespec *a)
317{
318 result->tv_sec += a->tv_sec;
319 result->tv_nsec += a->tv_nsec;
320
321 if (result->tv_nsec >= STARPU_NS_PER_S)
322 {
323 ++(result)->tv_sec;
324 result->tv_nsec -= STARPU_NS_PER_S;
325 }
326}
327
328/* Computes result = a - b */
329static __starpu_inline void starpu_timespec_sub(const struct timespec *a,
330 const struct timespec *b,
331 struct timespec *result)
332{
333 result->tv_sec = a->tv_sec - b->tv_sec;
334 result->tv_nsec = a->tv_nsec - b->tv_nsec;
335
336 if ((result)->tv_nsec < 0)
337 {
338 --(result)->tv_sec;
339 result->tv_nsec += STARPU_NS_PER_S;
340 }
341}
342
343#define starpu_timespec_cmp(a, b, CMP) \
344 (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_nsec CMP(b)->tv_nsec) : ((a)->tv_sec CMP(b)->tv_sec))
345
350double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end);
351
356double starpu_timing_timespec_to_us(struct timespec *ts);
357
365
373
382
385#ifdef __cplusplus
386}
387#endif
388
389#endif /* __STARPU_PROFILING_H__ */
int long long transferred_bytes
Definition starpu_profiling.h:179
struct timespec executing_time
Definition starpu_profiling.h:124
struct timespec acquire_data_end_time
Definition starpu_profiling.h:70
struct timespec waiting_time
Definition starpu_profiling.h:131
int workerid
Definition starpu_profiling.h:90
uint64_t stall_cycles
Definition starpu_profiling.h:163
struct timespec all_waiting_time
Definition starpu_profiling.h:149
struct timespec callback_end_time
Definition starpu_profiling.h:85
int transfer_count
Definition starpu_profiling.h:181
struct timespec submit_time
Definition starpu_profiling.h:56
struct timespec total_time
Definition starpu_profiling.h:177
struct timespec callback_start_time
Definition starpu_profiling.h:83
struct timespec all_scheduling_time
Definition starpu_profiling.h:155
double energy_consumed
Definition starpu_profiling.h:165
struct timespec pop_start_time
Definition starpu_profiling.h:63
struct timespec all_callback_time
Definition starpu_profiling.h:146
uint64_t used_cycles
Definition starpu_profiling.h:161
struct timespec push_end_time
Definition starpu_profiling.h:61
struct timespec all_executing_time
Definition starpu_profiling.h:143
double energy_consumed
Definition starpu_profiling.h:97
int executed_tasks
Definition starpu_profiling.h:158
uint64_t stall_cycles
Definition starpu_profiling.h:95
struct timespec start_time
Definition starpu_profiling.h:175
struct timespec callback_time
Definition starpu_profiling.h:127
struct timespec all_sleeping_time
Definition starpu_profiling.h:152
struct timespec acquire_data_start_time
Definition starpu_profiling.h:68
struct timespec release_data_end_time
Definition starpu_profiling.h:80
struct timespec pop_end_time
Definition starpu_profiling.h:65
struct timespec push_start_time
Definition starpu_profiling.h:59
struct timespec total_time
Definition starpu_profiling.h:121
struct timespec release_data_start_time
Definition starpu_profiling.h:78
struct timespec start_time
Definition starpu_profiling.h:73
struct timespec sleeping_time
Definition starpu_profiling.h:135
struct timespec scheduling_time
Definition starpu_profiling.h:139
struct timespec end_time
Definition starpu_profiling.h:75
uint64_t used_cycles
Definition starpu_profiling.h:93
struct timespec start_time
Definition starpu_profiling.h:119
void starpu_profiling_worker_helper_display_summary(void)
void starpu_profiling_bus_helper_display_summary(void)
void starpu_profiling_init(void)
int starpu_bus_get_profiling_info(int busid, struct starpu_profiling_bus_info *bus_info)
int starpu_bus_get_id(int src, int dst)
int starpu_bus_get_src(int busid)
double starpu_timing_timespec_to_us(struct timespec *ts)
int starpu_profiling_worker_get_info(int workerid, struct starpu_profiling_worker_info *worker_info)
int starpu_bus_get_direct(int busid)
int starpu_bus_get_count(void)
int starpu_bus_get_dst(int busid)
void starpu_data_display_memory_stats(void)
int starpu_bus_get_ngpus(int busid)
void starpu_bus_set_direct(int busid, int direct)
int starpu_profiling_status_set(int status)
double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end)
void starpu_profiling_set_id(int new_id)
void starpu_bus_set_ngpus(int busid, int ngpus)
int starpu_profiling_status_get(void)
Definition starpu_profiling.h:173
Definition starpu_profiling.h:54
Definition starpu_profiling.h:117