starpu_top_task.c 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011 William Braik, Yann Courtois, Jean-Marie Couteyen, Anthony Roy
  4. * Copyright (C) 2011, 2013 CNRS
  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 <starpu_top.h>
  18. #include <top/starpu_top_message_queue.h>
  19. #include <top/starpu_top_connection.h>
  20. #include <top/starpu_top_core.h>
  21. #include <core/task.h>
  22. #include <stdio.h>
  23. #include <string.h>
  24. #include <common/timing.h>
  25. /********************************************
  26. **************TASK RELATED FUNCTIONS********
  27. *******************************************/
  28. void _starpu_top_task_started(struct starpu_task *task,
  29. int devid,
  30. const struct timespec *ts)
  31. {
  32. unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
  33. STARPU_ASSERT(_starpu_top_status_get());
  34. char *str = (char *) malloc(sizeof(char)*64);
  35. snprintf(str, 64,
  36. "START;%llu;%d;%llu\n",
  37. taskid,
  38. devid,
  39. _starpu_top_timing_timespec_to_ms(ts));
  40. _starpu_top_message_add(_starpu_top_mt, str);
  41. }
  42. void _starpu_top_task_ended(struct starpu_task *task,
  43. int devid,
  44. const struct timespec *ts)
  45. {
  46. unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
  47. (void) devid; //unused
  48. STARPU_ASSERT(_starpu_top_status_get());
  49. char *str = (char *) malloc(sizeof(char)*64);
  50. snprintf(str, 64,
  51. "END;%llu;%llu\n",
  52. taskid,
  53. _starpu_top_timing_timespec_to_ms(ts));
  54. _starpu_top_message_add(_starpu_top_mt, str);
  55. }
  56. void __starpu_top_task_prevision_timespec(struct starpu_task *task,
  57. int devid,
  58. const struct timespec* start,
  59. const struct timespec* end)
  60. {
  61. starpu_top_task_prevision(task,
  62. devid,
  63. _starpu_top_timing_timespec_to_ms(start),
  64. _starpu_top_timing_timespec_to_ms(end));
  65. }
  66. void starpu_top_task_prevision(struct starpu_task *task,
  67. int devid,
  68. unsigned long long start,
  69. unsigned long long end)
  70. {
  71. if (!_starpu_top_status_get())
  72. return;
  73. unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
  74. STARPU_ASSERT(_starpu_top_status_get());
  75. struct timespec now;
  76. _starpu_clock_gettime(&now);
  77. char * str= (char *)malloc(sizeof(char)*200);
  78. snprintf(str, 128,
  79. "PREV;%llu;%d;%llu;%llu;%llu\n",
  80. taskid,
  81. devid,
  82. _starpu_top_timing_timespec_to_ms(&now),
  83. start,
  84. end);
  85. _starpu_top_message_add(_starpu_top_mt, str);
  86. }