StarPU Internal Handbook

debug.h
Go to the documentation of this file.
1/* StarPU --- Runtime system for heterogeneous multicore architectures.
2 *
3 * Copyright (C) 2009-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
4 *
5 * StarPU is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation; either version 2.1 of the License, or (at
8 * your option) any later version.
9 *
10 * StarPU is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 *
14 * See the GNU Lesser General Public License in COPYING.LGPL for more details.
15 */
16
17#ifndef __DEBUG_H__
18#define __DEBUG_H__
19
22#include <stdio.h>
23#include <stdlib.h>
24#include <stdarg.h>
25
26#include <common/config.h>
27#include <core/workers.h>
28
29#if defined(STARPU_USE_AYUDAME1)
30/* Ayudame 1 API */
31# include <Ayudame.h>
32# ifndef AYU_RT_STARPU
33# define AYU_RT_STARPU 4
34# endif
35# define STARPU_AYU_EVENT AYU_event
36
37# define STARPU_AYU_PREINIT() \
38 if (AYU_event) \
39 { \
40 enum ayu_runtime_t ayu_rt = AYU_RT_STARPU; \
41 AYU_event(AYU_PREINIT, 0, (void*) &ayu_rt); \
42 }
43
44# define STARPU_AYU_INIT() \
45 if (AYU_event) \
46 { \
47 AYU_event(AYU_INIT, 0, NULL); \
48 }
49
50# define STARPU_AYU_FINISH() \
51 if (AYU_event) \
52 { \
53 AYU_event(AYU_FINISH, 0, NULL); \
54 }
55
56# define STARPU_AYU_ADDDEPENDENCY(previous, handle, job_id) \
57 if (AYU_event) \
58 { \
59 uintptr_t __AYU_data[3] = { (previous), (uintptr_t) (handle), (uintptr_t) (handle) }; \
60 AYU_event(AYU_ADDDEPENDENCY, (job_id), __AYU_data); \
61 }
62
63# define STARPU_AYU_REMOVETASK(job_id) \
64 if (AYU_event) \
65 { \
66 AYU_event(AYU_REMOVETASK, (job_id), NULL); \
67 }
68
69# define STARPU_AYU_ADDTASK(job_id, task) \
70 if (AYU_event) \
71 { \
72 int64_t __AYU_data[2] = { \
73 ((struct starpu_task *)(task))!=NULL?_starpu_ayudame_get_func_id(((struct starpu_task *)(task))->cl):0, \
74 ((struct starpu_task *)(task))!=NULL?((struct starpu_task *)(task))->priority-STARPU_MIN_PRIO:0 \
75 }; \
76 AYU_event(AYU_ADDTASK, (job_id), __AYU_data); \
77 }
78
79# define STARPU_AYU_PRERUNTASK(job_id, workerid) \
80 if (AYU_event) \
81 { \
82 intptr_t __id = (workerid); \
83 AYU_event(AYU_PRERUNTASK, (job_id), &__id); \
84 }
85
86# define STARPU_AYU_RUNTASK(job_id) \
87 if (AYU_event) \
88 { \
89 AYU_event(AYU_RUNTASK, (job_id), NULL); \
90 }
91
92# define STARPU_AYU_POSTRUNTASK(job_id) \
93 if (AYU_event) \
94 { \
95 AYU_event(AYU_POSTRUNTASK, (job_id), NULL); \
96 }
97
98# define STARPU_AYU_ADDTOTASKQUEUE(job_id, worker_id) \
99 if (AYU_event) \
100 { \
101 intptr_t __id = (worker_id); \
102 AYU_event(AYU_ADDTASKTOQUEUE, (job_id), &__id); \
103 }
104
105# define STARPU_AYU_BARRIER() \
106 if (AYU_event) \
107 { \
108 AYU_event(AYU_BARRIER, 0, NULL); \
109 }
110
111#elif defined(STARPU_USE_AYUDAME2)
112/* Ayudame 2 API */
113# include <ayudame.h>
114# define STARPU_AYU_EVENT ayu_event
115
116# define STARPU_AYU_PREINIT()
117
118# define STARPU_AYU_INIT()
119
120# define STARPU_AYU_FINISH() \
121 if (ayu_event){ \
122 ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
123 ayu_event_data_t __data; \
124 __data.common.client_id = __cli_id; \
125 ayu_event(AYU_FINISH, __data); \
126 }
127
128# define STARPU_AYU_ADDDEPENDENCY(previous, handle, job_id) \
129 if (ayu_event) \
130 { \
131 ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
132 ayu_event_data_t __data; \
133 uint64_t __dep_id=0; \
134 __dep_id |= (previous) << 0; \
135 __dep_id |= (job_id) << 24; \
136 __dep_id |= (uintptr_t) (handle) << 48; \
137 __data.common.client_id = __cli_id; \
138 __data.add_dependency.dependency_id = __dep_id; \
139 __data.add_dependency.from_id=(previous); \
140 __data.add_dependency.to_id=(job_id); \
141 __data.add_dependency.dependency_label = "dep"; \
142 ayu_event(AYU_ADDDEPENDENCY, __data); \
143 ayu_wipe_data(&__data); \
144 \
145 char __buf[32]; \
146 snprintf(__buf, sizeof(__buf), "%llu", (unsigned long long)(uintptr_t) (handle)); \
147 __data.common.client_id = __cli_id; \
148 __data.set_property.property_owner_id = __dep_id; \
149 __data.set_property.key = "dep_address_value"; \
150 __data.set_property.value = __buf; \
151 ayu_event(AYU_SETPROPERTY, __data); \
152 ayu_wipe_data(&__data); \
153 }
154
155# define STARPU_AYU_REMOVETASK(job_id) \
156 if (ayu_event) \
157 { \
158 ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
159 ayu_event_data_t __data; \
160 __data.common.client_id = __cli_id; \
161 __data.set_property.property_owner_id = (job_id); \
162 __data.set_property.key = "state"; \
163 __data.set_property.value = "finished"; \
164 ayu_event(AYU_SETPROPERTY, __data); \
165 ayu_wipe_data(&__data); \
166 }
167
168# define STARPU_AYU_ADDTASK(job_id, task) \
169 if (ayu_event) \
170 { \
171 ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
172 ayu_event_data_t __data; \
173 __data.common.client_id = __cli_id; \
174 __data.add_task.task_id = (job_id); \
175 __data.add_task.scope_id = 0; \
176 __data.add_task.task_label = "task"; \
177 ayu_event(AYU_ADDTASK, __data); \
178 ayu_wipe_data(&__data); \
179 \
180 if ((task) != NULL) \
181 { \
182 char __buf[32]; \
183 snprintf(__buf, sizeof(__buf), "%d", ((struct starpu_task *)(task))->priority); \
184 __data.common.client_id = __cli_id; \
185 __data.set_property.property_owner_id = (job_id); \
186 __data.set_property.key = "priority"; \
187 __data.set_property.value = __buf; \
188 ayu_event(AYU_SETPROPERTY, __data); \
189 ayu_wipe_data(&__data); \
190 \
191 const char *__name = ((struct starpu_task *)(task))->name != NULL?((struct starpu_task *)(task))->name: \
192 ((struct starpu_task *)(task))->cl->name != NULL?((struct starpu_task *)(task))->cl->name:"<no_name>"; \
193 __data.common.client_id = __cli_id; \
194 __data.set_property.property_owner_id = (job_id); \
195 __data.set_property.key = "function_name"; \
196 __data.set_property.value = __name; \
197 ayu_event(AYU_SETPROPERTY, __data); \
198 ayu_wipe_data(&__data); \
199 } \
200 }
201
202# define STARPU_AYU_PRERUNTASK(job_id, workerid) \
203 if (ayu_event) \
204 { \
205 ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
206 ayu_event_data_t __data; \
207 __data.common.client_id = __cli_id; \
208 __data.set_property.property_owner_id = (job_id); \
209 __data.set_property.key = "state"; \
210 __data.set_property.value = "running"; \
211 ayu_event(AYU_SETPROPERTY, __data); \
212 ayu_wipe_data(&__data); \
213 \
214 char __buf[32]; \
215 snprintf(__buf, sizeof(__buf), "%d", (workerid)); \
216 __data.common.client_id = __cli_id; \
217 __data.set_property.property_owner_id = (job_id); \
218 __data.set_property.key = "worker"; \
219 __data.set_property.value = __buf; \
220 ayu_event(AYU_SETPROPERTY, __data); \
221 ayu_wipe_data(&__data); \
222 }
223
224# define STARPU_AYU_RUNTASK(job_id) \
225 if (ayu_event) { \
226 ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
227 ayu_event_data_t __data; \
228 __data.common.client_id = __cli_id; \
229 __data.set_property.property_owner_id = (job_id); \
230 __data.set_property.key = "state"; \
231 __data.set_property.value = "running"; \
232 ayu_event(AYU_SETPROPERTY, __data); \
233 ayu_wipe_data(&__data); \
234 }
235
236# define STARPU_AYU_POSTRUNTASK(job_id) \
237 if (ayu_event) \
238 { \
239 /* TODO ADD thread id core id etc */ \
240 ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
241 ayu_event_data_t __data; \
242 __data.common.client_id = __cli_id; \
243 __data.set_property.property_owner_id = (job_id); \
244 __data.set_property.key = "state"; \
245 __data.set_property.value = "finished"; \
246 ayu_event(AYU_SETPROPERTY, __data); \
247 ayu_wipe_data(&__data); \
248 }
249
250# define STARPU_AYU_ADDTOTASKQUEUE(job_id, worker_id) \
251 if (ayu_event) \
252 { \
253 ayu_client_id_t __cli_id = get_client_id(AYU_CLIENT_STARPU); \
254 ayu_event_data_t __data; \
255 __data.common.client_id = __cli_id; \
256 __data.set_property.property_owner_id = (job_id); \
257 __data.set_property.key = "state"; \
258 __data.set_property.value = "queued"; \
259 ayu_event(AYU_SETPROPERTY, __data); \
260 ayu_wipe_data(&__data); \
261 \
262 char __buf[32]; \
263 snprintf(__buf, sizeof(__buf), "%d", (int)(worker_id)); \
264 __data.common.client_id = __cli_id; \
265 __data.set_property.property_owner_id = (job_id); \
266 __data.set_property.key = "worker"; \
267 __data.set_property.value = __buf; \
268 ayu_event(AYU_SETPROPERTY, __data); \
269 ayu_wipe_data(&__data); \
270 }
271
272# define STARPU_AYU_BARRIER() \
273 if (ayu_event) \
274 { \
275 /* How to generate a barrier event with Ayudame 2? */ \
276 }
277#else
278# define STARPU_AYU_EVENT (0)
279# define STARPU_AYU_PREINIT()
280# define STARPU_AYU_INIT()
281# define STARPU_AYU_FINISH()
282# define STARPU_AYU_ADDDEPENDENCY(previous, handle, next_job)
283# define STARPU_AYU_REMOVETASK(job_id)
284# define STARPU_AYU_ADDTASK(job_id, task)
285# define STARPU_AYU_PRERUNTASK(job_id, workerid)
286# define STARPU_AYU_RUNTASK(job_id)
287# define STARPU_AYU_POSTRUNTASK(job_id)
288# define STARPU_AYU_ADDTOTASKQUEUE(job_id, worker_id)
289# define STARPU_AYU_BARRIER()
290
291#endif
292
294 void _starpu_open_debug_logfile(void);
295
297 void _starpu_close_debug_logfile(void);
298
300 void _starpu_print_to_logfile(const char *format, ...) STARPU_ATTRIBUTE_FORMAT(printf, 1, 2);
301
303extern int _starpu_use_fxt;
304
305#if defined(STARPU_USE_AYUDAME1)
307int64_t _starpu_ayudame_get_func_id(struct starpu_codelet *cl);
308#endif
309
310 void _starpu_watchdog_init(void);
311 void _starpu_watchdog_shutdown(void);
312
313#endif // __DEBUG_H__
_starpu_use_fxt
void int _starpu_use_fxt
_starpu_print_to_logfile
void _starpu_print_to_logfile(const char *format,...) STARPU_ATTRIBUTE_FORMAT(printf
_starpu_close_debug_logfile
void _starpu_close_debug_logfile(void)
_starpu_open_debug_logfile
void _starpu_open_debug_logfile(void)