fxt-tool.c 18 KB

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