starpu_fxt_tool.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2008-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. * Copyright (C) 2020,2021 Federal University of Rio Grande do Sul (UFRGS)
  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. #include <common/fxt.h>
  23. #define PROGNAME "starpu_fxt_tool"
  24. static void usage()
  25. {
  26. fprintf(stderr, "Generate a trace in the Paje format\n\n");
  27. fprintf(stderr, "Usage: %s [ options ]\n", PROGNAME);
  28. fprintf(stderr, "\n");
  29. fprintf(stderr, "Options:\n");
  30. fprintf(stderr, " -i <input file[s]> specify the input file[s]. Several files can be provided,\n");
  31. fprintf(stderr, " or the option specified several times for MPI execution\n");
  32. fprintf(stderr, " case\n");
  33. fprintf(stderr, " -o <output file> specify the paje output filename\n");
  34. fprintf(stderr, " -d <directory> specify the directory in which to save files\n");
  35. fprintf(stderr, " -c use a different colour for every type of task\n");
  36. fprintf(stderr, " -no-events do not show events\n");
  37. fprintf(stderr, " -no-counter do not show scheduler counters\n");
  38. fprintf(stderr, " -no-bus do not show PCI bus transfers\n");
  39. fprintf(stderr, " -no-flops do not show flops\n");
  40. fprintf(stderr, " -no-smooth avoid smoothing values for gflops etc.\n");
  41. fprintf(stderr, " -no-acquire do not show application data acquisitions tasks in DAG\n");
  42. fprintf(stderr, " -label-deps add label on dependencies.\n");
  43. fprintf(stderr, " -memory-states show detailed memory states of handles\n");
  44. fprintf(stderr, " -internal show StarPU-internal tasks in DAG\n");
  45. fprintf(stderr, " -number-events generate a file counting FxT events by type\n");
  46. fprintf(stderr, " -h, --help display this help and exit\n");
  47. fprintf(stderr, " -v, --version output version information and exit\n\n");
  48. fprintf(stderr, "Report bugs to <%s>.", PACKAGE_BUGREPORT);
  49. fprintf(stderr, "\n");
  50. }
  51. static struct starpu_fxt_options options;
  52. static int parse_args(int argc, char **argv)
  53. {
  54. /* Default options */
  55. starpu_fxt_options_init(&options);
  56. /* We want to support arguments such as "fxt_tool -i trace_*" */
  57. unsigned reading_input_filenames = 0;
  58. int i;
  59. for (i = 1; i < argc; i++)
  60. {
  61. int ret = _starpu_generate_paje_trace_read_option(argv[i], &options);
  62. if (ret == 0)
  63. {
  64. reading_input_filenames = 0;
  65. }
  66. else if (strcmp(argv[i], "-o") == 0)
  67. {
  68. free(options.out_paje_path);
  69. options.out_paje_path = strdup(argv[++i]);
  70. reading_input_filenames = 0;
  71. }
  72. else if (strcmp(argv[i], "-d") == 0)
  73. {
  74. options.dir = argv[++i];
  75. reading_input_filenames = 0;
  76. }
  77. else if (strcmp(argv[i], "-i") == 0)
  78. {
  79. if (options.ninputfiles >= STARPU_FXT_MAX_FILES)
  80. {
  81. 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);
  82. return 7;
  83. }
  84. options.filenames[options.ninputfiles++] = argv[++i];
  85. reading_input_filenames = 1;
  86. }
  87. else if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
  88. {
  89. usage();
  90. return 77;
  91. }
  92. else if (strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
  93. {
  94. fputs(PROGNAME " (" PACKAGE_NAME ") " PACKAGE_VERSION "\n", stderr);
  95. return 77;
  96. }
  97. /* That's pretty dirty: if the reading_input_filenames flag is
  98. * set, and that the argument does not match an option, we
  99. * assume this may be another filename */
  100. else if (reading_input_filenames)
  101. {
  102. if (options.ninputfiles >= STARPU_FXT_MAX_FILES)
  103. {
  104. 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);
  105. return 7;
  106. }
  107. options.filenames[options.ninputfiles++] = argv[i];
  108. }
  109. }
  110. if (!options.ninputfiles)
  111. {
  112. fprintf(stderr, "Incorrect usage, aborting\n");
  113. usage();
  114. return 77;
  115. }
  116. return 0;
  117. }
  118. int main(int argc, char **argv)
  119. {
  120. int ret = parse_args(argc, argv);
  121. if (ret)
  122. {
  123. starpu_fxt_options_shutdown(&options);
  124. return ret;
  125. }
  126. starpu_fxt_generate_trace(&options);
  127. starpu_fxt_options_shutdown(&options);
  128. return 0;
  129. }