starpu_fxt_dag.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2010-2013, 2015 Université de Bordeaux
  4. *
  5. * StarPU 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. * StarPU 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 <common/config.h>
  19. #ifdef STARPU_USE_FXT
  20. #include "starpu_fxt.h"
  21. static FILE *out_file;
  22. static unsigned cluster_cnt;
  23. void _starpu_fxt_dag_init(char *out_path)
  24. {
  25. if (!out_path)
  26. {
  27. out_file = NULL;
  28. return;
  29. }
  30. /* create a new file */
  31. out_file = fopen(out_path, "w+");
  32. if (!out_file)
  33. {
  34. fprintf(stderr,"error while opening %s\n", out_path);
  35. perror("fopen");
  36. exit(1);
  37. }
  38. cluster_cnt = 0;
  39. fprintf(out_file, "digraph G {\n");
  40. fprintf(out_file, "\tcolor=white\n");
  41. fprintf(out_file, "\trankdir=LR;\n");
  42. /* Create a new cluster */
  43. fprintf(out_file, "subgraph cluster_%u {\n", cluster_cnt);
  44. fprintf(out_file, "\tcolor=black;\n");
  45. }
  46. void _starpu_fxt_dag_terminate(void)
  47. {
  48. if (!out_file)
  49. return;
  50. /* Close the last cluster */
  51. fprintf(out_file, "}\n");
  52. /* Close the graph */
  53. fprintf(out_file, "}\n");
  54. fclose(out_file);
  55. }
  56. void _starpu_fxt_dag_add_tag(uint64_t tag, unsigned long job_id)
  57. {
  58. if (out_file)
  59. fprintf(out_file, "\t \"tag_%llx\"->\"task_%lu\"->\"tag_%llx\" [style=dashed]\n",
  60. (unsigned long long)tag, (unsigned long)job_id, (unsigned long long) tag);
  61. }
  62. void _starpu_fxt_dag_add_tag_deps(uint64_t child, uint64_t father)
  63. {
  64. if (out_file)
  65. fprintf(out_file, "\t \"tag_%llx\"->\"tag_%llx\"\n",
  66. (unsigned long long)father, (unsigned long long)child);
  67. }
  68. void _starpu_fxt_dag_add_task_deps(unsigned long dep_prev, unsigned long dep_succ)
  69. {
  70. if (out_file)
  71. fprintf(out_file, "\t \"task_%lu\"->\"task_%lu\"\n", dep_prev, dep_succ);
  72. }
  73. void _starpu_fxt_dag_set_tag_done(uint64_t tag, const char *color)
  74. {
  75. if (out_file)
  76. fprintf(out_file, "\t \"tag_%llx\" [ style=filled, fillcolor=\"%s\"]\n",
  77. (unsigned long long)tag, color);
  78. }
  79. void _starpu_fxt_dag_set_task_done(unsigned long job_id, const char *label, const char *color)
  80. {
  81. if (out_file)
  82. fprintf(out_file, "\t \"task_%lu\" [ style=filled, label=\"%s\", fillcolor=\"%s\"]\n", job_id, label, color);
  83. }
  84. void _starpu_fxt_dag_add_sync_point(void)
  85. {
  86. if (!out_file)
  87. return;
  88. /* Close the previous cluster */
  89. fprintf(out_file, "}\n");
  90. cluster_cnt++;
  91. /* Create a new cluster */
  92. fprintf(out_file, "subgraph cluster_%u {\n", cluster_cnt);
  93. fprintf(out_file, "\tcolor=black;\n");
  94. }
  95. #endif /* STARPU_USE_FXT */