profiling_helpers.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* StarPU --- Runtime system for heterogeneous multicore architectures.
  2. *
  3. * Copyright (C) 2011 Université de Bordeaux 1
  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 <starpu.h>
  17. #include <starpu_profiling.h>
  18. #include <profiling/profiling.h>
  19. void starpu_bus_profiling_helper_display_summary(void)
  20. {
  21. const char *stats;
  22. int long long sum_transferred = 0;
  23. if (!((stats = getenv("STARPU_BUS_STATS")) && atoi(stats))) return;
  24. fprintf(stderr, "\nData transfer statistics:\n");
  25. fprintf(stderr, "*************************\n");
  26. int busid;
  27. int bus_cnt = starpu_bus_get_count();
  28. for (busid = 0; busid < bus_cnt; busid++)
  29. {
  30. int src, dst;
  31. src = starpu_bus_get_src(busid);
  32. dst = starpu_bus_get_dst(busid);
  33. struct starpu_bus_profiling_info bus_info;
  34. starpu_bus_get_profiling_info(busid, &bus_info);
  35. int long long transferred = bus_info.transferred_bytes;
  36. int long long transfer_cnt = bus_info.transfer_count;
  37. double elapsed_time = starpu_timing_timespec_to_us(&bus_info.total_time);
  38. fprintf(stderr, "\t%d -> %d\t%.2lf MB\t%.2lfMB/s\t(transfers : %lld - avg %.2lf MB)\n", src, dst, (1.0*transferred)/(1024*1024), transferred/elapsed_time, transfer_cnt, (1.0*transferred)/(transfer_cnt*1024*1024));
  39. sum_transferred += transferred;
  40. }
  41. fprintf(stderr, "Total transfers: %.2lf MB\n", (1.0*sum_transferred)/(1024*1024));
  42. }
  43. void starpu_worker_profiling_helper_display_summary(void)
  44. {
  45. const char *stats;
  46. double sum_consumed = 0.;
  47. int profiling = starpu_profiling_status_get();
  48. double overall_time = 0;
  49. int workerid;
  50. int worker_cnt = starpu_worker_get_count();
  51. if (!((stats = getenv("STARPU_WORKER_STATS")) && atoi(stats))) return;
  52. fprintf(stderr, "\nWorker statistics:\n");
  53. fprintf(stderr, "******************\n");
  54. for (workerid = 0; workerid < worker_cnt; workerid++)
  55. {
  56. struct starpu_worker_profiling_info info;
  57. starpu_worker_get_profiling_info(workerid, &info);
  58. char name[64];
  59. starpu_worker_get_name(workerid, name, sizeof(name));
  60. if (profiling)
  61. {
  62. double total_time = starpu_timing_timespec_to_us(&info.total_time) / 1000.;
  63. double executing_time = starpu_timing_timespec_to_us(&info.executing_time) / 1000.;
  64. double sleeping_time = starpu_timing_timespec_to_us(&info.sleeping_time) / 1000.;
  65. if (total_time > overall_time)
  66. overall_time = total_time;
  67. fprintf(stderr, "%-32s\n", name);
  68. fprintf(stderr, "\t%d task(s)\n\ttotal: %.2lf ms executing: %.2lf ms sleeping: %.2lf\n", info.executed_tasks, total_time, executing_time, sleeping_time);
  69. if (info.used_cycles || info.stall_cycles)
  70. fprintf(stderr, "\t%lu Mcy %lu Mcy stall\n", info.used_cycles/1000000, info.stall_cycles/1000000);
  71. if (info.power_consumed)
  72. fprintf(stderr, "\t%f J consumed\n", info.power_consumed);
  73. }
  74. else
  75. {
  76. fprintf(stderr, "\t%-32s\t%d task(s)\n", name, info.executed_tasks);
  77. }
  78. sum_consumed += info.power_consumed;
  79. }
  80. if (profiling)
  81. {
  82. const char *strval_idle_power = getenv("STARPU_IDLE_POWER");
  83. if (strval_idle_power)
  84. {
  85. double idle_power = atof(strval_idle_power); /* Watt */
  86. double idle_consumption = idle_power * overall_time / 1000.; /* J */
  87. fprintf(stderr, "Idle consumption: %.2lf J\n", idle_consumption);
  88. sum_consumed += idle_consumption;
  89. }
  90. }
  91. if (profiling && sum_consumed)
  92. fprintf(stderr, "Total consumption: %.2lf J\n", sum_consumed);
  93. }