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-2014,2016,2017 Université de Bordeaux
4  * Copyright (C) 2010,2011,2013,2015,2017,2019 CNRS
5  * Copyright (C) 2016 Inria
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_PROFILING_H__
20 #define __STARPU_PROFILING_H__
21 
22 #include <starpu.h>
23 #include <errno.h>
24 #include <time.h>
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
39 #define STARPU_PROFILING_DISABLE 0
40 
43 #define STARPU_PROFILING_ENABLE 1
44 
50 {
52  struct timespec submit_time;
53 
55  struct timespec push_start_time;
57  struct timespec push_end_time;
59  struct timespec pop_start_time;
61  struct timespec pop_end_time;
62 
64  struct timespec acquire_data_start_time;
66  struct timespec acquire_data_end_time;
67 
69  struct timespec start_time;
71  struct timespec end_time;
72 
74  struct timespec release_data_start_time;
76  struct timespec release_data_end_time;
77 
79  struct timespec callback_start_time;
81  struct timespec callback_end_time;
82 
83  /* TODO add expected length, expected start/end ? */
84 
86  int workerid;
87 
89  uint64_t used_cycles;
91  uint64_t stall_cycles;
94 };
95 
102 {
104  struct timespec start_time;
106  struct timespec total_time;
108  struct timespec executing_time;
110  struct timespec sleeping_time;
113 
115  uint64_t used_cycles;
117  uint64_t stall_cycles;
120 
121  double flops;
122 };
123 
125 {
127  struct timespec start_time;
129  struct timespec total_time;
131  int long long transferred_bytes;
134 };
135 
140 void starpu_profiling_init(void);
141 
145 void starpu_profiling_set_id(int new_id);
146 
157 int starpu_profiling_status_set(int status);
158 
164 
165 #ifdef BUILDING_STARPU
166 #include <common/utils.h>
167 #ifdef __GNUC__
168 extern int _starpu_profiling;
169 #define starpu_profiling_status_get() ({ \
170  int __ret; \
171  ANNOTATE_HAPPENS_AFTER(&_starpu_profiling); \
172  __ret = _starpu_profiling; \
173  ANNOTATE_HAPPENS_BEFORE(&_starpu_profiling); \
174  __ret; \
175 })
176 #endif
177 #endif
178 
187 
191 int starpu_bus_get_count(void);
192 
196 int starpu_bus_get_id(int src, int dst);
197 
201 int starpu_bus_get_src(int busid);
202 
206 int starpu_bus_get_dst(int busid);
207 void starpu_bus_set_direct(int busid, int direct);
208 int starpu_bus_get_direct(int busid);
209 void starpu_bus_set_ngpus(int busid, int ngpus);
210 int starpu_bus_get_ngpus(int busid);
211 
216 int starpu_bus_get_profiling_info(int busid, struct starpu_profiling_bus_info *bus_info);
217 
218 /* Some helper functions to manipulate profiling API output */
219 /* Reset timespec */
220 static __starpu_inline void starpu_timespec_clear(struct timespec *tsp)
221 {
222  tsp->tv_sec = 0;
223  tsp->tv_nsec = 0;
224 }
225 
226 #define STARPU_NS_PER_S 1000000000
227 
228 /* Computes result = a + b */
229 static __starpu_inline void starpu_timespec_add(struct timespec *a,
230  struct timespec *b,
231  struct timespec *result)
232 {
233  result->tv_sec = a->tv_sec + b->tv_sec;
234  result->tv_nsec = a->tv_nsec + b->tv_nsec;
235 
236  if (result->tv_nsec >= STARPU_NS_PER_S)
237  {
238  ++(result)->tv_sec;
239  result->tv_nsec -= STARPU_NS_PER_S;
240  }
241 }
242 
243 /* Computes res += b */
244 static __starpu_inline void starpu_timespec_accumulate(struct timespec *result,
245  struct timespec *a)
246 {
247  result->tv_sec += a->tv_sec;
248  result->tv_nsec += a->tv_nsec;
249 
250  if (result->tv_nsec >= STARPU_NS_PER_S)
251  {
252  ++(result)->tv_sec;
253  result->tv_nsec -= STARPU_NS_PER_S;
254  }
255 }
256 
257 /* Computes result = a - b */
258 static __starpu_inline void starpu_timespec_sub(const struct timespec *a,
259  const struct timespec *b,
260  struct timespec *result)
261 {
262  result->tv_sec = a->tv_sec - b->tv_sec;
263  result->tv_nsec = a->tv_nsec - b->tv_nsec;
264 
265  if ((result)->tv_nsec < 0)
266  {
267  --(result)->tv_sec;
268  result->tv_nsec += STARPU_NS_PER_S;
269  }
270 }
271 
272 #define starpu_timespec_cmp(a, b, CMP) \
273  (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_nsec CMP (b)->tv_nsec) : ((a)->tv_sec CMP (b)->tv_sec))
274 
278 double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end);
279 
283 double starpu_timing_timespec_to_us(struct timespec *ts);
284 
291 
298 
306 
309 #ifdef __cplusplus
310 }
311 #endif
312 
313 #endif /* __STARPU_PROFILING_H__ */
Definition: starpu_profiling.h:49
int executed_tasks
Definition: starpu_profiling.h:112
int starpu_bus_get_src(int busid)
void starpu_data_display_memory_stats()
void starpu_profiling_bus_helper_display_summary(void)
int starpu_bus_get_profiling_info(int busid, struct starpu_profiling_bus_info *bus_info)
struct timespec release_data_start_time
Definition: starpu_profiling.h:74
struct timespec pop_start_time
Definition: starpu_profiling.h:59
int long long transferred_bytes
Definition: starpu_profiling.h:131
struct timespec callback_end_time
Definition: starpu_profiling.h:81
int transfer_count
Definition: starpu_profiling.h:133
uint64_t used_cycles
Definition: starpu_profiling.h:115
struct timespec pop_end_time
Definition: starpu_profiling.h:61
struct timespec submit_time
Definition: starpu_profiling.h:52
void starpu_profiling_init(void)
struct timespec acquire_data_end_time
Definition: starpu_profiling.h:66
struct timespec acquire_data_start_time
Definition: starpu_profiling.h:64
int starpu_bus_get_dst(int busid)
void starpu_profiling_worker_helper_display_summary(void)
int workerid
Definition: starpu_profiling.h:86
double starpu_timing_timespec_to_us(struct timespec *ts)
struct timespec push_start_time
Definition: starpu_profiling.h:55
double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end)
Definition: starpu_profiling.h:101
uint64_t stall_cycles
Definition: starpu_profiling.h:91
int starpu_profiling_status_set(int status)
void starpu_profiling_set_id(int new_id)
struct timespec start_time
Definition: starpu_profiling.h:69
struct timespec release_data_end_time
Definition: starpu_profiling.h:76
double energy_consumed
Definition: starpu_profiling.h:119
uint64_t stall_cycles
Definition: starpu_profiling.h:117
int starpu_bus_get_count(void)
struct timespec callback_start_time
Definition: starpu_profiling.h:79
double energy_consumed
Definition: starpu_profiling.h:93
Definition: starpu_profiling.h:124
uint64_t used_cycles
Definition: starpu_profiling.h:89
int starpu_profiling_status_get(void)
struct timespec push_end_time
Definition: starpu_profiling.h:57
int starpu_bus_get_id(int src, int dst)
struct timespec end_time
Definition: starpu_profiling.h:71
int starpu_profiling_worker_get_info(int workerid, struct starpu_profiling_worker_info *worker_info)