fxt_stats.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 fxt_t fut;
  18. struct fxt_ev_64 ev;
  19. static uint64_t transfers[16][16];
  20. static void handle_data_copy(void)
  21. {
  22. unsigned src = ev.param[0];
  23. unsigned dst = ev.param[1];
  24. unsigned size = ev.param[2];
  25. transfers[src][dst] += size;
  26. // printf("transfer %d -> %d : %d \n", src, dst, size);
  27. }
  28. /*
  29. * This program should be used to parse the log generated by FxT
  30. */
  31. int main(int argc, char **argv)
  32. {
  33. char *filename = NULL;
  34. int ret;
  35. int fd_in;
  36. if (argc < 2) {
  37. fprintf(stderr, "Usage : %s input_filename [-o output_filename]\n", argv[0]);
  38. exit(-1);
  39. }
  40. filename = argv[1];
  41. fd_in = open(filename, O_RDONLY);
  42. if (fd_in < 0) {
  43. perror("open failed :");
  44. exit(-1);
  45. }
  46. fut = fxt_fdopen(fd_in);
  47. if (!fut) {
  48. perror("fxt_fdopen :");
  49. exit(-1);
  50. }
  51. fxt_blockev_t block;
  52. block = fxt_blockev_enter(fut);
  53. unsigned njob = 0;
  54. unsigned nws = 0;
  55. double start_time = 10e30;
  56. double end_time = -10e30;
  57. while(1) {
  58. ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  59. if (ret != FXT_EV_OK) {
  60. fprintf(stderr, "no more block ...\n");
  61. break;
  62. }
  63. end_time = STARPU_MAX(end_time, ev.time);
  64. start_time = STARPU_MIN(start_time, ev.time);
  65. __attribute__ ((unused)) int nbparam = ev.nb_params;
  66. switch (ev.code) {
  67. case STARPU_FUT_DATA_COPY:
  68. handle_data_copy();
  69. break;
  70. case STARPU_FUT_JOB_POP:
  71. njob++;
  72. break;
  73. case STARPU_FUT_WORK_STEALING:
  74. nws++;
  75. break;
  76. default:
  77. break;
  78. }
  79. }
  80. printf("Start : start time %le end time %le length %le\n", start_time, end_time, end_time - start_time);
  81. unsigned src, dst;
  82. for (src = 0; src < 16; src++)
  83. {
  84. for (dst = 0; dst < 16; dst++)
  85. {
  86. if (transfers[src][dst] != 0) {
  87. printf("%d -> %d \t %ld MB\n", src, dst, transfers[src][dst]/(1024*1024));
  88. }
  89. }
  90. }
  91. printf("There was %d tasks and %d work stealing\n", njob, nws);
  92. return 0;
  93. }