starpu_fxt_stats.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011 Centre National de la Recherche Scientifique
  4. *
  5. * StarPU is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU Lesser General Public License as published by
  7. * the Free Software Foundation; either version 2.1 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * StarPU is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. */
  16. //#include "fxt_tool.h"
  17. #include <search.h>
  18. #include <sys/types.h>
  19. #include <sys/stat.h>
  20. #include <fcntl.h>
  21. #include <stdio.h>
  22. #include <stdint.h>
  23. #include <stdlib.h>
  24. #include <common/fxt.h>
  25. #include <common/list.h>
  26. #include <starpu.h>
  27. static fxt_t fut;
  28. struct fxt_ev_64 ev;
  29. static uint64_t transfers[16][16];
  30. static void handle_data_copy(void)
  31. {
  32. unsigned src = ev.param[0];
  33. unsigned dst = ev.param[1];
  34. unsigned size = ev.param[2];
  35. transfers[src][dst] += size;
  36. // printf("transfer %d -> %d : %d \n", src, dst, size);
  37. }
  38. /*
  39. * This program should be used to parse the log generated by FxT
  40. */
  41. int main(int argc, char **argv)
  42. {
  43. char *filename = NULL;
  44. int ret;
  45. int fd_in;
  46. if (argc < 2) {
  47. fprintf(stderr, "Usage : %s input_filename [-o output_filename]\n", argv[0]);
  48. exit(-1);
  49. }
  50. filename = argv[1];
  51. fd_in = open(filename, O_RDONLY);
  52. if (fd_in < 0) {
  53. perror("open failed :");
  54. exit(-1);
  55. }
  56. fut = fxt_fdopen(fd_in);
  57. if (!fut) {
  58. perror("fxt_fdopen :");
  59. exit(-1);
  60. }
  61. fxt_blockev_t block;
  62. block = fxt_blockev_enter(fut);
  63. unsigned njob = 0;
  64. unsigned nws = 0;
  65. double start_time = 10e30;
  66. double end_time = -10e30;
  67. while(1) {
  68. ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  69. if (ret != FXT_EV_OK) {
  70. fprintf(stderr, "no more block ...\n");
  71. break;
  72. }
  73. end_time = STARPU_MAX(end_time, ev.time);
  74. start_time = STARPU_MIN(start_time, ev.time);
  75. __attribute__ ((unused)) int nbparam = ev.nb_params;
  76. switch (ev.code) {
  77. case _STARPU_FUT_DATA_COPY:
  78. handle_data_copy();
  79. break;
  80. case _STARPU_FUT_JOB_POP:
  81. njob++;
  82. break;
  83. case _STARPU_FUT_WORK_STEALING:
  84. nws++;
  85. break;
  86. default:
  87. break;
  88. }
  89. }
  90. printf("Start : start time %e end time %e length %e\n", start_time, end_time, end_time - start_time);
  91. unsigned src, dst;
  92. for (src = 0; src < 16; src++)
  93. {
  94. for (dst = 0; dst < 16; dst++)
  95. {
  96. if (transfers[src][dst] != 0) {
  97. printf("%d -> %d \t %ld MB\n", src, dst, transfers[src][dst]/(1024*1024));
  98. }
  99. }
  100. }
  101. printf("There was %d tasks and %d work stealing\n", njob, nws);
  102. return 0;
  103. }