benchmark_driver.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include "cmsis_os.h"
  2. #include "ImC/imc_kernel.h"
  3. #include "ImC/imc_extension.h"
  4. #include "stm32l5xx_hal.h"
  5. #include <stdio.h>
  6. void vBenchmarkDriver(void *_benchmark)
  7. {
  8. void (*benchmark)(void) = _benchmark;
  9. int i = 0;
  10. #if (imcBENCH_INFINITE_LOOP)
  11. while(1) {
  12. #endif
  13. portDISABLE_INTERRUPTS();
  14. printf("Start benchmark (%d)\r\n", i);
  15. portENABLE_INTERRUPTS();
  16. // HAL_GPIO_WritePin(GPIOF, GPIO_PIN_11, GPIO_PIN_SET);
  17. benchmark();
  18. #if(imcPRINT_STATS)
  19. portDISABLE_INTERRUPTS();
  20. printf("(STAT) checkpoint triggered: %d\r\n", imc_checkpoint_triggered);
  21. printf("(STAT) checkpoint executed: %d\r\n", imc_checkpoint_executed);
  22. printf("(STAT) no forward progress: %d\r\n", no_forward_progress);
  23. portENABLE_INTERRUPTS();
  24. imc_checkpoint_triggered = 0;
  25. imc_checkpoint_executed = 0;
  26. no_forward_progress = 0;
  27. #endif
  28. #if(imcENABLE_ADAPTIVE_LOOP_PASS_COUNT && imcPRINT_LATENCY_OVERHEAD)
  29. unsigned int tick = DWT->CYCCNT;
  30. imc_ticks_total += tick - imc_last_tick;
  31. imc_last_tick = tick;
  32. portDISABLE_INTERRUPTS();
  33. printf("(STAT) cycles in init(): %d\r\n", imc_ticks_init);
  34. printf("(STAT) cycles in getCSC(): %d\r\n", imc_ticks_getCSC);
  35. printf("(STAT) cycles in adjust(): %d\r\n", imc_ticks_adjust);
  36. printf("(STAT) total cycles: %d\r\n", imc_ticks_total);
  37. portENABLE_INTERRUPTS();
  38. imc_ticks_init = 0;
  39. imc_ticks_getCSC = 0;
  40. imc_ticks_adjust = 0;
  41. imc_ticks_total = 0;
  42. #endif
  43. portDISABLE_INTERRUPTS();
  44. printf("End benchmark (%d)\r\n", i++);
  45. portENABLE_INTERRUPTS();
  46. #if (imcUSE_IMC_KERNEL == 1)
  47. vImcInvalidateRecovery();
  48. #endif
  49. // imcREQUEST_CHECKPOINT();
  50. #if (imcBENCH_INFINITE_LOOP)
  51. }
  52. #endif
  53. }