datastats.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * StarPU
  3. * Copyright (C) INRIA 2008-2009 (see AUTHORS file)
  4. *
  5. * This program 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. * This program 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 <stdio.h>
  17. #include <datawizard/datastats.h>
  18. #include <common/config.h>
  19. #include <starpu.h>
  20. /* measure the cache hit ratio for each node */
  21. #ifdef DATA_STATS
  22. static unsigned hit_cnt[16];
  23. static unsigned miss_cnt[16];
  24. #endif
  25. inline void msi_cache_hit(unsigned node __attribute__ ((unused)))
  26. {
  27. #ifdef DATA_STATS
  28. hit_cnt[node]++;
  29. #endif
  30. }
  31. inline void msi_cache_miss(unsigned node __attribute__ ((unused)))
  32. {
  33. #ifdef DATA_STATS
  34. miss_cnt[node]++;
  35. #endif
  36. }
  37. void display_msi_stats(void)
  38. {
  39. #ifdef DATA_STATS
  40. fprintf(stderr, "MSI cache stats :\n");
  41. unsigned node;
  42. for (node = 0; node < 4; node++)
  43. {
  44. if (hit_cnt[node]+miss_cnt[node])
  45. {
  46. fprintf(stderr, "memory node %d\n", node);
  47. fprintf(stderr, "\thit : %u (%2.2f \%%)\n", hit_cnt[node], (100.0f*hit_cnt[node])/(hit_cnt[node]+miss_cnt[node]));
  48. fprintf(stderr, "\tmiss : %u (%2.2f \%%)\n", miss_cnt[node], (100.0f*miss_cnt[node])/(hit_cnt[node]+miss_cnt[node]));
  49. }
  50. }
  51. #endif
  52. }
  53. /* measure the efficiency of our allocation cache */
  54. #ifdef DATA_STATS
  55. static unsigned alloc_cnt[16];
  56. static unsigned alloc_cache_hit_cnt[16];
  57. #endif
  58. inline void allocation_cache_hit(unsigned node __attribute__ ((unused)))
  59. {
  60. #ifdef DATA_STATS
  61. alloc_cache_hit_cnt[node]++;
  62. #endif
  63. }
  64. inline void data_allocation_inc_stats(unsigned node __attribute__ ((unused)))
  65. {
  66. #ifdef DATA_STATS
  67. alloc_cnt[node]++;
  68. #endif
  69. }
  70. void display_alloc_cache_stats(void)
  71. {
  72. #ifdef DATA_STATS
  73. fprintf(stderr, "Allocation cache stats:\n");
  74. unsigned node;
  75. for (node = 0; node < 4; node++)
  76. {
  77. if (alloc_cnt[node])
  78. {
  79. fprintf(stderr, "memory node %d\n", node);
  80. fprintf(stderr, "\ttotal alloc : %u\n", alloc_cnt[node]);
  81. fprintf(stderr, "\tcached alloc: %u (%2.2f \%%)\n",
  82. alloc_cache_hit_cnt[node], (100.0f*alloc_cache_hit_cnt[node])/(alloc_cnt[node]));
  83. }
  84. }
  85. #endif
  86. }
  87. /* measure the amount of data transfers between each pair of nodes */
  88. #ifdef DATA_STATS
  89. static size_t comm_ammount[8][8];
  90. void display_comm_ammounts(void)
  91. {
  92. unsigned src, dst;
  93. for (dst = 0; dst < 8; dst++)
  94. for (src = 0; src < 8; src++)
  95. {
  96. if (comm_ammount[src][dst])
  97. fprintf(stderr, "Total comm from %d to %d \t%dMB\n", src, dst, ((unsigned)comm_ammount[src][dst])/(1024*1024));
  98. }
  99. }
  100. inline void update_comm_ammount(uint32_t src_node, uint32_t dst_node, size_t size)
  101. {
  102. comm_ammount[src_node][dst_node] += size;
  103. }
  104. #else
  105. inline void display_comm_ammounts(void)
  106. {
  107. }
  108. #endif