fxt-tool.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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. #include "fxt-tool.h"
  17. static char *worker_name[MAXWORKERS];
  18. static char *cpus_worker_colors[MAXWORKERS] = {"/greens9/7", "/greens9/6", "/greens9/5", "/greens9/4", "/greens9/9", "/greens9/3", "/greens9/2", "/greens9/1" };
  19. static char *cuda_worker_colors[MAXWORKERS] = {"/ylorrd9/9", "/ylorrd9/6", "/ylorrd9/3", "/ylorrd9/1", "/ylorrd9/8", "/ylorrd9/7", "/ylorrd9/4", "/ylorrd9/2", "/ylorrd9/1"};
  20. static char *other_worker_colors[MAXWORKERS] = {"/greys9/9", "/greys9/8", "/greys9/7", "/greys9/6"};
  21. static char *worker_colors[MAXWORKERS];
  22. static fxt_t fut;
  23. struct fxt_ev_64 ev;
  24. static unsigned first_event = 1;
  25. static uint64_t start_time = 0;
  26. static uint64_t end_time = 0;
  27. static unsigned nworkers = 0;
  28. static char *filename = NULL;
  29. static unsigned per_task_colour = 0;
  30. static unsigned generate_distrib = 0;
  31. static unsigned no_counter = 0;
  32. static unsigned no_bus = 0;
  33. LIST_TYPE(symbol_name,
  34. char *name;
  35. );
  36. static symbol_name_list_t symbol_list;
  37. LIST_TYPE(communication,
  38. unsigned comid;
  39. float comm_start;
  40. float bandwith;
  41. unsigned node;
  42. );
  43. static communication_list_t communication_list;
  44. /*
  45. * Paje trace file tools
  46. */
  47. static char *out_paje_path = "paje.trace";
  48. static FILE *out_paje_file;
  49. static char *distrib_time_path = "distrib.data";
  50. static FILE *distrib_time;
  51. static void paje_output_file_init(void)
  52. {
  53. /* create a new file */
  54. out_paje_file = fopen(out_paje_path, "w+");
  55. if (generate_distrib)
  56. distrib_time = fopen(distrib_time_path, "w+");
  57. write_paje_header(out_paje_file);
  58. fprintf(out_paje_file, " \n \
  59. 1 P 0 \"Program\" \n \
  60. 1 Mn P \"Memory Node\" \n \
  61. 1 T Mn \"Worker\" \n \
  62. 1 Sc P \"Scheduler State\" \n \
  63. 2 event T \"event type\" \n \
  64. 3 S T \"Thread State\" \n \
  65. 3 MS Mn \"Memory Node State\" \n \
  66. 4 ntask Sc \"Number of tasks\" \n \
  67. 4 bw Mn \"Bandwith\" \n \
  68. 6 I S Initializing \"0.0 .7 1.0\" \n \
  69. 6 D S Deinitializing \"0.0 .1 .7\" \n \
  70. 6 Fi S FetchingInput \"1.0 .1 1.0\" \n \
  71. 6 Po S PushingOutput \"0.1 1.0 1.0\" \n \
  72. 6 E S Executing \".0 .6 .4\" \n \
  73. 6 C S Callback \".0 .3 .8\" \n \
  74. 6 B S Blocked \".9 .1 .0\" \n \
  75. 6 P S Progressing \".4 .1 .6\" \n \
  76. 6 A MS Allocating \".4 .1 .0\" \n \
  77. 6 Ar MS AllocatingReuse \".1 .1 .8\" \n \
  78. 6 R MS Reclaiming \".0 .1 .4\" \n \
  79. 6 Co MS DriverCopy \".3 .5 .1\" \n \
  80. 6 No MS Nothing \".0 .0 .0\" \n \
  81. 5 L P Mn Mn L\n");
  82. }
  83. static void paje_output_file_terminate(void)
  84. {
  85. /* close the file */
  86. fclose(out_paje_file);
  87. if (generate_distrib)
  88. fclose(distrib_time);
  89. }
  90. /*
  91. * Generic tools
  92. */
  93. static void handle_new_mem_node(void)
  94. {
  95. char *memnodestr = malloc(16*sizeof(char));
  96. sprintf(memnodestr, "%ld", ev.param[0]);
  97. fprintf(out_paje_file, "7 %f %s Mn p MEMNODE%s\n", (float)((ev.time-start_time)/1000000.0), memnodestr, memnodestr);
  98. if (!no_bus)
  99. fprintf(out_paje_file, "13 %f bw MEMNODE%d 0.0\n", (float)(start_time-start_time), ev.param[0]);
  100. }
  101. static unsigned cuda_index = 0;
  102. static unsigned cpus_index = 0;
  103. static unsigned other_index = 0;
  104. static void handle_worker_init_start(void)
  105. {
  106. /*
  107. arg0 : type of worker (cuda, core ..)
  108. arg1 : memory node
  109. arg2 : thread id
  110. */
  111. char *str = malloc(20*sizeof(char));
  112. char *color = NULL;
  113. strcpy(str, "unknown");
  114. switch (ev.param[0]) {
  115. case FUT_APPS_KEY:
  116. str = "apps";
  117. color = other_worker_colors[other_index++];
  118. break;
  119. case FUT_CORE_KEY:
  120. str = "core";
  121. color = cpus_worker_colors[cpus_index++];
  122. break;
  123. case FUT_CUDA_KEY:
  124. str = "cuda";
  125. color = cuda_worker_colors[cuda_index++];
  126. break;
  127. }
  128. // fprintf(stderr, "new %s worker (tid = %d)\n", str, ev.param[1]);
  129. char *memnodestr = malloc(16*sizeof(char));
  130. sprintf(memnodestr, "%ld", ev.param[1]);
  131. char *tidstr = malloc(16*sizeof(char));
  132. sprintf(tidstr, "%ld", ev.param[2]);
  133. fprintf(out_paje_file, "7 %f %s T MEMNODE%s %s \n", (float)((ev.time-start_time)/1000000.0), tidstr, memnodestr, tidstr);
  134. /* create a new key in the htable */
  135. uint64_t workerid = nworkers++;
  136. ENTRY item;
  137. item.key = tidstr;
  138. item.data = (void *)workerid;
  139. worker_colors[workerid] = color;
  140. ENTRY *res;
  141. res = hsearch(item, FIND);
  142. worker_name[workerid] = str;
  143. /* only register a thread once */
  144. STARPU_ASSERT(res == NULL);
  145. res = hsearch(item, ENTER);
  146. STARPU_ASSERT(res);
  147. /* start initialization */
  148. fprintf(out_paje_file, "10 %f S %ld I\n", (float)((ev.time-start_time)/1000000.0), ev.param[2]);
  149. }
  150. static void handle_worker_init_end(void)
  151. {
  152. fprintf(out_paje_file, "10 %f S %ld B\n", (float)((ev.time-start_time)/1000000.0), ev.param[0]);
  153. }
  154. static void handle_worker_deinit_start(void)
  155. {
  156. fprintf(out_paje_file, "10 %f S %ld D\n", (float)((ev.time-start_time)/1000000.0), ev.param[0]);
  157. }
  158. static void handle_worker_deinit_end(void)
  159. {
  160. fprintf(out_paje_file, "8 %f %ld T\n", (float)((ev.time-start_time)/1000000.0), ev.param[1]);
  161. }
  162. static int find_workder_id(unsigned long tid)
  163. {
  164. char tidstr[16];
  165. sprintf(tidstr, "%ld", tid);
  166. ENTRY item;
  167. item.key = tidstr;
  168. item.data = NULL;
  169. ENTRY *res;
  170. res = hsearch(item, FIND);
  171. //STARPU_ASSERT(res);
  172. if (!res)
  173. return -1;
  174. int id = (uintptr_t)(res->data);
  175. return id;
  176. }
  177. static unsigned get_colour_symbol_red(char *name)
  178. {
  179. /* choose some colour ... that's disguting yes */
  180. uint32_t hash_symbol = crc32_string(name, 0);
  181. return (unsigned)crc32_string("red", hash_symbol) % 1024;
  182. }
  183. static unsigned get_colour_symbol_green(char *name)
  184. {
  185. /* choose some colour ... that's disguting yes */
  186. uint32_t hash_symbol = crc32_string(name, 0);
  187. return (unsigned)crc32_string("green", hash_symbol) % 1024;
  188. }
  189. static unsigned get_colour_symbol_blue(char *name)
  190. {
  191. /* choose some colour ... that's disguting yes */
  192. uint32_t hash_symbol = crc32_string(name, 0);
  193. return (unsigned)crc32_string("blue", hash_symbol) % 1024;
  194. }
  195. static void create_paje_state_if_not_found(char *name)
  196. {
  197. symbol_name_itor_t itor;
  198. for (itor = symbol_name_list_begin(symbol_list);
  199. itor != symbol_name_list_end(symbol_list);
  200. itor = symbol_name_list_next(itor))
  201. {
  202. if (!strcmp(name, itor->name))
  203. {
  204. /* we found an entry */
  205. return;
  206. }
  207. }
  208. /* it's the first time ... */
  209. symbol_name_t entry = symbol_name_new();
  210. entry->name = malloc(strlen(name));
  211. strcpy(entry->name, name);
  212. symbol_name_list_push_front(symbol_list, entry);
  213. /* choose some colour ... that's disguting yes */
  214. unsigned hash_symbol_red = get_colour_symbol_red(name);
  215. unsigned hash_symbol_green = get_colour_symbol_green(name);
  216. unsigned hash_symbol_blue = get_colour_symbol_blue(name);
  217. fprintf(stderr, "name %s hash red %d green %d blue %d \n", name, hash_symbol_red, hash_symbol_green, hash_symbol_blue);
  218. uint32_t hash_sum = hash_symbol_red + hash_symbol_green + hash_symbol_blue;
  219. float red = (1.0f * hash_symbol_red) / hash_sum;
  220. float green = (1.0f * hash_symbol_green) / hash_sum;
  221. float blue = (1.0f * hash_symbol_blue) / hash_sum;
  222. /* create the Paje state */
  223. fprintf(out_paje_file, "6 %s S %s \"%f %f %f\" \n", name, red, green, blue, name);
  224. }
  225. /* TODO remove 32 */
  226. static double last_codelet_start[32];
  227. static uint64_t last_codelet_hash[32];
  228. static char last_codelet_symbol[128][32];
  229. static void handle_start_codelet_body(void)
  230. {
  231. int worker;
  232. worker = find_workder_id(ev.param[1]);
  233. if (worker < 0) return;
  234. unsigned long has_name = ev.param[2];
  235. char *name = has_name?(char *)&ev.param[3]:"unknown";
  236. snprintf(last_codelet_symbol[worker], 128, "%s", name);
  237. /* TODO */
  238. last_codelet_hash[worker] = 0;
  239. float start_codelet_time = (float)((ev.time-start_time)/1000000.0);
  240. last_codelet_start[worker] = start_codelet_time;
  241. if (per_task_colour)
  242. {
  243. create_paje_state_if_not_found(name);
  244. fprintf(out_paje_file, "101 %f S %ld E %s\n", start_codelet_time, ev.param[1], name);
  245. }
  246. else {
  247. fprintf(out_paje_file, "10 %f S %ld E\n", start_codelet_time, ev.param[1]);
  248. }
  249. end_time = STARPU_MAX(end_time, ev.time);
  250. }
  251. static void handle_end_codelet_body(void)
  252. {
  253. //fprintf(stderr, "end codelet %p on tid %d\n", (void *)ev.param[0], ev.param[1]);
  254. int worker;
  255. worker = find_workder_id(ev.param[1]);
  256. if (worker < 0) return;
  257. float end_codelet_time = (float)((ev.time-start_time)/1000000.0);
  258. // printf("<- worker %d\n", worker);
  259. fprintf(out_paje_file, "10 %f S %ld B\n", end_codelet_time, ev.param[1] );
  260. float codelet_length = (end_codelet_time - last_codelet_start[worker]);
  261. if (generate_distrib)
  262. fprintf(distrib_time, "%s\t%lx\t%d\t%f\n", last_codelet_symbol[worker],
  263. worker, last_codelet_hash[worker], codelet_length);
  264. end_time = STARPU_MAX(end_time, ev.time);
  265. }
  266. static void handle_user_event(void)
  267. {
  268. int worker;
  269. worker = find_workder_id(ev.param[1]);
  270. if (worker < 0) return;
  271. unsigned code;
  272. code = ev.param[2];
  273. fprintf(out_paje_file, "9 %f event %ld %d\n", (float)((ev.time-start_time)/1000000.0), ev.param[1], code);
  274. }
  275. static void handle_start_callback(void)
  276. {
  277. int worker;
  278. worker = find_workder_id(ev.param[1]);
  279. if (worker < 0) return;
  280. fprintf(out_paje_file, "10 %f S %ld C\n", (float)((ev.time-start_time)/1000000.0), ev.param[1] );
  281. }
  282. static void handle_end_callback(void)
  283. {
  284. int worker;
  285. worker = find_workder_id(ev.param[1]);
  286. if (worker < 0) return;
  287. fprintf(out_paje_file, "10 %f S %ld B\n", (float)((ev.time-start_time)/1000000.0), ev.param[1] );
  288. }
  289. static void handle_start_fetch_input(void)
  290. {
  291. int worker;
  292. worker = find_workder_id(ev.param[1]);
  293. if (worker < 0) return;
  294. fprintf(out_paje_file, "10 %f S %ld Fi\n", (float)((ev.time-start_time)/1000000.0), ev.param[1] );
  295. end_time = STARPU_MAX(end_time, ev.time);
  296. }
  297. static void handle_end_fetch_input(void)
  298. {
  299. int worker;
  300. worker = find_workder_id(ev.param[1]);
  301. if (worker < 0) return;
  302. fprintf(out_paje_file, "10 %f S %ld B\n", (float)((ev.time-start_time)/1000000.0), ev.param[1] );
  303. end_time = STARPU_MAX(end_time, ev.time);
  304. }
  305. static void handle_start_push_output(void)
  306. {
  307. int worker;
  308. worker = find_workder_id(ev.param[1]);
  309. if (worker < 0) return;
  310. fprintf(out_paje_file, "10 %f S %ld Po\n", (float)((ev.time-start_time)/1000000.0), ev.param[1] );
  311. end_time = STARPU_MAX(end_time, ev.time);
  312. }
  313. static void handle_end_push_output(void)
  314. {
  315. int worker;
  316. worker = find_workder_id(ev.param[1]);
  317. if (worker < 0) return;
  318. fprintf(out_paje_file, "10 %f S %ld B\n", (float)((ev.time-start_time)/1000000.0), ev.param[1] );
  319. end_time = STARPU_MAX(end_time, ev.time);
  320. }
  321. static void handle_start_progress(void)
  322. {
  323. int worker;
  324. worker = find_workder_id(ev.param[1]);
  325. if (worker < 0) return;
  326. fprintf(out_paje_file, "10 %f S %ld P\n", (float)((ev.time-start_time)/1000000.0), ev.param[1] );
  327. end_time = STARPU_MAX(end_time, ev.time);
  328. }
  329. static void handle_end_progress(void)
  330. {
  331. int worker;
  332. worker = find_workder_id(ev.param[1]);
  333. if (worker < 0) return;
  334. fprintf(out_paje_file, "10 %f S %ld B\n", (float)((ev.time-start_time)/1000000.0), ev.param[1] );
  335. end_time = STARPU_MAX(end_time, ev.time);
  336. }
  337. static void handle_data_copy(void)
  338. {
  339. }
  340. static void handle_start_driver_copy(void)
  341. {
  342. unsigned src = ev.param[0];
  343. unsigned dst = ev.param[1];
  344. unsigned size = ev.param[2];
  345. unsigned comid = ev.param[3];
  346. if (!no_bus)
  347. {
  348. fprintf(out_paje_file, "10 %f MS MEMNODE%d Co\n", (float)((ev.time-start_time)/1000000.0), dst);
  349. fprintf(out_paje_file, "18 %f L p %d MEMNODE%d com_%d\n", (float)((ev.time-start_time)/1000000.0), size, src, comid);
  350. /* create a structure to store the start of the communication, this will be matched later */
  351. communication_t com = communication_new();
  352. com->comid = comid;
  353. com->comm_start = (float)((ev.time-start_time)/1000000.0);
  354. /* that's a hack: either src or dst is non null */
  355. com->node = (src + dst);
  356. communication_list_push_back(communication_list, com);
  357. }
  358. }
  359. static void handle_end_driver_copy(void)
  360. {
  361. unsigned dst = ev.param[1];
  362. unsigned size = ev.param[2];
  363. unsigned comid = ev.param[3];
  364. if (!no_bus)
  365. {
  366. fprintf(out_paje_file, "10 %f MS MEMNODE%d No\n", (float)((ev.time-start_time)/1000000.0), dst);
  367. fprintf(out_paje_file, "19 %f L p %d MEMNODE%d com_%d\n", (float)((ev.time-start_time)/1000000.0), size, dst, comid);
  368. /* look for a data transfer to match */
  369. communication_itor_t itor;
  370. for (itor = communication_list_begin(communication_list);
  371. itor != communication_list_end(communication_list);
  372. itor = communication_list_next(itor))
  373. {
  374. if (itor->comid == comid)
  375. {
  376. float comm_end = (float)((ev.time-start_time)/1000000.0);
  377. float bandwith = (float)((0.001*size)/(comm_end - itor->comm_start));
  378. itor->bandwith = bandwith;
  379. communication_t com = communication_new();
  380. com->comid = comid;
  381. com->comm_start = (float)((ev.time-start_time)/1000000.0);
  382. com->bandwith = -bandwith;
  383. com->node = itor->node;
  384. communication_list_push_back(communication_list, com);
  385. break;
  386. }
  387. }
  388. }
  389. }
  390. static void display_bandwith_evolution(void)
  391. {
  392. float current_bandwith = 0.0;
  393. float current_bandwith_per_node[32] = {0.0};
  394. communication_itor_t itor;
  395. for (itor = communication_list_begin(communication_list);
  396. itor != communication_list_end(communication_list);
  397. itor = communication_list_next(itor))
  398. {
  399. current_bandwith += itor->bandwith;
  400. fprintf(out_paje_file, "13 %f bw MEMNODE0 %f\n",
  401. itor->comm_start, current_bandwith);
  402. current_bandwith_per_node[itor->node] += itor->bandwith;
  403. fprintf(out_paje_file, "13 %f bw MEMNODE%d %f\n",
  404. itor->comm_start, itor->node, current_bandwith_per_node[itor->node]);
  405. }
  406. }
  407. static void handle_start_alloc(void)
  408. {
  409. unsigned memnode = ev.param[0];
  410. fprintf(out_paje_file, "10 %f MS MEMNODE%d A\n", (float)((ev.time-start_time)/1000000.0), memnode);
  411. }
  412. static void handle_end_alloc(void)
  413. {
  414. unsigned memnode = ev.param[0];
  415. fprintf(out_paje_file, "10 %f MS MEMNODE%d No\n", (float)((ev.time-start_time)/1000000.0), memnode);
  416. }
  417. static void handle_start_alloc_reuse(void)
  418. {
  419. unsigned memnode = ev.param[0];
  420. fprintf(out_paje_file, "10 %f MS MEMNODE%d Ar\n", (float)((ev.time-start_time)/1000000.0), memnode);
  421. }
  422. static void handle_end_alloc_reuse(void)
  423. {
  424. unsigned memnode = ev.param[0];
  425. fprintf(out_paje_file, "10 %f MS MEMNODE%d No\n", (float)((ev.time-start_time)/1000000.0), memnode);
  426. }
  427. static void handle_start_memreclaim(void)
  428. {
  429. unsigned memnode = ev.param[0];
  430. fprintf(out_paje_file, "10 %f MS MEMNODE%d R\n", (float)((ev.time-start_time)/1000000.0), memnode);
  431. }
  432. static void handle_end_memreclaim(void)
  433. {
  434. unsigned memnode = ev.param[0];
  435. fprintf(out_paje_file, "10 %f MS MEMNODE%d No\n", (float)((ev.time-start_time)/1000000.0), memnode);
  436. }
  437. static int curq_size = 0;
  438. static void handle_job_push(void)
  439. {
  440. curq_size++;
  441. fprintf(out_paje_file, "13 %f ntask sched %f\n", (float)((ev.time-start_time)/1000000.0), (float)curq_size);
  442. }
  443. static void handle_job_pop(void)
  444. {
  445. curq_size--;
  446. fprintf(out_paje_file, "13 %f ntask sched %f\n", (float)((ev.time-start_time)/1000000.0), (float)curq_size);
  447. }
  448. static void handle_codelet_tag_deps(void)
  449. {
  450. uint64_t child;
  451. uint64_t father;
  452. child = ev.param[0];
  453. father = ev.param[1];
  454. add_deps(child, father);
  455. }
  456. static void handle_task_done(void)
  457. {
  458. uint64_t tag_id;
  459. tag_id = ev.param[0];
  460. unsigned long has_name = ev.param[2];
  461. char *name = has_name?(char *)&ev.param[3]:"unknown";
  462. int worker;
  463. worker = find_workder_id(ev.param[1]);
  464. char *colour;
  465. char buffer[32];
  466. if (per_task_colour) {
  467. snprintf(buffer, 32, "%.4f,%.4f,%.4f",
  468. get_colour_symbol_red(name)/1024.0,
  469. get_colour_symbol_green(name)/1024.0,
  470. get_colour_symbol_blue(name)/1024.0);
  471. colour = &buffer[0];
  472. }
  473. else {
  474. colour=(worker < 0)?"0.0,0.0,0.0":worker_colors[worker];
  475. }
  476. dot_set_tag_done(tag_id, colour);
  477. }
  478. static void parse_args(int argc, char **argv)
  479. {
  480. int i;
  481. for (i = 1; i < argc; i++) {
  482. if (strcmp(argv[i], "-c") == 0) {
  483. per_task_colour = 1;
  484. }
  485. if (strcmp(argv[i], "-o") == 0) {
  486. out_paje_path = argv[++i];
  487. }
  488. if (strcmp(argv[i], "-i") == 0) {
  489. filename = argv[++i];
  490. }
  491. if (strcmp(argv[i], "-no-counter") == 0) {
  492. no_counter = 1;
  493. }
  494. if (strcmp(argv[i], "-no-bus") == 0) {
  495. no_bus = 1;
  496. }
  497. if (strcmp(argv[i], "-d") == 0) {
  498. generate_distrib = 1;
  499. }
  500. if (strcmp(argv[i], "-h") == 0) {
  501. fprintf(stderr, "Usage : %s [-c] [-no-counter] [-no-bus] [-i input_filename] [-o output_filename]\n", argv[0]);
  502. fprintf(stderr, "\t-c: use a different colour for every type of task.\n");
  503. exit(-1);
  504. }
  505. }
  506. }
  507. /*
  508. * This program should be used to parse the log generated by FxT
  509. */
  510. int main(int argc, char **argv)
  511. {
  512. int ret;
  513. int fd_in, fd_out;
  514. int use_stdout = 1;
  515. init_dag_dot();
  516. parse_args(argc, argv);
  517. fd_in = open(filename, O_RDONLY);
  518. if (fd_in < 0) {
  519. perror("open failed :");
  520. exit(-1);
  521. }
  522. fut = fxt_fdopen(fd_in);
  523. if (!fut) {
  524. perror("fxt_fdopen :");
  525. exit(-1);
  526. }
  527. fxt_blockev_t block;
  528. block = fxt_blockev_enter(fut);
  529. /* create a htable to identify each worker(tid) */
  530. hcreate(MAXWORKERS);
  531. symbol_list = symbol_name_list_new();
  532. communication_list = communication_list_new();
  533. paje_output_file_init();
  534. while(1) {
  535. ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  536. if (ret != FXT_EV_OK) {
  537. fprintf(stderr, "no more block ...\n");
  538. break;
  539. }
  540. __attribute__ ((unused)) int nbparam = ev.nb_params;
  541. if (first_event)
  542. {
  543. first_event = 0;
  544. start_time = ev.time;
  545. /* create the "program" container */
  546. fprintf(out_paje_file, "7 %f p P 0 program \n", (float)(start_time-start_time));
  547. /* create a variable with the number of tasks */
  548. if (!no_counter)
  549. {
  550. fprintf(out_paje_file, "7 %f sched Sc p scheduler \n", (float)(start_time-start_time));
  551. fprintf(out_paje_file, "13 %f ntask sched 0.0\n", (float)(start_time-start_time));
  552. }
  553. }
  554. switch (ev.code) {
  555. case FUT_WORKER_INIT_START:
  556. handle_worker_init_start();
  557. break;
  558. case FUT_WORKER_INIT_END:
  559. handle_worker_init_end();
  560. break;
  561. case FUT_NEW_MEM_NODE:
  562. handle_new_mem_node();
  563. break;
  564. /* detect when the workers were idling or not */
  565. case FUT_START_CODELET_BODY:
  566. handle_start_codelet_body();
  567. break;
  568. case FUT_END_CODELET_BODY:
  569. handle_end_codelet_body();
  570. break;
  571. case FUT_START_CALLBACK:
  572. handle_start_callback();
  573. break;
  574. case FUT_END_CALLBACK:
  575. handle_end_callback();
  576. break;
  577. /* monitor stack size */
  578. case FUT_JOB_PUSH:
  579. if (!no_counter)
  580. handle_job_push();
  581. break;
  582. case FUT_JOB_POP:
  583. if (!no_counter)
  584. handle_job_pop();
  585. break;
  586. /* check the memory transfer overhead */
  587. case FUT_START_FETCH_INPUT:
  588. handle_start_fetch_input();
  589. break;
  590. case FUT_END_FETCH_INPUT:
  591. handle_end_fetch_input();
  592. break;
  593. case FUT_START_PUSH_OUTPUT:
  594. handle_start_push_output();
  595. break;
  596. case FUT_END_PUSH_OUTPUT:
  597. handle_end_push_output();
  598. break;
  599. case FUT_START_PROGRESS:
  600. handle_start_progress();
  601. break;
  602. case FUT_END_PROGRESS:
  603. handle_end_progress();
  604. break;
  605. case FUT_CODELET_TAG:
  606. //handle_codelet_tag();
  607. break;
  608. case FUT_CODELET_TAG_DEPS:
  609. handle_codelet_tag_deps();
  610. break;
  611. case FUT_TASK_DONE:
  612. handle_task_done();
  613. break;
  614. case FUT_DATA_COPY:
  615. if (!no_bus)
  616. handle_data_copy();
  617. break;
  618. case FUT_START_DRIVER_COPY:
  619. if (!no_bus)
  620. handle_start_driver_copy();
  621. break;
  622. case FUT_END_DRIVER_COPY:
  623. if (!no_bus)
  624. handle_end_driver_copy();
  625. break;
  626. case FUT_WORK_STEALING:
  627. /* XXX */
  628. break;
  629. case FUT_WORKER_DEINIT_START:
  630. handle_worker_deinit_start();
  631. break;
  632. case FUT_WORKER_DEINIT_END:
  633. handle_worker_deinit_end();
  634. break;
  635. case FUT_START_ALLOC:
  636. if (!no_bus)
  637. handle_start_alloc();
  638. break;
  639. case FUT_END_ALLOC:
  640. if (!no_bus)
  641. handle_end_alloc();
  642. break;
  643. case FUT_START_ALLOC_REUSE:
  644. if (!no_bus)
  645. handle_start_alloc_reuse();
  646. break;
  647. case FUT_END_ALLOC_REUSE:
  648. if (!no_bus)
  649. handle_end_alloc_reuse();
  650. break;
  651. case FUT_START_MEMRECLAIM:
  652. handle_start_memreclaim();
  653. break;
  654. case FUT_END_MEMRECLAIM:
  655. handle_end_memreclaim();
  656. break;
  657. case FUT_USER_EVENT:
  658. handle_user_event();
  659. break;
  660. default:
  661. fprintf(stderr, "unknown event.. %x at time %llx\n", (unsigned)ev.code, (long long unsigned)ev.time);
  662. break;
  663. }
  664. }
  665. display_bandwith_evolution();
  666. paje_output_file_terminate();
  667. terminate_dat_dot();
  668. return 0;
  669. }