You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
5.1KB

  1. /*
  2. * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org>
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. */
  18. #ifndef _DSPUTIL_PPC_
  19. #define _DSPUTIL_PPC_
  20. #ifdef POWERPC_TBL_PERFORMANCE_REPORT
  21. void powerpc_display_perf_report(void);
  22. /* if you add to the enum below, also add to the perfname array
  23. in dsputil_ppc.c */
  24. enum powerpc_perf_index {
  25. altivec_fft_num = 0,
  26. altivec_gmc1_num,
  27. altivec_dct_unquantize_h263_num,
  28. altivec_idct_add_num,
  29. altivec_idct_put_num,
  30. altivec_put_pixels16_num,
  31. altivec_avg_pixels16_num,
  32. altivec_avg_pixels8_num,
  33. altivec_put_pixels8_xy2_num,
  34. altivec_put_no_rnd_pixels8_xy2_num,
  35. altivec_put_pixels16_xy2_num,
  36. altivec_put_no_rnd_pixels16_xy2_num,
  37. powerpc_clear_blocks_dcbz32,
  38. powerpc_perf_total
  39. };
  40. enum powerpc_data_index {
  41. powerpc_data_min = 0,
  42. powerpc_data_max,
  43. powerpc_data_sum,
  44. powerpc_data_num,
  45. powerpc_data_total
  46. };
  47. extern unsigned long long perfdata[powerpc_perf_total][powerpc_data_total];
  48. #ifdef POWERPC_PERF_USE_PMC
  49. extern unsigned long long perfdata_miss[powerpc_perf_total][powerpc_data_total];
  50. #endif
  51. #ifndef POWERPC_PERF_USE_PMC
  52. #define POWERPC_GET_CYCLES(a) asm volatile("mftb %0" : "=r" (a))
  53. #define POWERPC_TBL_DECLARE(a, cond) register unsigned long tbl_start, tbl_stop
  54. #define POWERPC_TBL_START_COUNT(a, cond) do { POWERPC_GET_CYCLES(tbl_start); } while (0)
  55. #define POWERPC_TBL_STOP_COUNT(a, cond) do { \
  56. POWERPC_GET_CYCLES(tbl_stop); \
  57. if (tbl_stop > tbl_start) \
  58. { \
  59. unsigned long diff = tbl_stop - tbl_start; \
  60. if (cond) \
  61. { \
  62. if (diff < perfdata[a][powerpc_data_min]) \
  63. perfdata[a][powerpc_data_min] = diff; \
  64. if (diff > perfdata[a][powerpc_data_max]) \
  65. perfdata[a][powerpc_data_max] = diff; \
  66. perfdata[a][powerpc_data_sum] += diff; \
  67. perfdata[a][powerpc_data_num] ++; \
  68. } \
  69. } \
  70. } while (0)
  71. #else /* POWERPC_PERF_USE_PMC */
  72. #define POWERPC_GET_CYCLES(a) asm volatile("mfspr %0, 937" : "=r" (a))
  73. #define POWERPC_GET_MISS(a) asm volatile("mfspr %0, 938" : "=r" (a))
  74. #define POWERPC_TBL_DECLARE(a, cond) register unsigned long cycles_start, cycles_stop, miss_start, miss_stop
  75. #define POWERPC_TBL_START_COUNT(a, cond) do { POWERPC_GET_MISS(miss_start); POWERPC_GET_CYCLES(cycles_start); } while (0)
  76. #define POWERPC_TBL_STOP_COUNT(a, cond) do { \
  77. POWERPC_GET_CYCLES(cycles_stop); \
  78. POWERPC_GET_MISS(miss_stop); \
  79. if (cycles_stop >= cycles_start) \
  80. { \
  81. unsigned long diff = \
  82. cycles_stop - cycles_start; \
  83. if (cond) \
  84. { \
  85. if (diff < perfdata[a][powerpc_data_min]) \
  86. perfdata[a][powerpc_data_min] = diff; \
  87. if (diff > perfdata[a][powerpc_data_max]) \
  88. perfdata[a][powerpc_data_max] = diff; \
  89. perfdata[a][powerpc_data_sum] += diff; \
  90. perfdata[a][powerpc_data_num] ++; \
  91. } \
  92. } \
  93. if (miss_stop >= miss_start) \
  94. { \
  95. unsigned long diff = \
  96. miss_stop - miss_start; \
  97. if (cond) \
  98. { \
  99. if (diff < perfdata_miss[a][powerpc_data_min]) \
  100. perfdata_miss[a][powerpc_data_min] = diff; \
  101. if (diff > perfdata_miss[a][powerpc_data_max]) \
  102. perfdata_miss[a][powerpc_data_max] = diff; \
  103. perfdata_miss[a][powerpc_data_sum] += diff; \
  104. perfdata_miss[a][powerpc_data_num] ++; \
  105. } \
  106. } \
  107. } while (0)
  108. #endif /* POWERPC_PERF_USE_PMC */
  109. #else /* POWERPC_TBL_PERFORMANCE_REPORT */
  110. // those are needed to avoid empty statements.
  111. #define POWERPC_TBL_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
  112. #define POWERPC_TBL_START_COUNT(a, cond) do {} while (0)
  113. #define POWERPC_TBL_STOP_COUNT(a, cond) do {} while (0)
  114. #endif /* POWERPC_TBL_PERFORMANCE_REPORT */
  115. #endif /* _DSPUTIL_PPC_ */