starpu_fxt_tool.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2014, 2016-2017 Universite de Bordeaux
  4. * Copyright (C) 2012-2015 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 <config.h>
  21. #include <starpu.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> specify the input file. This can be specified several\n");
  30. fprintf(stderr, " times for MPI execution case\n");
  31. fprintf(stderr, " -o <output file> specify the output file\n");
  32. fprintf(stderr, " -c use a different colour for every type of task\n");
  33. fprintf(stderr, " -no-counter do not show scheduler counters\n");
  34. fprintf(stderr, " -no-bus do not show PCI bus transfers\n");
  35. fprintf(stderr, " -no-flops do not show flops\n");
  36. fprintf(stderr, " -no-smooth avoid smoothing values for gflops etc.\n");
  37. fprintf(stderr, " -h, --help display this help and exit\n");
  38. fprintf(stderr, " -v, --version output version information and exit\n\n");
  39. fprintf(stderr, "Report bugs to <"PACKAGE_BUGREPORT">.");
  40. fprintf(stderr, "\n");
  41. }
  42. static struct starpu_fxt_options options;
  43. static int parse_args(int argc, char **argv)
  44. {
  45. /* Default options */
  46. starpu_fxt_options_init(&options);
  47. /* We want to support arguments such as "fxt_tool -i trace_*" */
  48. unsigned reading_input_filenames = 0;
  49. int i;
  50. for (i = 1; i < argc; i++)
  51. {
  52. if (strcmp(argv[i], "-c") == 0)
  53. {
  54. options.per_task_colour = 1;
  55. reading_input_filenames = 0;
  56. continue;
  57. }
  58. if (strcmp(argv[i], "-o") == 0)
  59. {
  60. options.out_paje_path = argv[++i];
  61. reading_input_filenames = 0;
  62. continue;
  63. }
  64. if (strcmp(argv[i], "-i") == 0)
  65. {
  66. options.filenames[options.ninputfiles++] = argv[++i];
  67. reading_input_filenames = 1;
  68. continue;
  69. }
  70. if (strcmp(argv[i], "-no-counter") == 0)
  71. {
  72. options.no_counter = 1;
  73. reading_input_filenames = 0;
  74. continue;
  75. }
  76. if (strcmp(argv[i], "-no-bus") == 0)
  77. {
  78. options.no_bus = 1;
  79. reading_input_filenames = 0;
  80. continue;
  81. }
  82. if (strcmp(argv[i], "-no-flops") == 0)
  83. {
  84. options.no_flops = 1;
  85. reading_input_filenames = 0;
  86. continue;
  87. }
  88. if (strcmp(argv[i], "-no-smooth") == 0)
  89. {
  90. options.no_smooth = 1;
  91. reading_input_filenames = 0;
  92. continue;
  93. }
  94. if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
  95. {
  96. usage();
  97. return EXIT_SUCCESS;
  98. }
  99. if (strcmp(argv[i], "-v") == 0
  100. || strcmp(argv[i], "--version") == 0)
  101. {
  102. fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
  103. return EXIT_SUCCESS;
  104. }
  105. /* That's pretty dirty: if the reading_input_filenames flag is
  106. * set, and that the argument does not match an option, we
  107. * assume this may be another filename */
  108. if (reading_input_filenames)
  109. {
  110. options.filenames[options.ninputfiles++] = argv[i];
  111. continue;
  112. }
  113. }
  114. if (!options.ninputfiles)
  115. {
  116. fprintf(stderr, "Incorrect usage, aborting\n");
  117. usage();
  118. return 77;
  119. }
  120. return 0;
  121. }
  122. int main(int argc, char **argv)
  123. {
  124. int ret = parse_args(argc, argv);
  125. if (ret) return ret;
  126. starpu_fxt_generate_trace(&options);
  127. return 0;
  128. }