starpu_fxt_tool.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2013 Universite de Bordeaux 1
  4. * Copyright (C) 2012-2013 Centre National de la Recherche Scientifique
  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(char **argv)
  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\n");
  30. fprintf(stderr, " -o <output file> specify the output file\n");
  31. fprintf(stderr, " -c use a different colour for every type of task\n");
  32. fprintf(stderr, " -no-counter set the FxT no counter option\n");
  33. fprintf(stderr, " -no-bus set the FxT no bus option\n");
  34. fprintf(stderr, " -h, --help display this help and exit\n");
  35. fprintf(stderr, " -v, --version output version information and exit\n\n");
  36. fprintf(stderr, "Reports bugs to <"PACKAGE_BUGREPORT">.");
  37. fprintf(stderr, "\n");
  38. }
  39. static struct starpu_fxt_options options;
  40. static void parse_args(int argc, char **argv)
  41. {
  42. /* Default options */
  43. starpu_fxt_options_init(&options);
  44. /* We want to support arguments such as "fxt_tool -i trace_*" */
  45. unsigned reading_input_filenames = 0;
  46. int i;
  47. for (i = 1; i < argc; i++) {
  48. if (strcmp(argv[i], "-c") == 0) {
  49. options.per_task_colour = 1;
  50. reading_input_filenames = 0;
  51. continue;
  52. }
  53. if (strcmp(argv[i], "-o") == 0) {
  54. options.out_paje_path = argv[++i];
  55. reading_input_filenames = 0;
  56. continue;
  57. }
  58. if (strcmp(argv[i], "-i") == 0) {
  59. options.filenames[options.ninputfiles++] = argv[++i];
  60. reading_input_filenames = 1;
  61. continue;
  62. }
  63. if (strcmp(argv[i], "-no-counter") == 0) {
  64. options.no_counter = 1;
  65. reading_input_filenames = 0;
  66. continue;
  67. }
  68. if (strcmp(argv[i], "-no-bus") == 0) {
  69. options.no_bus = 1;
  70. reading_input_filenames = 0;
  71. continue;
  72. }
  73. if (strcmp(argv[i], "-h") == 0
  74. || strcmp(argv[i], "--help") == 0) {
  75. usage(argv);
  76. exit(EXIT_SUCCESS);
  77. }
  78. if (strcmp(argv[i], "-v") == 0
  79. || strcmp(argv[i], "--version") == 0) {
  80. fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
  81. exit(EXIT_SUCCESS);
  82. }
  83. /* That's pretty dirty: if the reading_input_filenames flag is
  84. * set, and that the argument does not match an option, we
  85. * assume this may be another filename */
  86. if (reading_input_filenames)
  87. {
  88. options.filenames[options.ninputfiles++] = argv[i];
  89. continue;
  90. }
  91. }
  92. if (!options.ninputfiles)
  93. {
  94. fprintf(stderr, "Incorrect usage, aborting\n");
  95. usage(argv);
  96. exit(-1);
  97. }
  98. }
  99. int main(int argc, char **argv)
  100. {
  101. parse_args(argc, argv);
  102. starpu_fxt_generate_trace(&options);
  103. return 0;
  104. }