dag_dot.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 <stdio.h>
  18. #include <stdint.h>
  19. #include "fxt_tool.h"
  20. static char *out_path = "dag.dot";
  21. static FILE *out_file;
  22. static unsigned cluster_cnt;
  23. void init_dag_dot(void)
  24. {
  25. /* create a new file */
  26. out_file = fopen(out_path, "w+");
  27. cluster_cnt = 0;
  28. fprintf(out_file, "digraph G {\n");
  29. fprintf(out_file, "\tcolor=white\n");
  30. fprintf(out_file, "\trankdir=LR;\n");
  31. /* Create a new cluster */
  32. fprintf(out_file, "subgraph cluster_%d {\n", cluster_cnt);
  33. fprintf(out_file, "\tcolor=black;\n");
  34. }
  35. void terminate_dat_dot(void)
  36. {
  37. /* Close the last cluster */
  38. fprintf(out_file, "}\n");
  39. /* Close the graph */
  40. fprintf(out_file, "}\n");
  41. fclose(out_file);
  42. }
  43. void add_deps(uint64_t child, uint64_t father)
  44. {
  45. fprintf(out_file, "\t \"tag_%llx\"->\"tag_%llx\"\n",
  46. (unsigned long long)father, (unsigned long long)child);
  47. }
  48. void add_task_deps(unsigned long dep_prev, unsigned long dep_succ)
  49. {
  50. fprintf(out_file, "\t \"task_%lx\"->\"task_%lx\"\n", dep_prev, dep_succ);
  51. }
  52. void dot_set_tag_done(uint64_t tag, const char *color)
  53. {
  54. fprintf(out_file, "\t \"tag_%llx\" \[ style=filled, label=\"\", color=\"%s\"]\n",
  55. (unsigned long long)tag, color);
  56. }
  57. void dot_set_task_done(unsigned long job_id, const char *label, const char *color)
  58. {
  59. fprintf(out_file, "\t \"task_%lx\" \[ style=filled, label=\"%s\", color=\"%s\"]\n", job_id, label, color);
  60. }
  61. void dot_add_sync_point(void)
  62. {
  63. /* Close the previous cluster */
  64. fprintf(out_file, "}\n");
  65. cluster_cnt++;
  66. /* Create a new cluster */
  67. fprintf(out_file, "subgraph cluster_%d {\n", cluster_cnt);
  68. fprintf(out_file, "\tcolor=black;\n");
  69. }