Timing.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #ifndef _TIMING_H_
  2. #define _TIMING_H_
  3. #include "Test.h"
  4. #include "arm_math_types.h"
  5. #include "arm_math_types_f16.h"
  6. void initCycleMeasurement();
  7. void cycleMeasurementStart();
  8. void cycleMeasurementStop();
  9. Testing::cycles_t getCycles();
  10. #if defined(EXTBENCH) || defined(CACHEANALYSIS)
  11. extern unsigned long sectionCounter;
  12. #if defined ( __CC_ARM )
  13. #define dbgInst(imm) __asm volatile{ DBG (imm) }
  14. #elif defined ( __GNUC__ ) || defined ( __llvm__ )
  15. #define dbgInst(imm) __asm volatile("DBG %0\n\t" : :"Ir" ((imm)) )
  16. #else
  17. #error "Unsupported compiler"
  18. #endif
  19. #define startSectionNB(num) dbgInst(((num) & 0x7) | 0x8)
  20. #define stopSectionNB(num) dbgInst(((num) & 0x7) | 0x0)
  21. static inline void startSection() {
  22. switch(sectionCounter & 0x7)
  23. {
  24. case 0:
  25. startSectionNB(0);
  26. break;
  27. case 1:
  28. startSectionNB(1);
  29. break;
  30. case 2:
  31. startSectionNB(2);
  32. break;
  33. case 3:
  34. startSectionNB(3);
  35. break;
  36. case 4:
  37. startSectionNB(4);
  38. break;
  39. case 5:
  40. startSectionNB(5);
  41. break;
  42. case 6:
  43. startSectionNB(6);
  44. break;
  45. case 7:
  46. startSectionNB(7);
  47. break;
  48. default:
  49. startSectionNB(0);
  50. }
  51. }
  52. static inline void stopSection() {
  53. switch(sectionCounter & 0x7)
  54. {
  55. case 0:
  56. stopSectionNB(0);
  57. break;
  58. case 1:
  59. stopSectionNB(1);
  60. break;
  61. case 2:
  62. stopSectionNB(2);
  63. break;
  64. case 3:
  65. stopSectionNB(3);
  66. break;
  67. case 4:
  68. stopSectionNB(4);
  69. break;
  70. case 5:
  71. stopSectionNB(5);
  72. break;
  73. case 6:
  74. stopSectionNB(6);
  75. break;
  76. case 7:
  77. stopSectionNB(7);
  78. break;
  79. default:
  80. stopSectionNB(0);
  81. }
  82. sectionCounter++;
  83. }
  84. #endif
  85. #endif