starpu_top_task.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011-2013,2015-2017 CNRS
  4. * Copyright (C) 2012,2014 Université de Bordeaux
  5. * Copyright (C) 2012 Inria
  6. * Copyright (C) 2011 William Braik, Yann Courtois, Jean-Marie Couteyen, Anthony Roy
  7. *
  8. * StarPU is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation; either version 2.1 of the License, or (at
  11. * your option) any later version.
  12. *
  13. * StarPU is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. *
  17. * See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. */
  19. #include <starpu_top.h>
  20. #include <top/starpu_top_message_queue.h>
  21. #include <top/starpu_top_connection.h>
  22. #include <top/starpu_top_core.h>
  23. #include <core/task.h>
  24. #include <stdio.h>
  25. #include <string.h>
  26. #include <common/timing.h>
  27. /********************************************
  28. **************TASK RELATED FUNCTIONS********
  29. *******************************************/
  30. void _starpu_top_task_started(struct starpu_task *task,
  31. int devid,
  32. const struct timespec *ts)
  33. {
  34. unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
  35. STARPU_ASSERT(_starpu_top_status_get());
  36. char *str;
  37. _STARPU_MALLOC(str, sizeof(char)*64);
  38. snprintf(str, 64,
  39. "START;%llu;%d;%llu\n",
  40. taskid,
  41. devid,
  42. _starpu_top_timing_timespec_to_ms(ts));
  43. _starpu_top_message_add(_starpu_top_mt, str);
  44. }
  45. void _starpu_top_task_ended(struct starpu_task *task,
  46. int devid,
  47. const struct timespec *ts)
  48. {
  49. unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
  50. (void) devid; //unused
  51. STARPU_ASSERT(_starpu_top_status_get());
  52. char *str;
  53. _STARPU_MALLOC(str, sizeof(char)*64);
  54. snprintf(str, 64,
  55. "END;%llu;%llu\n",
  56. taskid,
  57. _starpu_top_timing_timespec_to_ms(ts));
  58. _starpu_top_message_add(_starpu_top_mt, str);
  59. }
  60. void __starpu_top_task_prevision_timespec(struct starpu_task *task,
  61. int devid,
  62. const struct timespec* start,
  63. const struct timespec* end)
  64. {
  65. starpu_top_task_prevision(task,
  66. devid,
  67. _starpu_top_timing_timespec_to_ms(start),
  68. _starpu_top_timing_timespec_to_ms(end));
  69. }
  70. void starpu_top_task_prevision(struct starpu_task *task,
  71. int devid,
  72. unsigned long long start,
  73. unsigned long long end)
  74. {
  75. if (!_starpu_top_status_get())
  76. return;
  77. unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
  78. STARPU_ASSERT(_starpu_top_status_get());
  79. struct timespec now;
  80. _starpu_clock_gettime(&now);
  81. char *str;
  82. _STARPU_MALLOC(str, sizeof(char)*200);
  83. snprintf(str, 200,
  84. "PREV;%llu;%d;%llu;%llu;%llu\n",
  85. taskid,
  86. devid,
  87. _starpu_top_timing_timespec_to_ms(&now),
  88. start,
  89. end);
  90. _starpu_top_message_add(_starpu_top_mt, str);
  91. }