starpu_fxt_tool.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2008-2014,2016-2018 Université de Bordeaux
  4. * Copyright (C) 2010-2015,2017,2018 CNRS
  5. *
  6. * StarPU is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU Lesser General Public License as published by
  8. * the Free Software Foundation; either version 2.1 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * StarPU is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. *
  15. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. */
  17. /*
  18. * This program should be used to parse the log generated by FxT
  19. */
  20. #include <starpu.h>
  21. #include <common/config.h>
  22. #define PROGNAME "starpu_fxt_tool"
  23. static void usage()
  24. {
  25. fprintf(stderr, "Generate a trace in the Paje format\n\n");
  26. fprintf(stderr, "Usage: %s [ options ]\n", PROGNAME);
  27. fprintf(stderr, "\n");
  28. fprintf(stderr, "Options:\n");
  29. fprintf(stderr, " -i <input file[s]> specify the input file[s]. Several files can be provided,\n");
  30. fprintf(stderr, " or the option specified several times for MPI execution\n");
  31. fprintf(stderr, " case\n");
  32. fprintf(stderr, " -o <output file> specify the output file\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, " -internal show StarPU-internal tasks in DAG\n");
  42. fprintf(stderr, " -h, --help display this help and exit\n");
  43. fprintf(stderr, " -v, --version output version information and exit\n\n");
  44. fprintf(stderr, "Report bugs to <%s>.", PACKAGE_BUGREPORT);
  45. fprintf(stderr, "\n");
  46. }
  47. static struct starpu_fxt_options options;
  48. static int parse_args(int argc, char **argv)
  49. {
  50. /* Default options */
  51. starpu_fxt_options_init(&options);
  52. /* We want to support arguments such as "fxt_tool -i trace_*" */
  53. unsigned reading_input_filenames = 0;
  54. int i;
  55. for (i = 1; i < argc; i++)
  56. {
  57. if (strcmp(argv[i], "-c") == 0)
  58. {
  59. options.per_task_colour = 1;
  60. reading_input_filenames = 0;
  61. continue;
  62. }
  63. if (strcmp(argv[i], "-o") == 0)
  64. {
  65. options.out_paje_path = argv[++i];
  66. reading_input_filenames = 0;
  67. continue;
  68. }
  69. if (strcmp(argv[i], "-i") == 0)
  70. {
  71. options.filenames[options.ninputfiles++] = argv[++i];
  72. reading_input_filenames = 1;
  73. continue;
  74. }
  75. if (strcmp(argv[i], "-no-events") == 0)
  76. {
  77. options.no_events = 1;
  78. reading_input_filenames = 0;
  79. continue;
  80. }
  81. if (strcmp(argv[i], "-no-counter") == 0)
  82. {
  83. options.no_counter = 1;
  84. reading_input_filenames = 0;
  85. continue;
  86. }
  87. if (strcmp(argv[i], "-no-bus") == 0)
  88. {
  89. options.no_bus = 1;
  90. reading_input_filenames = 0;
  91. continue;
  92. }
  93. if (strcmp(argv[i], "-no-flops") == 0)
  94. {
  95. options.no_flops = 1;
  96. reading_input_filenames = 0;
  97. continue;
  98. }
  99. if (strcmp(argv[i], "-no-smooth") == 0)
  100. {
  101. options.no_smooth = 1;
  102. reading_input_filenames = 0;
  103. continue;
  104. }
  105. if (strcmp(argv[i], "-no-acquire") == 0)
  106. {
  107. options.no_acquire = 1;
  108. reading_input_filenames = 0;
  109. continue;
  110. }
  111. if (strcmp(argv[i], "-internal") == 0)
  112. {
  113. options.internal = 1;
  114. reading_input_filenames = 0;
  115. continue;
  116. }
  117. if (strcmp(argv[i], "-label-deps") == 0)
  118. {
  119. options.label_deps = 1;
  120. reading_input_filenames = 0;
  121. continue;
  122. }
  123. if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
  124. {
  125. usage();
  126. return EXIT_SUCCESS;
  127. }
  128. if (strcmp(argv[i], "-v") == 0
  129. || strcmp(argv[i], "--version") == 0)
  130. {
  131. fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
  132. return EXIT_SUCCESS;
  133. }
  134. /* That's pretty dirty: if the reading_input_filenames flag is
  135. * set, and that the argument does not match an option, we
  136. * assume this may be another filename */
  137. if (reading_input_filenames)
  138. {
  139. options.filenames[options.ninputfiles++] = argv[i];
  140. continue;
  141. }
  142. }
  143. if (!options.ninputfiles)
  144. {
  145. fprintf(stderr, "Incorrect usage, aborting\n");
  146. usage();
  147. return 77;
  148. }
  149. return 0;
  150. }
  151. int main(int argc, char **argv)
  152. {
  153. int ret = parse_args(argc, argv);
  154. if (ret) return ret;
  155. starpu_fxt_generate_trace(&options);
  156. return 0;
  157. }