dag_dot.c 2.2 KB

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