starpu_top_task.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 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 <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 <sys/time.h>
  25. #include <common/timing.h>
  26. /********************************************
  27. **************TASK RELATED FUNCTIONS********
  28. *******************************************/
  29. void _starpu_top_task_started(struct starpu_task *task,
  30. int devid,
  31. const struct timespec *ts)
  32. {
  33. unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
  34. STARPU_ASSERT(_starpu_top_status_get());
  35. char *str = (char *) malloc(sizeof(char)*64);
  36. snprintf(str, 64,
  37. "START;%llu;%d;%llu\n",
  38. taskid,
  39. devid,
  40. _starpu_top_timing_timespec_to_ms(ts));
  41. _starpu_top_message_add(_starpu_top_mt, str);
  42. }
  43. void _starpu_top_task_ended(struct starpu_task *task,
  44. int devid,
  45. const struct timespec *ts)
  46. {
  47. unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
  48. (void) devid; //unused
  49. STARPU_ASSERT(_starpu_top_status_get());
  50. char *str = (char *) malloc(sizeof(char)*64);
  51. snprintf(str, 64,
  52. "END;%llu;%llu\n",
  53. taskid,
  54. _starpu_top_timing_timespec_to_ms(ts));
  55. _starpu_top_message_add(_starpu_top_mt, str);
  56. }
  57. void __starpu_top_task_prevision_timespec(struct starpu_task *task,
  58. int devid,
  59. const struct timespec* start,
  60. const struct timespec* end)
  61. {
  62. starpu_top_task_prevision(task,
  63. devid,
  64. _starpu_top_timing_timespec_to_ms(start),
  65. _starpu_top_timing_timespec_to_ms(end));
  66. }
  67. void starpu_top_task_prevision(struct starpu_task *task,
  68. int devid,
  69. unsigned long long start,
  70. unsigned long long end)
  71. {
  72. if (!_starpu_top_status_get())
  73. return;
  74. unsigned long long taskid = _starpu_get_job_associated_to_task(task)->job_id;
  75. STARPU_ASSERT(_starpu_top_status_get());
  76. struct timespec now;
  77. _starpu_clock_gettime(&now);
  78. char * str= (char *)malloc(sizeof(char)*200);
  79. snprintf(str, 128,
  80. "PREV;%llu;%d;%llu;%llu;%llu\n",
  81. taskid,
  82. devid,
  83. _starpu_top_timing_timespec_to_ms(&now),
  84. start,
  85. end);
  86. _starpu_top_message_add(_starpu_top_mt, str);
  87. }