main_fifobench.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #include <cstdio>
  2. #include <cstdint>
  3. #if defined(COMMAND_LINE)
  4. #include <cstdlib>
  5. #endif
  6. #include "arm_math.h"
  7. #include "scheduler.h"
  8. #include "RTE_Components.h"
  9. #include CMSIS_device_header
  10. #include "cmsis_os2.h"
  11. float32_t input_buffer[192]={0};
  12. float32_t output_buffer[192]={0};
  13. extern "C" {
  14. extern void initCycleMeasurement();
  15. extern void cycleMeasurementStart();
  16. extern void cycleMeasurementStop();
  17. extern int32_t getCycles();
  18. }
  19. #define OVERHEADLOOP 100
  20. uint32_t memtest[50]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,
  21. 29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49};
  22. void mem(const uint32_t * ptr)
  23. {
  24. __asm volatile ("LDR R0,[%[src],#4]\n"
  25. "LDR R0,[%[src],#4]\n"
  26. "LDR R0,[%[src],#4]\n"
  27. "LDR R0,[%[src],#4]\n"
  28. "LDR R0,[%[src],#4]\n"
  29. "LDR R0,[%[src],#4]\n"
  30. "LDR R0,[%[src],#4]\n"
  31. "LDR R0,[%[src],#4]\n"
  32. "LDR R0,[%[src],#4]\n"
  33. "LDR R0,[%[src],#4]\n"
  34. "LDR R0,[%[src],#4]\n"
  35. "LDR R0,[%[src],#4]\n"
  36. "LDR R0,[%[src],#4]\n"
  37. "LDR R0,[%[src],#4]\n"
  38. "LDR R0,[%[src],#4]\n"
  39. "LDR R0,[%[src],#4]\n"
  40. "LDR R0,[%[src],#4]\n"
  41. "LDR R0,[%[src],#4]\n"
  42. "LDR R0,[%[src],#4]\n"
  43. "LDR R0,[%[src],#4]\n"
  44. "LDR R0,[%[src],#4]\n"
  45. "LDR R0,[%[src],#4]\n"
  46. "LDR R0,[%[src],#4]\n"
  47. "LDR R0,[%[src],#4]\n"
  48. "LDR R0,[%[src],#4]\n"
  49. "LDR R0,[%[src],#4]\n"
  50. "LDR R0,[%[src],#4]\n"
  51. "LDR R0,[%[src],#4]\n"
  52. "LDR R0,[%[src],#4]\n"
  53. "LDR R0,[%[src],#4]\n"
  54. "LDR R0,[%[src],#4]\n"
  55. "LDR R0,[%[src],#4]\n"
  56. "LDR R0,[%[src],#4]\n"
  57. "LDR R0,[%[src],#4]\n"
  58. "LDR R0,[%[src],#4]\n"
  59. "LDR R0,[%[src],#4]\n"
  60. "LDR R0,[%[src],#4]\n"
  61. "LDR R0,[%[src],#4]\n"
  62. "LDR R0,[%[src],#4]\n"
  63. "LDR R0,[%[src],#4]\n"
  64. "LDR R0,[%[src],#4]\n"
  65. "LDR R0,[%[src],#4]\n"
  66. "LDR R0,[%[src],#4]\n"
  67. "LDR R0,[%[src],#4]\n"
  68. "LDR R0,[%[src],#4]\n"
  69. "LDR R0,[%[src],#4]\n"
  70. "LDR R0,[%[src],#4]\n"
  71. "LDR R0,[%[src],#4]\n"
  72. "LDR R0,[%[src],#4]\n"
  73. "LDR R0,[%[src],#4]\n"
  74. :[src] "+r" (ptr)
  75. :
  76. :"memory","r0"
  77. );
  78. }
  79. int main(void)
  80. {
  81. // System Initialization
  82. SystemCoreClockUpdate();
  83. int error;
  84. uint32_t nbSched = 0;
  85. int32_t overhead = 0;
  86. printf("Start\n\r");
  87. initCycleMeasurement();
  88. for(int i=0;i<OVERHEADLOOP;i++)
  89. {
  90. cycleMeasurementStart();
  91. mem(memtest);
  92. cycleMeasurementStop();
  93. overhead += getCycles() - 50;
  94. }
  95. overhead = overhead / OVERHEADLOOP;
  96. printf("Measurement overhead %d\r\n",overhead);
  97. cycleMeasurementStart();
  98. nbSched=scheduler(&error,input_buffer,output_buffer);
  99. cycleMeasurementStop();
  100. int32_t cycles = (getCycles() - overhead)/nbSched;
  101. printf("Number of schedule iterations = %d\n\r",nbSched);
  102. printf("Error code = %d\n\r",error);
  103. printf("Cycles per iteration = %d\n\r",cycles);
  104. #if defined(COMMAND_LINE)
  105. exit(0);
  106. #else
  107. osThreadExit();
  108. #endif
  109. }