fxt_tool_common.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /*
  2. * StarPU
  3. * Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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. #include "fxt_tool.h"
  17. static char *cpus_worker_colors[STARPU_NMAXWORKERS] = {"/greens9/7", "/greens9/6", "/greens9/5", "/greens9/4", "/greens9/9", "/greens9/3", "/greens9/2", "/greens9/1" };
  18. static char *cuda_worker_colors[STARPU_NMAXWORKERS] = {"/ylorrd9/9", "/ylorrd9/6", "/ylorrd9/3", "/ylorrd9/1", "/ylorrd9/8", "/ylorrd9/7", "/ylorrd9/4", "/ylorrd9/2", "/ylorrd9/1"};
  19. static char *opencl_worker_colors[STARPU_NMAXWORKERS] = {"/blues9/9", "/blues9/6", "/blues9/3", "/blues9/1", "/blues9/8", "/blues9/7", "/blues9/4", "/blues9/2", "/blues9/1"};
  20. static char *other_worker_colors[STARPU_NMAXWORKERS] = {"/greys9/9", "/greys9/8", "/greys9/7", "/greys9/6"};
  21. static char *worker_colors[STARPU_NMAXWORKERS];
  22. static unsigned opencl_index = 0;
  23. static unsigned cuda_index = 0;
  24. static unsigned cpus_index = 0;
  25. static unsigned other_index = 0;
  26. void set_next_other_worker_color(int workerid)
  27. {
  28. worker_colors[workerid] = other_worker_colors[other_index++];
  29. }
  30. void set_next_cpu_worker_color(int workerid)
  31. {
  32. worker_colors[workerid] = cpus_worker_colors[cpus_index++];
  33. }
  34. void set_next_cuda_worker_color(int workerid)
  35. {
  36. worker_colors[workerid] = cuda_worker_colors[cuda_index++];
  37. }
  38. void set_next_opencl_worker_color(int workerid)
  39. {
  40. worker_colors[workerid] = opencl_worker_colors[opencl_index++];
  41. }
  42. const char *get_worker_color(int workerid)
  43. {
  44. return worker_colors[workerid];
  45. }
  46. unsigned get_colour_symbol_red(char *name)
  47. {
  48. /* choose some colour ... that's disguting yes */
  49. uint32_t hash_symbol = _starpu_crc32_string(name, 0);
  50. return (unsigned)_starpu_crc32_string("red", hash_symbol) % 1024;
  51. }
  52. unsigned get_colour_symbol_green(char *name)
  53. {
  54. /* choose some colour ... that's disguting yes */
  55. uint32_t hash_symbol = _starpu_crc32_string(name, 0);
  56. return (unsigned)_starpu_crc32_string("green", hash_symbol) % 1024;
  57. }
  58. unsigned get_colour_symbol_blue(char *name)
  59. {
  60. /* choose some colour ... that's disguting yes */
  61. uint32_t hash_symbol = _starpu_crc32_string(name, 0);
  62. return (unsigned)_starpu_crc32_string("blue", hash_symbol) % 1024;
  63. }
  64. /* This must be called when we start handling a new trace */
  65. void reinit_colors(void)
  66. {
  67. other_index = 0;
  68. cpus_index = 0;
  69. cuda_index = 0;
  70. }
  71. uint64_t find_start_time(char *filename_in)
  72. {
  73. /* Open the trace file */
  74. int fd_in;
  75. fd_in = open(filename_in, O_RDONLY);
  76. if (fd_in < 0) {
  77. perror("open failed :");
  78. exit(-1);
  79. }
  80. static fxt_t fut;
  81. fut = fxt_fdopen(fd_in);
  82. if (!fut) {
  83. perror("fxt_fdopen :");
  84. exit(-1);
  85. }
  86. fxt_blockev_t block;
  87. block = fxt_blockev_enter(fut);
  88. struct fxt_ev_64 ev;
  89. int ret = fxt_next_ev(block, FXT_EV_TYPE_64, (struct fxt_ev *)&ev);
  90. STARPU_ASSERT (ret == FXT_EV_OK);
  91. /* Close the trace file */
  92. if (close(fd_in))
  93. {
  94. perror("close failed :");
  95. exit(-1);
  96. }
  97. return (ev.time);
  98. }