starpu_fxt_tool.c 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2008-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  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. /*
  17. * This program should be used to parse the log generated by FxT
  18. */
  19. #include <starpu.h>
  20. #include <common/config.h>
  21. #define PROGNAME "starpu_fxt_tool"
  22. static void usage()
  23. {
  24. fprintf(stderr, "Generate a trace in the Paje format\n\n");
  25. fprintf(stderr, "Usage: %s [ options ]\n", PROGNAME);
  26. fprintf(stderr, "\n");
  27. fprintf(stderr, "Options:\n");
  28. fprintf(stderr, " -i <input file[s]> specify the input file[s]. Several files can be provided,\n");
  29. fprintf(stderr, " or the option specified several times for MPI execution\n");
  30. fprintf(stderr, " case\n");
  31. fprintf(stderr, " -o <output file> specify the paje output filename\n");
  32. fprintf(stderr, " -d <directory> specify the directory in which to save files\n");
  33. fprintf(stderr, " -c use a different colour for every type of task\n");
  34. fprintf(stderr, " -no-events do not show events\n");
  35. fprintf(stderr, " -no-counter do not show scheduler counters\n");
  36. fprintf(stderr, " -no-bus do not show PCI bus transfers\n");
  37. fprintf(stderr, " -no-flops do not show flops\n");
  38. fprintf(stderr, " -no-smooth avoid smoothing values for gflops etc.\n");
  39. fprintf(stderr, " -no-acquire do not show application data acquisitions tasks in DAG\n");
  40. fprintf(stderr, " -label-deps add label on dependencies.\n");
  41. fprintf(stderr, " -memory-states show detailed memory states of handles\n");
  42. fprintf(stderr, " -internal show StarPU-internal tasks in DAG\n");
  43. fprintf(stderr, " -number-events generate a file counting FxT events by type\n");
  44. fprintf(stderr, " -h, --help display this help and exit\n");
  45. fprintf(stderr, " -v, --version output version information and exit\n\n");
  46. fprintf(stderr, "Report bugs to <%s>.", PACKAGE_BUGREPORT);
  47. fprintf(stderr, "\n");
  48. }
  49. static struct starpu_fxt_options options;
  50. static int parse_args(int argc, char **argv)
  51. {
  52. /* Default options */
  53. starpu_fxt_options_init(&options);
  54. /* We want to support arguments such as "fxt_tool -i trace_*" */
  55. unsigned reading_input_filenames = 0;
  56. int i;
  57. for (i = 1; i < argc; i++)
  58. {
  59. if (strcmp(argv[i], "-c") == 0)
  60. {
  61. options.per_task_colour = 1;
  62. reading_input_filenames = 0;
  63. continue;
  64. }
  65. if (strcmp(argv[i], "-o") == 0)
  66. {
  67. free(options.out_paje_path);
  68. options.out_paje_path = strdup(argv[++i]);
  69. reading_input_filenames = 0;
  70. continue;
  71. }
  72. if (strcmp(argv[i], "-d") == 0)
  73. {
  74. options.dir = argv[++i];
  75. reading_input_filenames = 0;
  76. continue;
  77. }
  78. if (strcmp(argv[i], "-i") == 0)
  79. {
  80. if (options.ninputfiles >= STARPU_FXT_MAX_FILES)
  81. {
  82. fprintf(stderr, "Error: The number of trace files is superior to STARPU_FXT_MAX_FILES (%d)\nPlease recompile StarPU with a bigger --enable-fxt-max-files\n", STARPU_FXT_MAX_FILES);
  83. return 7;
  84. }
  85. options.filenames[options.ninputfiles++] = argv[++i];
  86. reading_input_filenames = 1;
  87. continue;
  88. }
  89. if (strcmp(argv[i], "-no-events") == 0)
  90. {
  91. options.no_events = 1;
  92. reading_input_filenames = 0;
  93. continue;
  94. }
  95. if (strcmp(argv[i], "-number-events") == 0)
  96. {
  97. options.number_events_path = strdup("number_events.data");
  98. reading_input_filenames = 0;
  99. continue;
  100. }
  101. if (strcmp(argv[i], "-no-counter") == 0)
  102. {
  103. options.no_counter = 1;
  104. reading_input_filenames = 0;
  105. continue;
  106. }
  107. if (strcmp(argv[i], "-no-bus") == 0)
  108. {
  109. options.no_bus = 1;
  110. reading_input_filenames = 0;
  111. continue;
  112. }
  113. if (strcmp(argv[i], "-no-flops") == 0)
  114. {
  115. options.no_flops = 1;
  116. reading_input_filenames = 0;
  117. continue;
  118. }
  119. if (strcmp(argv[i], "-no-smooth") == 0)
  120. {
  121. options.no_smooth = 1;
  122. reading_input_filenames = 0;
  123. continue;
  124. }
  125. if (strcmp(argv[i], "-no-acquire") == 0)
  126. {
  127. options.no_acquire = 1;
  128. reading_input_filenames = 0;
  129. continue;
  130. }
  131. if (strcmp(argv[i], "-memory-states") == 0)
  132. {
  133. options.memory_states = 1;
  134. reading_input_filenames = 0;
  135. continue;
  136. }
  137. if (strcmp(argv[i], "-internal") == 0)
  138. {
  139. options.internal = 1;
  140. reading_input_filenames = 0;
  141. continue;
  142. }
  143. if (strcmp(argv[i], "-label-deps") == 0)
  144. {
  145. options.label_deps = 1;
  146. reading_input_filenames = 0;
  147. continue;
  148. }
  149. if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
  150. {
  151. usage();
  152. return 77;
  153. }
  154. if (strcmp(argv[i], "-v") == 0
  155. || strcmp(argv[i], "--version") == 0)
  156. {
  157. fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
  158. return 77;
  159. }
  160. /* That's pretty dirty: if the reading_input_filenames flag is
  161. * set, and that the argument does not match an option, we
  162. * assume this may be another filename */
  163. if (reading_input_filenames)
  164. {
  165. if (options.ninputfiles >= STARPU_FXT_MAX_FILES)
  166. {
  167. fprintf(stderr, "Error: The number of trace files is superior to STARPU_FXT_MAX_FILES (%d)\nPlease recompile StarPU with a bigger --enable-fxt-max-files\n", STARPU_FXT_MAX_FILES);
  168. return 7;
  169. }
  170. options.filenames[options.ninputfiles++] = argv[i];
  171. continue;
  172. }
  173. }
  174. if (!options.ninputfiles)
  175. {
  176. fprintf(stderr, "Incorrect usage, aborting\n");
  177. usage();
  178. return 77;
  179. }
  180. return 0;
  181. }
  182. int main(int argc, char **argv)
  183. {
  184. int ret = parse_args(argc, argv);
  185. if (ret)
  186. {
  187. starpu_fxt_options_shutdown(&options);
  188. return ret;
  189. }
  190. starpu_fxt_generate_trace(&options);
  191. starpu_fxt_options_shutdown(&options);
  192. return 0;
  193. }