StarPU Handbook - StarPU Introduction
starpu_profiling.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) 2020-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#include <starpu.h>
19
20#ifndef __STARPU_PROFILING_H__
21#define __STARPU_PROFILING_H__
22
23#include <errno.h>
24#include <time.h>
25
26#include <starpu_config.h>
27
28#ifdef STARPU_PAPI
29#include <papi.h>
30#endif
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
44#define STARPU_PROFILING_DISABLE 0
48#define STARPU_PROFILING_ENABLE 1
49
55{
57 struct timespec submit_time;
58
60 struct timespec push_start_time;
62 struct timespec push_end_time;
64 struct timespec pop_start_time;
66 struct timespec pop_end_time;
67
69 struct timespec acquire_data_start_time;
71 struct timespec acquire_data_end_time;
72
74 struct timespec start_time;
76 struct timespec end_time;
77
79 struct timespec release_data_start_time;
81 struct timespec release_data_end_time;
82
84 struct timespec callback_start_time;
86 struct timespec callback_end_time;
87
88 /* TODO add expected length, expected start/end ? */
89
92
94 uint64_t used_cycles;
96 uint64_t stall_cycles;
99
100#ifdef STARPU_PAPI
102 long long int papi_values[PAPI_MAX_HWCTRS];
103 int papi_event_set;
104#endif
105};
106
118{
120 struct timespec start_time;
122 struct timespec total_time;
123
125 struct timespec executing_time;
128 struct timespec callback_time;
132 struct timespec waiting_time;
136 struct timespec sleeping_time;
140 struct timespec scheduling_time;
141
144 struct timespec all_executing_time;
147 struct timespec all_callback_time;
150 struct timespec all_waiting_time;
153 struct timespec all_sleeping_time;
156 struct timespec all_scheduling_time;
157
160
162 uint64_t used_cycles;
164 uint64_t stall_cycles;
167
168 /* TODO: add wasted time due to failed tasks */
169
170 double flops;
171};
172
177{
179 struct timespec start_time;
181 struct timespec total_time;
183 int long long transferred_bytes;
186};
187
194
199void starpu_profiling_set_id(int new_id);
200
213
220
221#ifdef BUILDING_STARPU
222#include <common/utils.h>
223#ifdef __GNUC__
224extern int _starpu_profiling;
225#define starpu_profiling_status_get() ( \
226 { \
227 int __ret; \
228 ANNOTATE_HAPPENS_AFTER(&_starpu_profiling); \
229 __ret = _starpu_profiling; \
230 ANNOTATE_HAPPENS_BEFORE(&_starpu_profiling); \
231 __ret; \
232 })
233#endif
234#endif
235
245
251
256int starpu_bus_get_id(int src, int dst);
257
262int starpu_bus_get_src(int busid);
263
268int starpu_bus_get_dst(int busid);
272void starpu_bus_set_direct(int busid, int direct);
280void starpu_bus_set_ngpus(int busid, int ngpus);
284int starpu_bus_get_ngpus(int busid);
285
292
293/* Some helper functions to manipulate profiling API output */
294/* Reset timespec */
295static __starpu_inline void starpu_timespec_clear(struct timespec *tsp)
296{
297 tsp->tv_sec = 0;
298 tsp->tv_nsec = 0;
299}
300
301#define STARPU_NS_PER_S 1000000000
302
303/* Computes result = a + b */
304static __starpu_inline void starpu_timespec_add(struct timespec *a,
305 struct timespec *b,
306 struct timespec *result)
307{
308 result->tv_sec = a->tv_sec + b->tv_sec;
309 result->tv_nsec = a->tv_nsec + b->tv_nsec;
310
311 if (result->tv_nsec >= STARPU_NS_PER_S)
312 {
313 ++(result)->tv_sec;
314 result->tv_nsec -= STARPU_NS_PER_S;
315 }
316}
317
318/* Computes res += b */
319static __starpu_inline void starpu_timespec_accumulate(struct timespec *result,
320 struct timespec *a)
321{
322 result->tv_sec += a->tv_sec;
323 result->tv_nsec += a->tv_nsec;
324
325 if (result->tv_nsec >= STARPU_NS_PER_S)
326 {
327 ++(result)->tv_sec;
328 result->tv_nsec -= STARPU_NS_PER_S;
329 }
330}
331
332/* Computes result = a - b */
333static __starpu_inline void starpu_timespec_sub(const struct timespec *a,
334 const struct timespec *b,
335 struct timespec *result)
336{
337 result->tv_sec = a->tv_sec - b->tv_sec;
338 result->tv_nsec = a->tv_nsec - b->tv_nsec;
339
340 if ((result)->tv_nsec < 0)
341 {
342 --(result)->tv_sec;
343 result->tv_nsec += STARPU_NS_PER_S;
344 }
345}
346
347#define starpu_timespec_cmp(a, b, CMP) \
348 (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_nsec CMP(b)->tv_nsec) : ((a)->tv_sec CMP(b)->tv_sec))
349
354double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end);
355
360double starpu_timing_timespec_to_us(struct timespec *ts);
361
369
377
386
389#ifdef __cplusplus
390}
391#endif
392
393#endif /* __STARPU_PROFILING_H__ */
int long long transferred_bytes
Definition: starpu_profiling.h:183
struct timespec executing_time
Definition: starpu_profiling.h:125
struct timespec acquire_data_end_time
Definition: starpu_profiling.h:71
struct timespec waiting_time
Definition: starpu_profiling.h:132
int workerid
Definition: starpu_profiling.h:91
uint64_t stall_cycles
Definition: starpu_profiling.h:164
struct timespec all_waiting_time
Definition: starpu_profiling.h:150
struct timespec callback_end_time
Definition: starpu_profiling.h:86
int transfer_count
Definition: starpu_profiling.h:185
struct timespec submit_time
Definition: starpu_profiling.h:57
struct timespec total_time
Definition: starpu_profiling.h:181
struct timespec callback_start_time
Definition: starpu_profiling.h:84
struct timespec all_scheduling_time
Definition: starpu_profiling.h:156
double energy_consumed
Definition: starpu_profiling.h:166
struct timespec pop_start_time
Definition: starpu_profiling.h:64
struct timespec all_callback_time
Definition: starpu_profiling.h:147
uint64_t used_cycles
Definition: starpu_profiling.h:162
struct timespec push_end_time
Definition: starpu_profiling.h:62
struct timespec all_executing_time
Definition: starpu_profiling.h:144
double energy_consumed
Definition: starpu_profiling.h:98
int executed_tasks
Definition: starpu_profiling.h:159
uint64_t stall_cycles
Definition: starpu_profiling.h:96
struct timespec start_time
Definition: starpu_profiling.h:179
struct timespec callback_time
Definition: starpu_profiling.h:128
struct timespec all_sleeping_time
Definition: starpu_profiling.h:153
struct timespec acquire_data_start_time
Definition: starpu_profiling.h:69
struct timespec release_data_end_time
Definition: starpu_profiling.h:81
struct timespec pop_end_time
Definition: starpu_profiling.h:66
struct timespec push_start_time
Definition: starpu_profiling.h:60
struct timespec total_time
Definition: starpu_profiling.h:122
struct timespec release_data_start_time
Definition: starpu_profiling.h:79
struct timespec start_time
Definition: starpu_profiling.h:74
struct timespec sleeping_time
Definition: starpu_profiling.h:136
struct timespec scheduling_time
Definition: starpu_profiling.h:140
struct timespec end_time
Definition: starpu_profiling.h:76
uint64_t used_cycles
Definition: starpu_profiling.h:94
struct timespec start_time
Definition: starpu_profiling.h:120
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:177
Definition: starpu_profiling.h:55
Definition: starpu_profiling.h:118