fxt_tool_common.c 3.0 KB

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