dag_dot.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 <stdio.h>
  17. #include <stdint.h>
  18. #include "fxt_tool.h"
  19. static char *out_path = "dag.dot";
  20. static FILE *out_file;
  21. void init_dag_dot(void)
  22. {
  23. /* create a new file */
  24. out_file = fopen(out_path, "w+");
  25. fprintf(out_file, "digraph G {\n");
  26. fprintf(out_file, "\tcolor=white\n");
  27. fprintf(out_file, "\trankdir=LR;\n");
  28. }
  29. void terminate_dat_dot(void)
  30. {
  31. fprintf(out_file, "}\n");
  32. fclose(out_file);
  33. }
  34. void add_deps(uint64_t child, uint64_t father)
  35. {
  36. fprintf(out_file, "\t \"tag_%llx\"->\"tag_%llx\"\n",
  37. (unsigned long long)father, (unsigned long long)child);
  38. }
  39. void add_task_deps(unsigned long dep_prev, unsigned long dep_succ)
  40. {
  41. fprintf(out_file, "\t \"task_%lx\"->\"task_%lx\"\n", dep_prev, dep_succ);
  42. }
  43. void dot_set_tag_done(uint64_t tag, const char *color)
  44. {
  45. fprintf(out_file, "\t \"tag_%llx\" \[ style=filled, label=\"\", color=\"%s\"]\n",
  46. (unsigned long long)tag, color);
  47. }
  48. void dot_set_task_done(unsigned long job_id, const char *label, const char *color)
  49. {
  50. fprintf(out_file, "\t \"task_%lx\" \[ style=filled, label=\"%s\", color=\"%s\"]\n", job_id, label, color);
  51. }