StarPU Handbook
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
starpu_profiling.h
Go to the documentation of this file.
1 /* StarPU --- Runtime system for heterogeneous multicore architectures.
2  *
3  * Copyright (C) 2010-2014 Université de Bordeaux 1
4  * Copyright (C) 2010, 2011, 2013 Centre National de la Recherche Scientifique
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 #include <starpu_util.h>
25 
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30 
31 #define STARPU_PROFILING_DISABLE 0
32 #define STARPU_PROFILING_ENABLE 1
33 
35 {
36  struct timespec submit_time;
37 
38  struct timespec push_start_time;
39  struct timespec push_end_time;
40  struct timespec pop_start_time;
41  struct timespec pop_end_time;
42 
43  struct timespec acquire_data_start_time;
44  struct timespec acquire_data_end_time;
45 
46  struct timespec start_time;
47  struct timespec end_time;
48 
49  struct timespec release_data_start_time;
50  struct timespec release_data_end_time;
51 
52  struct timespec callback_start_time;
53  struct timespec callback_end_time;
54 
55  /* TODO add expected length, expected start/end ? */
56  int workerid;
57 
58  uint64_t used_cycles;
59  uint64_t stall_cycles;
61 };
62 
64 {
65  struct timespec start_time;
66  struct timespec total_time;
67  struct timespec executing_time;
68  struct timespec sleeping_time;
70 
71  uint64_t used_cycles;
72  uint64_t stall_cycles;
74 };
75 
77 {
78  struct timespec start_time;
79  struct timespec total_time;
80  int long long transferred_bytes;
82 };
83 
85 void starpu_profiling_set_id(int new_id);
86 int starpu_profiling_status_set(int status);
88 
89 #ifdef BUILDING_STARPU
90 #include <common/utils.h>
91 #ifdef __GNUC__
92 extern int _starpu_profiling;
93 #define starpu_profiling_status_get() ({ \
94  int __ret; \
95  ANNOTATE_HAPPENS_AFTER(&_starpu_profiling); \
96  __ret = _starpu_profiling; \
97  ANNOTATE_HAPPENS_BEFORE(&_starpu_profiling); \
98  __ret; \
99 })
100 #endif
101 #endif
102 
103 int starpu_profiling_worker_get_info(int workerid, struct starpu_profiling_worker_info *worker_info);
104 
105 int starpu_bus_get_count(void);
106 int starpu_bus_get_id(int src, int dst);
107 int starpu_bus_get_src(int busid);
108 int starpu_bus_get_dst(int busid);
109 
110 int starpu_bus_get_profiling_info(int busid, struct starpu_profiling_bus_info *bus_info);
111 
112 /* Some helper functions to manipulate profiling API output */
113 /* Reset timespec */
114 static __starpu_inline void starpu_timespec_clear(struct timespec *tsp)
115 {
116  tsp->tv_sec = 0;
117  tsp->tv_nsec = 0;
118 }
119 
120 /* Computes result = a + b */
121 static __starpu_inline void starpu_timespec_add(struct timespec *a,
122  struct timespec *b,
123  struct timespec *result)
124 {
125  result->tv_sec = a->tv_sec + b->tv_sec;
126  result->tv_nsec = a->tv_nsec + b->tv_nsec;
127 
128  if (result->tv_nsec >= 1000000000)
129  {
130  ++(result)->tv_sec;
131  result->tv_nsec -= 1000000000;
132  }
133 }
134 
135 /* Computes res += b */
136 static __starpu_inline void starpu_timespec_accumulate(struct timespec *result,
137  struct timespec *a)
138 {
139  result->tv_sec += a->tv_sec;
140  result->tv_nsec += a->tv_nsec;
141 
142  if (result->tv_nsec >= 1000000000)
143  {
144  ++(result)->tv_sec;
145  result->tv_nsec -= 1000000000;
146  }
147 }
148 
149 /* Computes result = a - b */
150 static __starpu_inline void starpu_timespec_sub(const struct timespec *a,
151  const struct timespec *b,
152  struct timespec *result)
153 {
154  result->tv_sec = a->tv_sec - b->tv_sec;
155  result->tv_nsec = a->tv_nsec - b->tv_nsec;
156 
157  if ((result)->tv_nsec < 0)
158  {
159  --(result)->tv_sec;
160  result->tv_nsec += 1000000000;
161  }
162 }
163 
164 #define starpu_timespec_cmp(a, b, CMP) \
165  (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_nsec CMP (b)->tv_nsec) : ((a)->tv_sec CMP (b)->tv_sec))
166 
167 double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end);
168 double starpu_timing_timespec_to_us(struct timespec *ts);
169 
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif /* __STARPU_PROFILING_H__ */
Definition: starpu_profiling.h:34
struct timespec acquire_data_start_time
Definition: starpu_profiling.h:43
struct timespec total_time
Definition: starpu_profiling.h:79
struct timespec start_time
Definition: starpu_profiling.h:46
int starpu_bus_get_src(int busid)
struct timespec start_time
Definition: starpu_profiling.h:65
void starpu_profiling_bus_helper_display_summary(void)
int starpu_bus_get_profiling_info(int busid, struct starpu_profiling_bus_info *bus_info)
int executed_tasks
Definition: starpu_profiling.h:69
struct timespec acquire_data_end_time
Definition: starpu_profiling.h:44
uint64_t used_cycles
Definition: starpu_profiling.h:58
double power_consumed
Definition: starpu_profiling.h:60
struct timespec pop_start_time
Definition: starpu_profiling.h:40
uint64_t used_cycles
Definition: starpu_profiling.h:71
uint64_t stall_cycles
Definition: starpu_profiling.h:72
int transfer_count
Definition: starpu_profiling.h:81
struct timespec push_start_time
Definition: starpu_profiling.h:38
struct timespec callback_end_time
Definition: starpu_profiling.h:53
struct timespec release_data_start_time
Definition: starpu_profiling.h:49
struct timespec sleeping_time
Definition: starpu_profiling.h:68
struct timespec total_time
Definition: starpu_profiling.h:66
struct timespec executing_time
Definition: starpu_profiling.h:67
struct timespec submit_time
Definition: starpu_profiling.h:36
double power_consumed
Definition: starpu_profiling.h:73
struct timespec start_time
Definition: starpu_profiling.h:78
void starpu_profiling_init()
int starpu_bus_get_dst(int busid)
struct timespec pop_end_time
Definition: starpu_profiling.h:41
void starpu_profiling_worker_helper_display_summary(void)
double starpu_timing_timespec_to_us(struct timespec *ts)
struct timespec callback_start_time
Definition: starpu_profiling.h:52
double starpu_timing_timespec_delay_us(struct timespec *start, struct timespec *end)
uint64_t stall_cycles
Definition: starpu_profiling.h:59
Definition: starpu_profiling.h:63
int workerid
Definition: starpu_profiling.h:56
int starpu_profiling_status_set(int status)
void starpu_profiling_set_id(int new_id)
struct timespec push_end_time
Definition: starpu_profiling.h:39
struct timespec release_data_end_time
Definition: starpu_profiling.h:50
int starpu_bus_get_count(void)
Definition: starpu_profiling.h:76
int starpu_profiling_status_get(void)
int starpu_bus_get_id(int src, int dst)
int starpu_profiling_worker_get_info(int workerid, struct starpu_profiling_worker_info *worker_info)
struct timespec end_time
Definition: starpu_profiling.h:47
int long long transferred_bytes
Definition: starpu_profiling.h:80