profiling_helpers.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. int long long sum_transferred = 0;
  22. fprintf(stderr, "\nData transfer statistics:\n");
  23. fprintf(stderr, "*************************\n");
  24. int busid;
  25. int bus_cnt = starpu_bus_get_count();
  26. for (busid = 0; busid < bus_cnt; busid++)
  27. {
  28. int src, dst;
  29. src = starpu_bus_get_src(busid);
  30. dst = starpu_bus_get_dst(busid);
  31. struct starpu_bus_profiling_info bus_info;
  32. starpu_bus_get_profiling_info(busid, &bus_info);
  33. int long long transferred = bus_info.transferred_bytes;
  34. int long long transfer_cnt = bus_info.transfer_count;
  35. double elapsed_time = starpu_timing_timespec_to_us(&bus_info.total_time);
  36. 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));
  37. sum_transferred += transferred;
  38. }
  39. fprintf(stderr, "Total transfers: %.2lf MB\n", (1.0*sum_transferred)/(1024*1024));
  40. }
  41. void starpu_worker_profiling_helper_display_summary(void)
  42. {
  43. double sum_consumed = 0.;
  44. int profiling = starpu_profiling_status_get();
  45. fprintf(stderr, "\nWorker statistics:\n");
  46. fprintf(stderr, "******************\n");
  47. int workerid;
  48. int worker_cnt = starpu_worker_get_count();
  49. for (workerid = 0; workerid < worker_cnt; workerid++)
  50. {
  51. struct starpu_worker_profiling_info info;
  52. starpu_worker_get_profiling_info(workerid, &info);
  53. char name[32];
  54. starpu_worker_get_name(workerid, name, sizeof(name));
  55. if (profiling) {
  56. double total_time = starpu_timing_timespec_to_us(&info.total_time) / 1000.;
  57. double executing_time = starpu_timing_timespec_to_us(&info.executing_time) / 1000.;
  58. double sleeping_time = starpu_timing_timespec_to_us(&info.sleeping_time) / 1000.;
  59. fprintf(stderr, "%-32s\n", name);
  60. 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);
  61. if (info.used_cycles || info.stall_cycles)
  62. fprintf(stderr, "\t%lu Mcy %lu Mcy stall\n", info.used_cycles/1000000, info.stall_cycles/1000000);
  63. if (info.power_consumed)
  64. fprintf(stderr, "\t%lf J consumed\n", info.power_consumed);
  65. } else {
  66. fprintf(stderr, "\t%-32s\tapproximately %d task(s)\n", name, info.executed_tasks);
  67. }
  68. sum_consumed += info.power_consumed;
  69. }
  70. if (profiling && sum_consumed)
  71. fprintf(stderr, "Total consumption: %.2lf J\n", sum_consumed);
  72. }