fxt-tool-common.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 = crc32_string(name, 0);
  44. return (unsigned)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 = crc32_string(name, 0);
  50. return (unsigned)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 = crc32_string(name, 0);
  56. return (unsigned)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. }