fxt_tool_common.c 3.5 KB

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