fxt.h 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2009-2016 Université de Bordeaux
  4. * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2016 CNRS
  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. #ifndef __FXT_H__
  18. #define __FXT_H__
  19. #ifndef _GNU_SOURCE
  20. #define _GNU_SOURCE /* ou _BSD_SOURCE ou _SVID_SOURCE */
  21. #endif
  22. #include <string.h>
  23. #include <sys/types.h>
  24. #include <stdlib.h>
  25. #include <common/config.h>
  26. #ifdef HAVE_UNISTD_H
  27. #include <unistd.h>
  28. #endif
  29. #include <common/utils.h>
  30. #include <starpu.h>
  31. /* some key to identify the worker kind */
  32. #define _STARPU_FUT_APPS_KEY 0x100
  33. #define _STARPU_FUT_CPU_KEY 0x101
  34. #define _STARPU_FUT_CUDA_KEY 0x102
  35. #define _STARPU_FUT_OPENCL_KEY 0x103
  36. #define _STARPU_FUT_MIC_KEY 0x104
  37. #define _STARPU_FUT_SCC_KEY 0x105
  38. #define _STARPU_FUT_WORKER_INIT_START 0x5100
  39. #define _STARPU_FUT_WORKER_INIT_END 0x5101
  40. #define _STARPU_FUT_START_CODELET_BODY 0x5102
  41. #define _STARPU_FUT_END_CODELET_BODY 0x5103
  42. #define _STARPU_FUT_JOB_PUSH 0x5104
  43. #define _STARPU_FUT_JOB_POP 0x5105
  44. #define _STARPU_FUT_UPDATE_TASK_CNT 0x5106
  45. #define _STARPU_FUT_START_FETCH_INPUT 0x5107
  46. #define _STARPU_FUT_END_FETCH_INPUT 0x5108
  47. #define _STARPU_FUT_START_PUSH_OUTPUT 0x5109
  48. #define _STARPU_FUT_END_PUSH_OUTPUT 0x5110
  49. #define _STARPU_FUT_TAG 0x5111
  50. #define _STARPU_FUT_TAG_DEPS 0x5112
  51. #define _STARPU_FUT_TASK_DEPS 0x5113
  52. #define _STARPU_FUT_DATA_COPY 0x5114
  53. #define _STARPU_FUT_WORK_STEALING 0x5115
  54. #define _STARPU_FUT_WORKER_DEINIT_START 0x5116
  55. #define _STARPU_FUT_WORKER_DEINIT_END 0x5117
  56. #define _STARPU_FUT_WORKER_SLEEP_START 0x5118
  57. #define _STARPU_FUT_WORKER_SLEEP_END 0x5119
  58. #define _STARPU_FUT_TASK_SUBMIT 0x511a
  59. #define _STARPU_FUT_CODELET_DATA_HANDLE 0x511b
  60. #define _STARPU_FUT_MODEL_NAME 0x511c
  61. #define _STARPU_FUT_USER_DEFINED_START 0x5120
  62. #define _STARPU_FUT_USER_DEFINED_END 0x5121
  63. #define _STARPU_FUT_NEW_MEM_NODE 0x5122
  64. #define _STARPU_FUT_START_CALLBACK 0x5123
  65. #define _STARPU_FUT_END_CALLBACK 0x5124
  66. #define _STARPU_FUT_TASK_DONE 0x5125
  67. #define _STARPU_FUT_TAG_DONE 0x5126
  68. #define _STARPU_FUT_START_ALLOC 0x5127
  69. #define _STARPU_FUT_END_ALLOC 0x5128
  70. #define _STARPU_FUT_START_ALLOC_REUSE 0x5129
  71. #define _STARPU_FUT_END_ALLOC_REUSE 0x5130
  72. #define _STARPU_FUT_START_MEMRECLAIM 0x5131
  73. #define _STARPU_FUT_END_MEMRECLAIM 0x5132
  74. #define _STARPU_FUT_START_DRIVER_COPY 0x5133
  75. #define _STARPU_FUT_END_DRIVER_COPY 0x5134
  76. #define _STARPU_FUT_START_DRIVER_COPY_ASYNC 0x5135
  77. #define _STARPU_FUT_END_DRIVER_COPY_ASYNC 0x5136
  78. #define _STARPU_FUT_START_PROGRESS 0x5137
  79. #define _STARPU_FUT_END_PROGRESS 0x5138
  80. #define _STARPU_FUT_USER_EVENT 0x5139
  81. #define _STARPU_FUT_SET_PROFILING 0x513a
  82. #define _STARPU_FUT_TASK_WAIT_FOR_ALL 0x513b
  83. #define _STARPU_FUT_EVENT 0x513c
  84. #define _STARPU_FUT_THREAD_EVENT 0x513d
  85. #define _STARPU_FUT_CODELET_DETAILS 0x513e
  86. #define _STARPU_FUT_CODELET_DATA 0x513f
  87. #define _STARPU_FUT_LOCKING_MUTEX 0x5140
  88. #define _STARPU_FUT_MUTEX_LOCKED 0x5141
  89. #define _STARPU_FUT_UNLOCKING_MUTEX 0x5142
  90. #define _STARPU_FUT_MUTEX_UNLOCKED 0x5143
  91. #define _STARPU_FUT_TRYLOCK_MUTEX 0x5144
  92. #define _STARPU_FUT_RDLOCKING_RWLOCK 0x5145
  93. #define _STARPU_FUT_RWLOCK_RDLOCKED 0x5146
  94. #define _STARPU_FUT_WRLOCKING_RWLOCK 0x5147
  95. #define _STARPU_FUT_RWLOCK_WRLOCKED 0x5148
  96. #define _STARPU_FUT_UNLOCKING_RWLOCK 0x5149
  97. #define _STARPU_FUT_RWLOCK_UNLOCKED 0x514a
  98. #define _STARPU_FUT_LOCKING_SPINLOCK 0x514b
  99. #define _STARPU_FUT_SPINLOCK_LOCKED 0x514c
  100. #define _STARPU_FUT_UNLOCKING_SPINLOCK 0x514d
  101. #define _STARPU_FUT_SPINLOCK_UNLOCKED 0x514e
  102. #define _STARPU_FUT_TRYLOCK_SPINLOCK 0x514f
  103. #define _STARPU_FUT_COND_WAIT_BEGIN 0x5150
  104. #define _STARPU_FUT_COND_WAIT_END 0x5151
  105. #define _STARPU_FUT_MEMORY_FULL 0x5152
  106. #define _STARPU_FUT_DATA_LOAD 0x5153
  107. #define _STARPU_FUT_START_UNPARTITION 0x5154
  108. #define _STARPU_FUT_END_UNPARTITION 0x5155
  109. #define _STARPU_FUT_START_FREE 0x5156
  110. #define _STARPU_FUT_END_FREE 0x5157
  111. #define _STARPU_FUT_START_WRITEBACK 0x5158
  112. #define _STARPU_FUT_END_WRITEBACK 0x5159
  113. #define _STARPU_FUT_SCHED_COMPONENT_PUSH_PRIO 0x515a
  114. #define _STARPU_FUT_SCHED_COMPONENT_POP_PRIO 0x515b
  115. #define _STARPU_FUT_START_WRITEBACK_ASYNC 0x515c
  116. #define _STARPU_FUT_END_WRITEBACK_ASYNC 0x515d
  117. #define _STARPU_FUT_HYPERVISOR_BEGIN 0x5160
  118. #define _STARPU_FUT_HYPERVISOR_END 0x5161
  119. #define _STARPU_FUT_BARRIER_WAIT_BEGIN 0x5162
  120. #define _STARPU_FUT_BARRIER_WAIT_END 0x5163
  121. #define _STARPU_FUT_WORKER_SCHEDULING_START 0x5164
  122. #define _STARPU_FUT_WORKER_SCHEDULING_END 0x5165
  123. #define _STARPU_FUT_WORKER_SCHEDULING_PUSH 0x5166
  124. #define _STARPU_FUT_WORKER_SCHEDULING_POP 0x5167
  125. #define _STARPU_FUT_START_EXECUTING 0x5168
  126. #define _STARPU_FUT_END_EXECUTING 0x5169
  127. #define _STARPU_FUT_SCHED_COMPONENT_NEW 0x516a
  128. #define _STARPU_FUT_SCHED_COMPONENT_CONNECT 0x516b
  129. #define _STARPU_FUT_SCHED_COMPONENT_PUSH 0x516c
  130. #define _STARPU_FUT_SCHED_COMPONENT_PULL 0x516d
  131. #define _STARPU_FUT_TASK_SUBMIT_START 0x516e
  132. #define _STARPU_FUT_TASK_SUBMIT_END 0x516f
  133. #define _STARPU_FUT_TASK_BUILD_START 0x5170
  134. #define _STARPU_FUT_TASK_BUILD_END 0x5171
  135. #define _STARPU_FUT_TASK_MPI_DECODE_START 0x5172
  136. #define _STARPU_FUT_TASK_MPI_DECODE_END 0x5173
  137. #define _STARPU_FUT_TASK_MPI_PRE_START 0x5174
  138. #define _STARPU_FUT_TASK_MPI_PRE_END 0x5175
  139. #define _STARPU_FUT_TASK_MPI_POST_START 0x5176
  140. #define _STARPU_FUT_TASK_MPI_POST_END 0x5177
  141. #define _STARPU_FUT_TASK_WAIT_START 0x5178
  142. #define _STARPU_FUT_TASK_WAIT_END 0x5179
  143. #define _STARPU_FUT_TASK_WAIT_FOR_ALL_START 0x517a
  144. #define _STARPU_FUT_TASK_WAIT_FOR_ALL_END 0x517b
  145. #define _STARPU_FUT_HANDLE_DATA_REGISTER 0x517c
  146. #define _STARPU_FUT_DATA_INVALIDATE 0x517d
  147. #ifdef STARPU_USE_FXT
  148. #include <fxt/fxt.h>
  149. #include <fxt/fut.h>
  150. /* Some versions of FxT do not include the declaration of the function */
  151. #ifdef HAVE_ENABLE_FUT_FLUSH
  152. #if !HAVE_DECL_ENABLE_FUT_FLUSH
  153. void enable_fut_flush();
  154. #endif
  155. #endif
  156. #ifdef HAVE_FUT_SET_FILENAME
  157. #if !HAVE_DECL_FUT_SET_FILENAME
  158. void fut_set_filename(char *filename);
  159. #endif
  160. #endif
  161. extern int _starpu_fxt_started;
  162. extern starpu_pthread_mutex_t _starpu_fxt_started_mutex;
  163. extern starpu_pthread_cond_t _starpu_fxt_started_cond;
  164. long _starpu_gettid(void);
  165. /* Initialize the FxT library. */
  166. void _starpu_fxt_init_profiling(unsigned trace_buffer_size);
  167. /* Stop the FxT library, and generate the trace file. */
  168. void _starpu_stop_fxt_profiling(void);
  169. /* Associate the current processing unit to the identifier of the LWP that runs
  170. * the worker. */
  171. void _starpu_fxt_register_thread(unsigned);
  172. #ifdef FUT_NEEDS_COMMIT
  173. #define _STARPU_FUT_COMMIT(size) fut_commitstampedbuffer(size)
  174. #else
  175. #define _STARPU_FUT_COMMIT(size) do { } while (0)
  176. #endif
  177. #ifdef FUT_DO_PROBE1STR
  178. #define _STARPU_FUT_DO_PROBE1STR(CODE, P1, str) FUT_DO_PROBE1STR(CODE, P1, str)
  179. #else
  180. /* Sometimes we need something a little more specific than the wrappers from
  181. * FxT: these macro permit to put add an event with 3 (or 4) numbers followed
  182. * by a string. */
  183. #define _STARPU_FUT_DO_PROBE1STR(CODE, P1, str) \
  184. do { \
  185. if(fut_active) { \
  186. /* No more than FXT_MAX_PARAMS args are allowed */ \
  187. /* we add a \0 just in case ... */ \
  188. size_t len = STARPU_MIN(strlen(str)+1, (FXT_MAX_PARAMS - 1)*sizeof(unsigned long));\
  189. unsigned nbargs_str = (len + sizeof(unsigned long) - 1)/(sizeof(unsigned long));\
  190. unsigned nbargs = 1 + nbargs_str; \
  191. size_t total_len = FUT_SIZE(nbargs); \
  192. unsigned long *futargs = \
  193. fut_getstampedbuffer(FUT_CODE(CODE, nbargs), total_len);\
  194. *(futargs++) = (unsigned long)(P1); \
  195. snprintf((char *)futargs, len, "%s", str); \
  196. ((char *)futargs)[len - 1] = '\0'; \
  197. _STARPU_FUT_COMMIT(total_len); \
  198. } \
  199. } while (0);
  200. #endif
  201. #ifdef FUT_DO_PROBE2STR
  202. #define _STARPU_FUT_DO_PROBE2STR(CODE, P1, P2, str) FUT_DO_PROBE2STR(CODE, P1, P2, str)
  203. #else
  204. /* Sometimes we need something a little more specific than the wrappers from
  205. * FxT: these macro permit to put add an event with 3 (or 4) numbers followed
  206. * by a string. */
  207. #define _STARPU_FUT_DO_PROBE2STR(CODE, P1, P2, str) \
  208. do { \
  209. if(fut_active) { \
  210. /* No more than FXT_MAX_PARAMS args are allowed */ \
  211. /* we add a \0 just in case ... */ \
  212. size_t len = STARPU_MIN(strlen(str)+1, (FXT_MAX_PARAMS - 2)*sizeof(unsigned long));\
  213. unsigned nbargs_str = (len + sizeof(unsigned long) - 1)/(sizeof(unsigned long));\
  214. unsigned nbargs = 2 + nbargs_str; \
  215. size_t total_len = FUT_SIZE(nbargs); \
  216. unsigned long *futargs = \
  217. fut_getstampedbuffer(FUT_CODE(CODE, nbargs), total_len);\
  218. *(futargs++) = (unsigned long)(P1); \
  219. *(futargs++) = (unsigned long)(P2); \
  220. snprintf((char *)futargs, len, "%s", str); \
  221. ((char *)futargs)[len - 1] = '\0'; \
  222. _STARPU_FUT_COMMIT(total_len); \
  223. } \
  224. } while (0);
  225. #endif
  226. #ifdef FUT_DO_PROBE3STR
  227. #define _STARPU_FUT_DO_PROBE3STR(CODE, P1, P2, P3, str) FUT_DO_PROBE3STR(CODE, P1, P2, P3, str)
  228. #else
  229. #define _STARPU_FUT_DO_PROBE3STR(CODE, P1, P2, P3, str) \
  230. do { \
  231. if(fut_active) { \
  232. /* No more than FXT_MAX_PARAMS args are allowed */ \
  233. /* we add a \0 just in case ... */ \
  234. size_t len = STARPU_MIN(strlen(str)+1, (FXT_MAX_PARAMS - 3)*sizeof(unsigned long));\
  235. unsigned nbargs_str = (len + sizeof(unsigned long) - 1)/(sizeof(unsigned long));\
  236. unsigned nbargs = 3 + nbargs_str; \
  237. size_t total_len = FUT_SIZE(nbargs); \
  238. unsigned long *futargs = \
  239. fut_getstampedbuffer(FUT_CODE(CODE, nbargs), total_len);\
  240. *(futargs++) = (unsigned long)(P1); \
  241. *(futargs++) = (unsigned long)(P2); \
  242. *(futargs++) = (unsigned long)(P3); \
  243. snprintf((char *)futargs, len, "%s", str); \
  244. ((char *)futargs)[len - 1] = '\0'; \
  245. _STARPU_FUT_COMMIT(total_len); \
  246. } \
  247. } while (0);
  248. #endif
  249. #ifdef FUT_DO_PROBE4STR
  250. #define _STARPU_FUT_DO_PROBE4STR(CODE, P1, P2, P3, P4, str) FUT_DO_PROBE4STR(CODE, P1, P2, P3, P4, str)
  251. #else
  252. #define _STARPU_FUT_DO_PROBE4STR(CODE, P1, P2, P3, P4, str) \
  253. do { \
  254. if(fut_active) { \
  255. /* No more than FXT_MAX_PARAMS args are allowed */ \
  256. /* we add a \0 just in case ... */ \
  257. size_t len = STARPU_MIN(strlen(str)+1, (FXT_MAX_PARAMS - 4)*sizeof(unsigned long));\
  258. unsigned nbargs_str = (len + sizeof(unsigned long) - 1)/(sizeof(unsigned long));\
  259. unsigned nbargs = 4 + nbargs_str; \
  260. size_t total_len = FUT_SIZE(nbargs); \
  261. unsigned long *futargs = \
  262. fut_getstampedbuffer(FUT_CODE(CODE, nbargs), total_len);\
  263. *(futargs++) = (unsigned long)(P1); \
  264. *(futargs++) = (unsigned long)(P2); \
  265. *(futargs++) = (unsigned long)(P3); \
  266. *(futargs++) = (unsigned long)(P4); \
  267. snprintf((char *)futargs, len, "%s", str); \
  268. ((char *)futargs)[len - 1] = '\0'; \
  269. _STARPU_FUT_COMMIT(total_len); \
  270. } \
  271. } while (0);
  272. #endif
  273. #ifdef FUT_DO_PROBE5STR
  274. #define _STARPU_FUT_DO_PROBE5STR(CODE, P1, P2, P3, P4, P5, str) FUT_DO_PROBE5STR(CODE, P1, P2, P3, P4, P5, str)
  275. #else
  276. #define _STARPU_FUT_DO_PROBE5STR(CODE, P1, P2, P3, P4, P5, str) \
  277. do { \
  278. if(fut_active) { \
  279. /* No more than FXT_MAX_PARAMS args are allowed */ \
  280. /* we add a \0 just in case ... */ \
  281. size_t len = STARPU_MIN(strlen(str)+1, (FXT_MAX_PARAMS - 5)*sizeof(unsigned long));\
  282. unsigned nbargs_str = (len + sizeof(unsigned long) - 1)/(sizeof(unsigned long));\
  283. unsigned nbargs = 5 + nbargs_str; \
  284. size_t total_len = FUT_SIZE(nbargs); \
  285. unsigned long *futargs = \
  286. fut_getstampedbuffer(FUT_CODE(CODE, nbargs), total_len);\
  287. *(futargs++) = (unsigned long)(P1); \
  288. *(futargs++) = (unsigned long)(P2); \
  289. *(futargs++) = (unsigned long)(P3); \
  290. *(futargs++) = (unsigned long)(P4); \
  291. *(futargs++) = (unsigned long)(P5); \
  292. snprintf((char *)futargs, len, "%s", str); \
  293. ((char *)futargs)[len - 1] = '\0'; \
  294. _STARPU_FUT_COMMIT(total_len); \
  295. } \
  296. } while (0);
  297. #endif
  298. #ifdef FUT_DO_PROBE6STR
  299. #define _STARPU_FUT_DO_PROBE6STR(CODE, P1, P2, P3, P4, P5, P6, str) FUT_DO_PROBE6STR(CODE, P1, P2, P3, P4, P5, P6, str)
  300. #else
  301. #define _STARPU_FUT_DO_PROBE6STR(CODE, P1, P2, P3, P4, P5, P6, str) \
  302. do { \
  303. if(fut_active) { \
  304. /* No more than FXT_MAX_PARAMS args are allowed */ \
  305. /* we add a \0 just in case ... */ \
  306. size_t len = STARPU_MIN(strlen(str)+1, (FXT_MAX_PARAMS - 6)*sizeof(unsigned long));\
  307. unsigned nbargs_str = (len + sizeof(unsigned long) - 1)/(sizeof(unsigned long));\
  308. unsigned nbargs = 6 + nbargs_str; \
  309. size_t total_len = FUT_SIZE(nbargs); \
  310. unsigned long *futargs = \
  311. fut_getstampedbuffer(FUT_CODE(CODE, nbargs), total_len);\
  312. *(futargs++) = (unsigned long)(P1); \
  313. *(futargs++) = (unsigned long)(P2); \
  314. *(futargs++) = (unsigned long)(P3); \
  315. *(futargs++) = (unsigned long)(P4); \
  316. *(futargs++) = (unsigned long)(P5); \
  317. *(futargs++) = (unsigned long)(P6); \
  318. snprintf((char *)futargs, len, "%s", str); \
  319. ((char *)futargs)[len - 1] = '\0'; \
  320. _STARPU_FUT_COMMIT(total_len); \
  321. } \
  322. } while (0);
  323. #endif
  324. #ifdef FUT_DO_PROBE7STR
  325. #define _STARPU_FUT_DO_PROBE7STR(CODE, P1, P2, P3, P4, P5, P6, P7, str) FUT_DO_PROBE7STR(CODE, P1, P2, P3, P4, P5, P6, P7, str)
  326. #else
  327. #define _STARPU_FUT_DO_PROBE7STR(CODE, P1, P2, P3, P4, P5, P6, P7, str) \
  328. do { \
  329. if(fut_active) { \
  330. /* No more than FXT_MAX_PARAMS args are allowed */ \
  331. /* we add a \0 just in case ... */ \
  332. size_t len = STARPU_MIN(strlen(str)+1, (FXT_MAX_PARAMS - 7)*sizeof(unsigned long));\
  333. unsigned nbargs_str = (len + sizeof(unsigned long) - 1)/(sizeof(unsigned long));\
  334. unsigned nbargs = 7 + nbargs_str; \
  335. size_t total_len = FUT_SIZE(nbargs); \
  336. unsigned long *futargs = \
  337. fut_getstampedbuffer(FUT_CODE(CODE, nbargs), total_len);\
  338. *(futargs++) = (unsigned long)(P1); \
  339. *(futargs++) = (unsigned long)(P2); \
  340. *(futargs++) = (unsigned long)(P3); \
  341. *(futargs++) = (unsigned long)(P4); \
  342. *(futargs++) = (unsigned long)(P5); \
  343. *(futargs++) = (unsigned long)(P6); \
  344. *(futargs++) = (unsigned long)(P7); \
  345. snprintf((char *)futargs, len, "%s", str); \
  346. ((char *)futargs)[len - 1] = '\0'; \
  347. _STARPU_FUT_COMMIT(total_len); \
  348. } \
  349. } while (0);
  350. #endif
  351. #ifndef FUT_RAW_PROBE7
  352. #define FUT_RAW_PROBE7(CODE,P1,P2,P3,P4,P5,P6,P7) do { \
  353. if(fut_active) { \
  354. unsigned long *__args __attribute__((unused))= \
  355. fut_getstampedbuffer(CODE, \
  356. FUT_SIZE(7)); \
  357. *(__args++)=(unsigned long)(P1);*(__args++)=(unsigned long)(P2);*(__args++)=(unsigned long)(P3);*(__args++)=(unsigned long)(P4);*(__args++)=(unsigned long)(P5);*(__args++)=(unsigned long)(P6);*(__args++)=(unsigned long)(P7); \
  358. _STARPU_FUT_COMMIT(FUT_SIZE(7)); \
  359. } \
  360. } while (0)
  361. #endif
  362. #ifndef FUT_DO_PROBE7
  363. #define FUT_DO_PROBE7(CODE,P1,P2,P3,P4,P5,P6,P7) do { \
  364. FUT_RAW_PROBE7(FUT_CODE(CODE, 7),P1,P2,P3,P4,P5,P6,P7); \
  365. } while (0)
  366. #endif
  367. /* workerkind = _STARPU_FUT_CPU_KEY for instance */
  368. #define _STARPU_TRACE_NEW_MEM_NODE(nodeid) \
  369. FUT_DO_PROBE2(_STARPU_FUT_NEW_MEM_NODE, nodeid, _starpu_gettid());
  370. #define _STARPU_TRACE_WORKER_INIT_START(workerkind, workerid, devid, memnode, bindid, sync) \
  371. FUT_DO_PROBE7(_STARPU_FUT_WORKER_INIT_START, workerkind, workerid, devid, memnode, bindid, sync, _starpu_gettid());
  372. #define _STARPU_TRACE_WORKER_INIT_END(__workerid) \
  373. FUT_DO_PROBE2(_STARPU_FUT_WORKER_INIT_END, _starpu_gettid(), (__workerid));
  374. #define _STARPU_TRACE_START_CODELET_BODY(job, nimpl, perf_arch, workerid) \
  375. do { \
  376. const char *model_name = _starpu_job_get_model_name((job)), *name = _starpu_job_get_task_name((job)); \
  377. if (name) \
  378. { \
  379. /* we include the task name */ \
  380. _STARPU_FUT_DO_PROBE5STR(_STARPU_FUT_START_CODELET_BODY, (job)->job_id, ((job)->task)->sched_ctx, workerid, starpu_worker_get_memory_node(workerid), 1, name); \
  381. if (model_name && strcmp(model_name, name)) \
  382. _STARPU_FUT_DO_PROBE1STR(_STARPU_FUT_MODEL_NAME, (job)->job_id, model_name); \
  383. } \
  384. else { \
  385. FUT_DO_PROBE5(_STARPU_FUT_START_CODELET_BODY, (job)->job_id, ((job)->task)->sched_ctx, workerid, starpu_worker_get_memory_node(workerid), 0); \
  386. } \
  387. { \
  388. if ((job)->task->cl) \
  389. { \
  390. const int __nbuffers = STARPU_TASK_GET_NBUFFERS((job)->task); \
  391. char __buf[FXT_MAX_PARAMS*sizeof(long)]; \
  392. int __i; \
  393. for (__i = 0; __i < __nbuffers; __i++) \
  394. { \
  395. starpu_data_handle_t __handle = STARPU_TASK_GET_HANDLE((job)->task, __i); \
  396. void *__interface = _STARPU_TASK_GET_INTERFACES((job)->task)[__i]; \
  397. if (__handle->ops->describe) \
  398. { \
  399. __handle->ops->describe(__interface, __buf, sizeof(__buf)); \
  400. _STARPU_FUT_DO_PROBE1STR(_STARPU_FUT_CODELET_DATA, workerid, __buf); \
  401. } \
  402. FUT_DO_PROBE4(_STARPU_FUT_CODELET_DATA_HANDLE, (job)->job_id, (__handle), _starpu_data_get_size(__handle), STARPU_TASK_GET_MODE((job)->task, __i)); \
  403. } \
  404. } \
  405. const size_t __job_size = _starpu_job_get_data_size((job)->task->cl?(job)->task->cl->model:NULL, perf_arch, nimpl, (job)); \
  406. const uint32_t __job_hash = _starpu_compute_buffers_footprint((job)->task->cl?(job)->task->cl->model:NULL, perf_arch, nimpl, (job));\
  407. FUT_DO_PROBE7(_STARPU_FUT_CODELET_DETAILS, (job), ((job)->task)->sched_ctx, __job_size, __job_hash, (job)->task->tag_id, workerid, ((job)->job_id)); \
  408. } \
  409. } while(0);
  410. #define _STARPU_TRACE_END_CODELET_BODY(job, nimpl, perf_arch, workerid) \
  411. do { \
  412. const size_t job_size = _starpu_job_get_data_size((job)->task->cl?(job)->task->cl->model:NULL, perf_arch, nimpl, (job)); \
  413. const uint32_t job_hash = _starpu_compute_buffers_footprint((job)->task->cl?(job)->task->cl->model:NULL, perf_arch, nimpl, (job));\
  414. char _archname[32]=""; \
  415. starpu_perfmodel_get_arch_name(perf_arch, _archname, 32, 0); \
  416. _STARPU_FUT_DO_PROBE4STR(_STARPU_FUT_END_CODELET_BODY, (job)->job_id, (job_size), (job_hash), workerid, _archname); \
  417. } while(0);
  418. #define _STARPU_TRACE_START_EXECUTING() \
  419. FUT_DO_PROBE1(_STARPU_FUT_START_EXECUTING, _starpu_gettid());
  420. #define _STARPU_TRACE_END_EXECUTING() \
  421. FUT_DO_PROBE1(_STARPU_FUT_END_EXECUTING, _starpu_gettid());
  422. #define _STARPU_TRACE_START_CALLBACK(job) \
  423. FUT_DO_PROBE2(_STARPU_FUT_START_CALLBACK, job, _starpu_gettid());
  424. #define _STARPU_TRACE_END_CALLBACK(job) \
  425. FUT_DO_PROBE2(_STARPU_FUT_END_CALLBACK, job, _starpu_gettid());
  426. #define _STARPU_TRACE_JOB_PUSH(task, prio) \
  427. FUT_DO_PROBE3(_STARPU_FUT_JOB_PUSH, task, prio, _starpu_gettid());
  428. #define _STARPU_TRACE_JOB_POP(task, prio) \
  429. FUT_DO_PROBE3(_STARPU_FUT_JOB_POP, task, prio, _starpu_gettid());
  430. #define _STARPU_TRACE_UPDATE_TASK_CNT(counter) \
  431. FUT_DO_PROBE2(_STARPU_FUT_UPDATE_TASK_CNT, counter, _starpu_gettid())
  432. #define _STARPU_TRACE_START_FETCH_INPUT(job) \
  433. FUT_DO_PROBE2(_STARPU_FUT_START_FETCH_INPUT, job, _starpu_gettid());
  434. #define _STARPU_TRACE_END_FETCH_INPUT(job) \
  435. FUT_DO_PROBE2(_STARPU_FUT_END_FETCH_INPUT, job, _starpu_gettid());
  436. #define _STARPU_TRACE_START_PUSH_OUTPUT(job) \
  437. FUT_DO_PROBE2(_STARPU_FUT_START_PUSH_OUTPUT, job, _starpu_gettid());
  438. #define _STARPU_TRACE_END_PUSH_OUTPUT(job) \
  439. FUT_DO_PROBE2(_STARPU_FUT_END_PUSH_OUTPUT, job, _starpu_gettid());
  440. #define _STARPU_TRACE_TAG(tag, job) \
  441. FUT_DO_PROBE2(_STARPU_FUT_TAG, tag, (job)->job_id)
  442. #define _STARPU_TRACE_TAG_DEPS(tag_child, tag_father) \
  443. FUT_DO_PROBE2(_STARPU_FUT_TAG_DEPS, tag_child, tag_father)
  444. #define _STARPU_TRACE_TASK_DEPS(job_prev, job_succ) \
  445. FUT_DO_PROBE2(_STARPU_FUT_TASK_DEPS, (job_prev)->job_id, (job_succ)->job_id)
  446. #define _STARPU_TRACE_GHOST_TASK_DEPS(ghost_prev_id, job_succ_id) \
  447. FUT_DO_PROBE2(_STARPU_FUT_TASK_DEPS, (ghost_prev_id), (job_succ_id))
  448. #define _STARPU_TRACE_TASK_DONE(job) \
  449. do { \
  450. unsigned exclude_from_dag = (job)->exclude_from_dag; \
  451. const char *model_name = _starpu_job_get_task_name((job)); \
  452. if (model_name) \
  453. { \
  454. _STARPU_FUT_DO_PROBE4STR(_STARPU_FUT_TASK_DONE, (job)->job_id, _starpu_gettid(), (long unsigned)exclude_from_dag, 1, model_name);\
  455. } \
  456. else { \
  457. FUT_DO_PROBE4(_STARPU_FUT_TASK_DONE, (job)->job_id, _starpu_gettid(), (long unsigned)exclude_from_dag, 0);\
  458. } \
  459. } while(0);
  460. #define _STARPU_TRACE_TAG_DONE(tag) \
  461. do { \
  462. struct _starpu_job *job = (tag)->job; \
  463. const char *model_name = _starpu_job_get_task_name((job)); \
  464. if (model_name) \
  465. { \
  466. _STARPU_FUT_DO_PROBE3STR(_STARPU_FUT_TAG_DONE, (tag)->id, _starpu_gettid(), 1, model_name); \
  467. } \
  468. else { \
  469. FUT_DO_PROBE3(_STARPU_FUT_TAG_DONE, (tag)->id, _starpu_gettid(), 0);\
  470. } \
  471. } while(0);
  472. #define _STARPU_TRACE_DATA_COPY(src_node, dst_node, size) \
  473. FUT_DO_PROBE3(_STARPU_FUT_DATA_COPY, src_node, dst_node, size)
  474. #define _STARPU_TRACE_START_DRIVER_COPY(src_node, dst_node, size, com_id, prefetch, handle) \
  475. FUT_DO_PROBE6(_STARPU_FUT_START_DRIVER_COPY, src_node, dst_node, size, com_id, prefetch, handle)
  476. #define _STARPU_TRACE_END_DRIVER_COPY(src_node, dst_node, size, com_id, prefetch) \
  477. FUT_DO_PROBE5(_STARPU_FUT_END_DRIVER_COPY, src_node, dst_node, size, com_id, prefetch)
  478. #define _STARPU_TRACE_START_DRIVER_COPY_ASYNC(src_node, dst_node) \
  479. FUT_DO_PROBE2(_STARPU_FUT_START_DRIVER_COPY_ASYNC, src_node, dst_node)
  480. #define _STARPU_TRACE_END_DRIVER_COPY_ASYNC(src_node, dst_node) \
  481. FUT_DO_PROBE2(_STARPU_FUT_END_DRIVER_COPY_ASYNC, src_node, dst_node)
  482. #define _STARPU_TRACE_WORK_STEALING(empty_q, victim_q) \
  483. FUT_DO_PROBE2(_STARPU_FUT_WORK_STEALING, empty_q, victim_q)
  484. #define _STARPU_TRACE_WORKER_DEINIT_START \
  485. FUT_DO_PROBE1(_STARPU_FUT_WORKER_DEINIT_START, _starpu_gettid());
  486. #define _STARPU_TRACE_WORKER_DEINIT_END(workerkind) \
  487. FUT_DO_PROBE2(_STARPU_FUT_WORKER_DEINIT_END, workerkind, _starpu_gettid());
  488. #define _STARPU_TRACE_WORKER_SCHEDULING_START \
  489. FUT_DO_PROBE1(_STARPU_FUT_WORKER_SCHEDULING_START, _starpu_gettid());
  490. #define _STARPU_TRACE_WORKER_SCHEDULING_END \
  491. FUT_DO_PROBE1(_STARPU_FUT_WORKER_SCHEDULING_END, _starpu_gettid());
  492. #define _STARPU_TRACE_WORKER_SCHEDULING_PUSH \
  493. FUT_DO_PROBE1(_STARPU_FUT_WORKER_SCHEDULING_PUSH, _starpu_gettid());
  494. #define _STARPU_TRACE_WORKER_SCHEDULING_POP \
  495. FUT_DO_PROBE1(_STARPU_FUT_WORKER_SCHEDULING_POP, _starpu_gettid());
  496. #define _STARPU_TRACE_WORKER_SLEEP_START \
  497. FUT_DO_PROBE1(_STARPU_FUT_WORKER_SLEEP_START, _starpu_gettid());
  498. #define _STARPU_TRACE_WORKER_SLEEP_END \
  499. FUT_DO_PROBE1(_STARPU_FUT_WORKER_SLEEP_END, _starpu_gettid());
  500. #define _STARPU_TRACE_TASK_SUBMIT(job) \
  501. FUT_DO_PROBE2(_STARPU_FUT_TASK_SUBMIT, (job)->job_id, _starpu_gettid());
  502. #define _STARPU_TRACE_TASK_SUBMIT_START() \
  503. FUT_DO_PROBE1(_STARPU_FUT_TASK_SUBMIT_START, _starpu_gettid());
  504. #define _STARPU_TRACE_TASK_SUBMIT_END() \
  505. FUT_DO_PROBE1(_STARPU_FUT_TASK_SUBMIT_END, _starpu_gettid());
  506. #define _STARPU_TRACE_TASK_BUILD_START() \
  507. FUT_DO_PROBE1(_STARPU_FUT_TASK_BUILD_START, _starpu_gettid());
  508. #define _STARPU_TRACE_TASK_BUILD_END() \
  509. FUT_DO_PROBE1(_STARPU_FUT_TASK_BUILD_END, _starpu_gettid());
  510. #define _STARPU_TRACE_TASK_MPI_DECODE_START() \
  511. FUT_DO_PROBE1(_STARPU_FUT_TASK_MPI_DECODE_START, _starpu_gettid());
  512. #define _STARPU_TRACE_TASK_MPI_DECODE_END() \
  513. FUT_DO_PROBE1(_STARPU_FUT_TASK_MPI_DECODE_END, _starpu_gettid());
  514. #define _STARPU_TRACE_TASK_MPI_PRE_START() \
  515. FUT_DO_PROBE1(_STARPU_FUT_TASK_MPI_PRE_START, _starpu_gettid());
  516. #define _STARPU_TRACE_TASK_MPI_PRE_END() \
  517. FUT_DO_PROBE1(_STARPU_FUT_TASK_MPI_PRE_END, _starpu_gettid());
  518. #define _STARPU_TRACE_TASK_MPI_POST_START() \
  519. FUT_DO_PROBE1(_STARPU_FUT_TASK_MPI_POST_START, _starpu_gettid());
  520. #define _STARPU_TRACE_TASK_MPI_POST_END() \
  521. FUT_DO_PROBE1(_STARPU_FUT_TASK_MPI_POST_END, _starpu_gettid());
  522. #define _STARPU_TRACE_TASK_WAIT_START(job) \
  523. FUT_DO_PROBE2(_STARPU_FUT_TASK_WAIT_START, (job)->job_id, _starpu_gettid());
  524. #define _STARPU_TRACE_TASK_WAIT_END() \
  525. FUT_DO_PROBE1(_STARPU_FUT_TASK_WAIT_END, _starpu_gettid());
  526. #define _STARPU_TRACE_TASK_WAIT_FOR_ALL_START() \
  527. FUT_DO_PROBE1(_STARPU_FUT_TASK_WAIT_FOR_ALL_START, _starpu_gettid());
  528. #define _STARPU_TRACE_TASK_WAIT_FOR_ALL_END() \
  529. FUT_DO_PROBE1(_STARPU_FUT_TASK_WAIT_FOR_ALL_END, _starpu_gettid());
  530. #define _STARPU_TRACE_USER_DEFINED_START \
  531. FUT_DO_PROBE1(_STARPU_FUT_USER_DEFINED_START, _starpu_gettid());
  532. #define _STARPU_TRACE_USER_DEFINED_END \
  533. FUT_DO_PROBE1(_STARPU_FUT_USER_DEFINED_END, _starpu_gettid());
  534. #define _STARPU_TRACE_START_ALLOC(memnode, size) \
  535. FUT_DO_PROBE3(_STARPU_FUT_START_ALLOC, memnode, _starpu_gettid(), size);
  536. #define _STARPU_TRACE_END_ALLOC(memnode) \
  537. FUT_DO_PROBE2(_STARPU_FUT_END_ALLOC, memnode, _starpu_gettid());
  538. #define _STARPU_TRACE_START_ALLOC_REUSE(memnode, size) \
  539. FUT_DO_PROBE3(_STARPU_FUT_START_ALLOC_REUSE, memnode, _starpu_gettid(), size);
  540. #define _STARPU_TRACE_END_ALLOC_REUSE(memnode) \
  541. FUT_DO_PROBE2(_STARPU_FUT_END_ALLOC_REUSE, memnode, _starpu_gettid());
  542. #define _STARPU_TRACE_START_FREE(memnode, size) \
  543. FUT_DO_PROBE3(_STARPU_FUT_START_FREE, memnode, _starpu_gettid(), size);
  544. #define _STARPU_TRACE_END_FREE(memnode) \
  545. FUT_DO_PROBE2(_STARPU_FUT_END_FREE, memnode, _starpu_gettid());
  546. #define _STARPU_TRACE_START_WRITEBACK(memnode) \
  547. FUT_DO_PROBE2(_STARPU_FUT_START_WRITEBACK, memnode, _starpu_gettid());
  548. #define _STARPU_TRACE_END_WRITEBACK(memnode) \
  549. FUT_DO_PROBE2(_STARPU_FUT_END_WRITEBACK, memnode, _starpu_gettid());
  550. #define _STARPU_TRACE_START_MEMRECLAIM(memnode,is_prefetch) \
  551. FUT_DO_PROBE3(_STARPU_FUT_START_MEMRECLAIM, memnode, is_prefetch, _starpu_gettid());
  552. #define _STARPU_TRACE_END_MEMRECLAIM(memnode, is_prefetch) \
  553. FUT_DO_PROBE3(_STARPU_FUT_END_MEMRECLAIM, memnode, is_prefetch, _starpu_gettid());
  554. #define _STARPU_TRACE_START_WRITEBACK_ASYNC(memnode) \
  555. FUT_DO_PROBE2(_STARPU_FUT_START_WRITEBACK_ASYNC, memnode, _starpu_gettid());
  556. #define _STARPU_TRACE_END_WRITEBACK_ASYNC(memnode) \
  557. FUT_DO_PROBE2(_STARPU_FUT_END_WRITEBACK_ASYNC, memnode, _starpu_gettid());
  558. /* We skip these events becasue they are called so often that they cause FxT to
  559. * fail and make the overall trace unreadable anyway. */
  560. #define _STARPU_TRACE_START_PROGRESS(memnode) \
  561. do {} while (0)
  562. // FUT_DO_PROBE2(_STARPU_FUT_START_PROGRESS, memnode, _starpu_gettid());
  563. #define _STARPU_TRACE_END_PROGRESS(memnode) \
  564. do {} while (0)
  565. //FUT_DO_PROBE2(_STARPU_FUT_END_PROGRESS, memnode, _starpu_gettid());
  566. #define _STARPU_TRACE_USER_EVENT(code) \
  567. FUT_DO_PROBE2(_STARPU_FUT_USER_EVENT, code, _starpu_gettid());
  568. #define _STARPU_TRACE_SET_PROFILING(status) \
  569. FUT_DO_PROBE2(_STARPU_FUT_SET_PROFILING, status, _starpu_gettid());
  570. #define _STARPU_TRACE_TASK_WAIT_FOR_ALL \
  571. FUT_DO_PROBE0(_STARPU_FUT_TASK_WAIT_FOR_ALL)
  572. #define _STARPU_TRACE_EVENT(S) \
  573. FUT_DO_PROBESTR(_STARPU_FUT_EVENT,S)
  574. #define _STARPU_TRACE_THREAD_EVENT(S) \
  575. _STARPU_FUT_DO_PROBE1STR(_STARPU_FUT_THREAD_EVENT, _starpu_gettid(), S)
  576. #define _STARPU_TRACE_HYPERVISOR_BEGIN() \
  577. FUT_DO_PROBE1(_STARPU_FUT_HYPERVISOR_BEGIN, _starpu_gettid());
  578. #define _STARPU_TRACE_HYPERVISOR_END() \
  579. FUT_DO_PROBE1(_STARPU_FUT_HYPERVISOR_END, _starpu_gettid());
  580. #ifdef STARPU_FXT_LOCK_TRACES
  581. #define _STARPU_TRACE_LOCKING_MUTEX() do { \
  582. const char *file; \
  583. file = strrchr(__FILE__,'/') + 1; \
  584. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_LOCKING_MUTEX,__LINE__,_starpu_gettid(),file); \
  585. } while (0)
  586. #define _STARPU_TRACE_MUTEX_LOCKED() do { \
  587. const char *file; \
  588. file = strrchr(__FILE__,'/') + 1; \
  589. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_MUTEX_LOCKED,__LINE__,_starpu_gettid(),file); \
  590. } while(0)
  591. #define _STARPU_TRACE_UNLOCKING_MUTEX() do { \
  592. const char *file; \
  593. file = strrchr(__FILE__,'/') + 1; \
  594. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_UNLOCKING_MUTEX,__LINE__,_starpu_gettid(),file); \
  595. } while(0)
  596. #define _STARPU_TRACE_MUTEX_UNLOCKED() do {\
  597. const char *file; \
  598. file = strrchr(__FILE__,'/') + 1; \
  599. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_MUTEX_UNLOCKED,__LINE__,_starpu_gettid(),file); \
  600. } while(0)
  601. #define _STARPU_TRACE_TRYLOCK_MUTEX() do { \
  602. const char *file; \
  603. file = strrchr(__FILE__,'/') + 1; \
  604. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_TRYLOCK_MUTEX,__LINE__,_starpu_gettid(),file); \
  605. } while(0)
  606. #define _STARPU_TRACE_RDLOCKING_RWLOCK() do { \
  607. const char *file; \
  608. file = strrchr(__FILE__,'/') + 1; \
  609. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_RDLOCKING_RWLOCK,__LINE__,_starpu_gettid(),file); \
  610. } while(0)
  611. #define _STARPU_TRACE_RWLOCK_RDLOCKED() do { \
  612. const char *file; \
  613. file = strrchr(__FILE__,'/') + 1; \
  614. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_RWLOCK_RDLOCKED,__LINE__,_starpu_gettid(),file); \
  615. } while(0)
  616. #define _STARPU_TRACE_WRLOCKING_RWLOCK() do { \
  617. const char *file; \
  618. file = strrchr(__FILE__,'/') + 1; \
  619. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_WRLOCKING_RWLOCK,__LINE__,_starpu_gettid(),file); \
  620. } while(0)
  621. #define _STARPU_TRACE_RWLOCK_WRLOCKED() do { \
  622. const char *file; \
  623. file = strrchr(__FILE__,'/') + 1; \
  624. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_RWLOCK_WRLOCKED,__LINE__,_starpu_gettid(),file); \
  625. } while(0)
  626. #define _STARPU_TRACE_UNLOCKING_RWLOCK() do { \
  627. const char *file; \
  628. file = strrchr(__FILE__,'/') + 1; \
  629. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_UNLOCKING_RWLOCK,__LINE__,_starpu_gettid(),file); \
  630. } while(0)
  631. #define _STARPU_TRACE_RWLOCK_UNLOCKED() do { \
  632. const char *file; \
  633. file = strrchr(__FILE__,'/') + 1; \
  634. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_RWLOCK_UNLOCKED,__LINE__,_starpu_gettid(),file); \
  635. } while(0)
  636. #define STARPU_TRACE_SPINLOCK_CONDITITION (starpu_worker_get_type(starpu_worker_get_id()) == STARPU_CUDA_WORKER)
  637. #define _STARPU_TRACE_LOCKING_SPINLOCK(file, line) do {\
  638. if (STARPU_TRACE_SPINLOCK_CONDITITION) { \
  639. const char *xfile; \
  640. xfile = strrchr(file,'/') + 1; \
  641. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_LOCKING_SPINLOCK,line,_starpu_gettid(),xfile); \
  642. } \
  643. } while(0)
  644. #define _STARPU_TRACE_SPINLOCK_LOCKED(file, line) do { \
  645. if (STARPU_TRACE_SPINLOCK_CONDITITION) { \
  646. const char *xfile; \
  647. xfile = strrchr(file,'/') + 1; \
  648. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_SPINLOCK_LOCKED,line,_starpu_gettid(),xfile); \
  649. } \
  650. } while(0)
  651. #define _STARPU_TRACE_UNLOCKING_SPINLOCK(file, line) do { \
  652. if (STARPU_TRACE_SPINLOCK_CONDITITION) { \
  653. const char *xfile; \
  654. xfile = strrchr(file,'/') + 1; \
  655. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_UNLOCKING_SPINLOCK,line,_starpu_gettid(),xfile); \
  656. } \
  657. } while(0)
  658. #define _STARPU_TRACE_SPINLOCK_UNLOCKED(file, line) do { \
  659. if (STARPU_TRACE_SPINLOCK_CONDITITION) { \
  660. const char *xfile; \
  661. xfile = strrchr(file,'/') + 1; \
  662. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_SPINLOCK_UNLOCKED,line,_starpu_gettid(),xfile); \
  663. } \
  664. } while(0)
  665. #define _STARPU_TRACE_TRYLOCK_SPINLOCK(file, line) do { \
  666. if (STARPU_TRACE_SPINLOCK_CONDITITION) { \
  667. const char *xfile; \
  668. xfile = strrchr(file,'/') + 1; \
  669. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_TRYLOCK_SPINLOCK,line,_starpu_gettid(),xfile); \
  670. } \
  671. } while(0)
  672. #define _STARPU_TRACE_COND_WAIT_BEGIN() do { \
  673. const char *file; \
  674. file = strrchr(__FILE__,'/') + 1; \
  675. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_COND_WAIT_BEGIN,__LINE__,_starpu_gettid(),file); \
  676. } while(0)
  677. #define _STARPU_TRACE_COND_WAIT_END() do { \
  678. const char *file; \
  679. file = strrchr(__FILE__,'/') + 1; \
  680. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_COND_WAIT_END,__LINE__,_starpu_gettid(),file); \
  681. } while(0)
  682. #define _STARPU_TRACE_BARRIER_WAIT_BEGIN() do { \
  683. const char *file; \
  684. file = strrchr(__FILE__,'/') + 1; \
  685. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_BARRIER_WAIT_BEGIN,__LINE__,_starpu_gettid(),file); \
  686. } while(0)
  687. #define _STARPU_TRACE_BARRIER_WAIT_END() do { \
  688. const char *file; \
  689. file = strrchr(__FILE__,'/') + 1; \
  690. _STARPU_FUT_DO_PROBE2STR(_STARPU_FUT_BARRIER_WAIT_END,__LINE__,_starpu_gettid(),file); \
  691. } while(0)
  692. #else // !STARPU_FXT_LOCK_TRACES
  693. #define _STARPU_TRACE_LOCKING_MUTEX() do {} while(0)
  694. #define _STARPU_TRACE_MUTEX_LOCKED() do {} while(0)
  695. #define _STARPU_TRACE_UNLOCKING_MUTEX() do {} while(0)
  696. #define _STARPU_TRACE_MUTEX_UNLOCKED() do {} while(0)
  697. #define _STARPU_TRACE_TRYLOCK_MUTEX() do {} while(0)
  698. #define _STARPU_TRACE_RDLOCKING_RWLOCK() do {} while(0)
  699. #define _STARPU_TRACE_RWLOCK_RDLOCKED() do {} while(0)
  700. #define _STARPU_TRACE_WRLOCKING_RWLOCK() do {} while(0)
  701. #define _STARPU_TRACE_RWLOCK_WRLOCKED() do {} while(0)
  702. #define _STARPU_TRACE_UNLOCKING_RWLOCK() do {} while(0)
  703. #define _STARPU_TRACE_RWLOCK_UNLOCKED() do {} while(0)
  704. #define _STARPU_TRACE_LOCKING_SPINLOCK(file, line) do {} while(0)
  705. #define _STARPU_TRACE_SPINLOCK_LOCKED(file, line) do {} while(0)
  706. #define _STARPU_TRACE_UNLOCKING_SPINLOCK(file, line) do {} while(0)
  707. #define _STARPU_TRACE_SPINLOCK_UNLOCKED(file, line) do {} while(0)
  708. #define _STARPU_TRACE_TRYLOCK_SPINLOCK(file, line) do {} while(0)
  709. #define _STARPU_TRACE_COND_WAIT_BEGIN() do {} while(0)
  710. #define _STARPU_TRACE_COND_WAIT_END() do {} while(0)
  711. #define _STARPU_TRACE_BARRIER_WAIT_BEGIN() do {} while(0)
  712. #define _STARPU_TRACE_BARRIER_WAIT_END() do {} while(0)
  713. #endif // STARPU_FXT_LOCK_TRACES
  714. #define _STARPU_TRACE_MEMORY_FULL(size) \
  715. FUT_DO_PROBE2(_STARPU_FUT_MEMORY_FULL,size,_starpu_gettid());
  716. #define _STARPU_TRACE_DATA_LOAD(workerid,size) \
  717. FUT_DO_PROBE2(_STARPU_FUT_DATA_LOAD, workerid, size);
  718. #define _STARPU_TRACE_START_UNPARTITION(handle, memnode) \
  719. FUT_DO_PROBE3(_STARPU_FUT_START_UNPARTITION, memnode, _starpu_gettid(), handle);
  720. #define _STARPU_TRACE_END_UNPARTITION(handle, memnode) \
  721. FUT_DO_PROBE3(_STARPU_FUT_END_UNPARTITION, memnode, _starpu_gettid(), handle);
  722. #define _STARPU_TRACE_SCHED_COMPONENT_PUSH_PRIO(workerid, ntasks, exp_len) \
  723. FUT_DO_PROBE4(_STARPU_FUT_SCHED_COMPONENT_PUSH_PRIO, _starpu_gettid(), workerid, ntasks, exp_len);
  724. #define _STARPU_TRACE_SCHED_COMPONENT_POP_PRIO(workerid, ntasks, exp_len) \
  725. FUT_DO_PROBE4(_STARPU_FUT_SCHED_COMPONENT_POP_PRIO, _starpu_gettid(), workerid, ntasks, exp_len);
  726. #define _STARPU_TRACE_SCHED_COMPONENT_NEW(component) \
  727. _STARPU_FUT_DO_PROBE1STR(_STARPU_FUT_SCHED_COMPONENT_NEW, component, (component)->name);
  728. #define _STARPU_TRACE_SCHED_COMPONENT_CONNECT(parent, child) \
  729. FUT_DO_PROBE2(_STARPU_FUT_SCHED_COMPONENT_CONNECT, parent, child);
  730. #define _STARPU_TRACE_SCHED_COMPONENT_PUSH(from, to, task) \
  731. FUT_DO_PROBE5(_STARPU_FUT_SCHED_COMPONENT_PUSH, _starpu_gettid(), from, to, task, (task)->priority);
  732. #define _STARPU_TRACE_SCHED_COMPONENT_PULL(from, to, task) \
  733. FUT_DO_PROBE5(_STARPU_FUT_SCHED_COMPONENT_PULL, _starpu_gettid(), from, to, task, (task)->priority);
  734. #define _STARPU_TRACE_HANDLE_DATA_REGISTER(handle) \
  735. FUT_DO_PROBE1(_STARPU_FUT_HANDLE_DATA_REGISTER, handle)
  736. #if 0
  737. #define _STARPU_TRACE_DATA_INVALIDATE(handle, node) \
  738. FUT_DO_PROBE2(_STARPU_FUT_DATA_INVALIDATE, handle, node)
  739. #else
  740. #define _STARPU_TRACE_DATA_INVALIDATE(handle, node) do {} while (0)
  741. #endif
  742. #else // !STARPU_USE_FXT
  743. /* Dummy macros in case FxT is disabled */
  744. #define _STARPU_TRACE_NEW_MEM_NODE(nodeid) do {} while(0)
  745. #define _STARPU_TRACE_WORKER_INIT_START(a,b,c,d,e,f) do {} while(0)
  746. #define _STARPU_TRACE_WORKER_INIT_END(workerid) do {} while(0)
  747. #define _STARPU_TRACE_START_CODELET_BODY(job, nimpl, perf_arch, workerid) do {} while(0)
  748. #define _STARPU_TRACE_END_CODELET_BODY(job, nimpl, perf_arch, workerid) do {} while(0)
  749. #define _STARPU_TRACE_START_EXECUTING() do {} while(0)
  750. #define _STARPU_TRACE_END_EXECUTING() do {} while(0)
  751. #define _STARPU_TRACE_START_CALLBACK(job) do {} while(0)
  752. #define _STARPU_TRACE_END_CALLBACK(job) do {} while(0)
  753. #define _STARPU_TRACE_JOB_PUSH(task, prio) do {} while(0)
  754. #define _STARPU_TRACE_JOB_POP(task, prio) do {} while(0)
  755. #define _STARPU_TRACE_UPDATE_TASK_CNT(counter) do {} while(0)
  756. #define _STARPU_TRACE_START_FETCH_INPUT(job) do {} while(0)
  757. #define _STARPU_TRACE_END_FETCH_INPUT(job) do {} while(0)
  758. #define _STARPU_TRACE_START_PUSH_OUTPUT(job) do {} while(0)
  759. #define _STARPU_TRACE_END_PUSH_OUTPUT(job) do {} while(0)
  760. #define _STARPU_TRACE_TAG(tag, job) do {} while(0)
  761. #define _STARPU_TRACE_TAG_DEPS(a, b) do {} while(0)
  762. #define _STARPU_TRACE_TASK_DEPS(a, b) do {} while(0)
  763. #define _STARPU_TRACE_GHOST_TASK_DEPS(a, b) do {} while(0)
  764. #define _STARPU_TRACE_TASK_DONE(a) do {} while(0)
  765. #define _STARPU_TRACE_TAG_DONE(a) do {} while(0)
  766. #define _STARPU_TRACE_DATA_COPY(a, b, c) do {} while(0)
  767. #define _STARPU_TRACE_START_DRIVER_COPY(a,b,c,d,e,f) do {} while(0)
  768. #define _STARPU_TRACE_END_DRIVER_COPY(a,b,c,d,e) do {} while(0)
  769. #define _STARPU_TRACE_START_DRIVER_COPY_ASYNC(a,b) do {} while(0)
  770. #define _STARPU_TRACE_END_DRIVER_COPY_ASYNC(a,b) do {} while(0)
  771. #define _STARPU_TRACE_WORK_STEALING(a, b) do {} while(0)
  772. #define _STARPU_TRACE_WORKER_DEINIT_START do {} while(0)
  773. #define _STARPU_TRACE_WORKER_DEINIT_END(a) do {} while(0)
  774. #define _STARPU_TRACE_WORKER_SCHEDULING_START do {} while(0)
  775. #define _STARPU_TRACE_WORKER_SCHEDULING_END do {} while(0)
  776. #define _STARPU_TRACE_WORKER_SCHEDULING_PUSH do {} while(0)
  777. #define _STARPU_TRACE_WORKER_SCHEDULING_POP do {} while(0)
  778. #define _STARPU_TRACE_WORKER_SLEEP_START do {} while(0)
  779. #define _STARPU_TRACE_WORKER_SLEEP_END do {} while(0)
  780. #define _STARPU_TRACE_TASK_SUBMIT(job) do {} while(0)
  781. #define _STARPU_TRACE_TASK_SUBMIT_START() do {} while(0)
  782. #define _STARPU_TRACE_TASK_SUBMIT_END() do {} while(0)
  783. #define _STARPU_TRACE_TASK_BUILD_START() do {} while(0)
  784. #define _STARPU_TRACE_TASK_BUILD_END() do {} while(0)
  785. #define _STARPU_TRACE_TASK_MPI_DECODE_START() do {} while(0)
  786. #define _STARPU_TRACE_TASK_MPI_DECODE_END() do {} while(0)
  787. #define _STARPU_TRACE_TASK_MPI_PRE_START() do {} while(0)
  788. #define _STARPU_TRACE_TASK_MPI_PRE_END() do {} while(0)
  789. #define _STARPU_TRACE_TASK_MPI_POST_START() do {} while(0)
  790. #define _STARPU_TRACE_TASK_MPI_POST_END() do {} while(0)
  791. #define _STARPU_TRACE_TASK_WAIT_START(job) do {} while(0)
  792. #define _STARPU_TRACE_TASK_WAIT_END() do {} while(0)
  793. #define _STARPU_TRACE_TASK_WAIT_FOR_ALL_START() do {} while(0)
  794. #define _STARPU_TRACE_TASK_WAIT_FOR_ALL_END() do {} while(0)
  795. #define _STARPU_TRACE_USER_DEFINED_START do {} while(0)
  796. #define _STARPU_TRACE_USER_DEFINED_END do {} while(0)
  797. #define _STARPU_TRACE_START_ALLOC(memnode, size) do {} while(0)
  798. #define _STARPU_TRACE_END_ALLOC(memnode) do {} while(0)
  799. #define _STARPU_TRACE_START_ALLOC_REUSE(a, size) do {} while(0)
  800. #define _STARPU_TRACE_END_ALLOC_REUSE(a) do {} while(0)
  801. #define _STARPU_TRACE_START_FREE(memnode, size) do {} while(0)
  802. #define _STARPU_TRACE_END_FREE(memnode) do {} while(0)
  803. #define _STARPU_TRACE_START_WRITEBACK(memnode) do {} while(0)
  804. #define _STARPU_TRACE_END_WRITEBACK(memnode) do {} while(0)
  805. #define _STARPU_TRACE_START_MEMRECLAIM(memnode,is_prefetch) do {} while(0)
  806. #define _STARPU_TRACE_END_MEMRECLAIM(memnode,is_prefetch) do {} while(0)
  807. #define _STARPU_TRACE_START_WRITEBACK_ASYNC(memnode) do {} while(0)
  808. #define _STARPU_TRACE_END_WRITEBACK_ASYNC(memnode) do {} while(0)
  809. #define _STARPU_TRACE_START_PROGRESS(memnode) do {} while(0)
  810. #define _STARPU_TRACE_END_PROGRESS(memnode) do {} while(0)
  811. #define _STARPU_TRACE_USER_EVENT(code) do {} while(0)
  812. #define _STARPU_TRACE_SET_PROFILING(status) do {} while(0)
  813. #define _STARPU_TRACE_TASK_WAIT_FOR_ALL do {} while(0)
  814. #define _STARPU_TRACE_EVENT(S) do {} while(0)
  815. #define _STARPU_TRACE_THREAD_EVENT(S) do {} while(0)
  816. #define _STARPU_TRACE_LOCKING_MUTEX() do {} while(0)
  817. #define _STARPU_TRACE_MUTEX_LOCKED() do {} while(0)
  818. #define _STARPU_TRACE_UNLOCKING_MUTEX() do {} while(0)
  819. #define _STARPU_TRACE_MUTEX_UNLOCKED() do {} while(0)
  820. #define _STARPU_TRACE_TRYLOCK_MUTEX() do {} while(0)
  821. #define _STARPU_TRACE_RDLOCKING_RWLOCK() do {} while(0)
  822. #define _STARPU_TRACE_RWLOCK_RDLOCKED() do {} while(0)
  823. #define _STARPU_TRACE_WRLOCKING_RWLOCK() do {} while(0)
  824. #define _STARPU_TRACE_RWLOCK_WRLOCKED() do {} while(0)
  825. #define _STARPU_TRACE_UNLOCKING_RWLOCK() do {} while(0)
  826. #define _STARPU_TRACE_RWLOCK_UNLOCKED() do {} while(0)
  827. #define _STARPU_TRACE_LOCKING_SPINLOCK(file, line) do {} while(0)
  828. #define _STARPU_TRACE_SPINLOCK_LOCKED(file, line) do {} while(0)
  829. #define _STARPU_TRACE_UNLOCKING_SPINLOCK(file, line) do {} while(0)
  830. #define _STARPU_TRACE_SPINLOCK_UNLOCKED(file, line) do {} while(0)
  831. #define _STARPU_TRACE_TRYLOCK_SPINLOCK(file, line) do {} while(0)
  832. #define _STARPU_TRACE_COND_WAIT_BEGIN() do {} while(0)
  833. #define _STARPU_TRACE_COND_WAIT_END() do {} while(0)
  834. #define _STARPU_TRACE_BARRIER_WAIT_BEGIN() do {} while(0)
  835. #define _STARPU_TRACE_BARRIER_WAIT_END() do {} while(0)
  836. #define _STARPU_TRACE_MEMORY_FULL(size) do {} while(0)
  837. #define _STARPU_TRACE_DATA_LOAD(workerid,size) do {} while(0)
  838. #define _STARPU_TRACE_START_UNPARTITION(handle, memnode) do {} while(0)
  839. #define _STARPU_TRACE_END_UNPARTITION(handle, memnode) do {} while(0)
  840. #define _STARPU_TRACE_SCHED_COMPONENT_PUSH_PRIO(workerid, ntasks, exp_len) do {} while(0)
  841. #define _STARPU_TRACE_SCHED_COMPONENT_POP_PRIO(workerid, ntasks, exp_len) do {} while(0)
  842. #define _STARPU_TRACE_HYPERVISOR_BEGIN() do {} while(0)
  843. #define _STARPU_TRACE_HYPERVISOR_END() do {} while(0)
  844. #define _STARPU_TRACE_SCHED_COMPONENT_NEW(component) do {} while (0)
  845. #define _STARPU_TRACE_SCHED_COMPONENT_CONNECT(parent, child) do {} while (0)
  846. #define _STARPU_TRACE_SCHED_COMPONENT_PUSH(from, to, task) do {} while (0)
  847. #define _STARPU_TRACE_SCHED_COMPONENT_PULL(from, to, task) do {} while (0)
  848. #define _STARPU_TRACE_HANDLE_DATA_REGISTER(handle) do {} while (0)
  849. #define _STARPU_TRACE_DATA_INVALIDATE(handle, node) do {} while (0)
  850. #endif // STARPU_USE_FXT
  851. #endif // __FXT_H__