dag_dot.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2011 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. if (!out_file) {
  28. fprintf(stderr,"error while opening %s\n", out_path);
  29. perror("fopen");
  30. exit(1);
  31. }
  32. cluster_cnt = 0;
  33. fprintf(out_file, "digraph G {\n");
  34. fprintf(out_file, "\tcolor=white\n");
  35. fprintf(out_file, "\trankdir=LR;\n");
  36. /* Create a new cluster */
  37. fprintf(out_file, "subgraph cluster_%d {\n", cluster_cnt);
  38. fprintf(out_file, "\tcolor=black;\n");
  39. }
  40. void terminate_dat_dot(void)
  41. {
  42. /* Close the last cluster */
  43. fprintf(out_file, "}\n");
  44. /* Close the graph */
  45. fprintf(out_file, "}\n");
  46. fclose(out_file);
  47. }
  48. void add_deps(uint64_t child, uint64_t father)
  49. {
  50. fprintf(out_file, "\t \"tag_%llx\"->\"tag_%llx\"\n",
  51. (unsigned long long)father, (unsigned long long)child);
  52. }
  53. void add_task_deps(unsigned long dep_prev, unsigned long dep_succ)
  54. {
  55. fprintf(out_file, "\t \"task_%lx\"->\"task_%lx\"\n", dep_prev, dep_succ);
  56. }
  57. void dot_set_tag_done(uint64_t tag, const char *color)
  58. {
  59. fprintf(out_file, "\t \"tag_%llx\" \[ style=filled, label=\"\", color=\"%s\"]\n",
  60. (unsigned long long)tag, color);
  61. }
  62. void dot_set_task_done(unsigned long job_id, const char *label, const char *color)
  63. {
  64. fprintf(out_file, "\t \"task_%lx\" \[ style=filled, label=\"%s\", color=\"%s\"]\n", job_id, label, color);
  65. }
  66. void dot_add_sync_point(void)
  67. {
  68. /* Close the previous cluster */
  69. fprintf(out_file, "}\n");
  70. cluster_cnt++;
  71. /* Create a new cluster */
  72. fprintf(out_file, "subgraph cluster_%d {\n", cluster_cnt);
  73. fprintf(out_file, "\tcolor=black;\n");
  74. }