imc_extension.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef INC_IMC_IMC_EXTENSION_H_
  2. #define INC_IMC_IMC_EXTENSION_H_
  3. #ifndef imcBENCH_NAME
  4. #define imcBENCH_NAME vConv2d
  5. #endif
  6. #ifndef imcBENCH_INFINITE_LOOP
  7. #define imcBENCH_INFINITE_LOOP 0
  8. #endif
  9. #ifndef imcPRINT_RECOVERY_MESSAGE
  10. #define imcPRINT_RECOVERY_MESSAGE 0
  11. #endif
  12. #ifndef imcENABLE_STATIC_LOOP_PASS_COUNT
  13. #define imcENABLE_STATIC_LOOP_PASS_COUNT 0
  14. #endif
  15. #ifndef imcENABLE_ADAPTIVE_LOOP_PASS_COUNT
  16. #define imcENABLE_ADAPTIVE_LOOP_PASS_COUNT 1
  17. #endif
  18. #ifndef imcMAX_LOOP_IDS
  19. #define imcMAX_LOOP_IDS 1
  20. #endif
  21. #ifndef imcLOOP_PASS_COUNT
  22. #define imcLOOP_PASS_COUNT 10
  23. #endif
  24. #ifndef imcBENCH_REPEAT_COUNT
  25. #define imcBENCH_REPEAT_COUNT 1
  26. #endif
  27. #ifndef imcPRINT_STATS
  28. #define imcPRINT_STATS 0
  29. #endif
  30. #ifndef imcPRINT_INIT_TIME
  31. #define imcPRINT_INIT_TIME 0
  32. #endif
  33. #ifndef imcPRINT_LATENCY_OVERHEAD
  34. #define imcPRINT_LATENCY_OVERHEAD 0
  35. #endif
  36. #ifndef imcCUSTOM_UNROLL
  37. #define imcCUSTOM_UNROLL 0
  38. #endif
  39. #ifndef imcENABLE_DYNAMIC_CHECKPOINT
  40. #define imcENABLE_DYNAMIC_CHECKPOINT 0
  41. #endif
  42. #define IMC_KERNEL_NVM __attribute__((section(".kernel_nvm")))
  43. #define imcCAP_VOL_HIGH 4800
  44. #define imcCAP_VOL_LOW 3500
  45. #define imcENERGY_TOTAL (imcCAP_VOL_HIGH*imcCAP_VOL_HIGH - imcCAP_VOL_LOW*imcCAP_VOL_LOW)
  46. #if (imcCUSTOM_UNROLL)
  47. // #define STRINGIFY(x) ("clang loop unroll_count(" ##str ")")
  48. #define DO_PRAGMA(x) _Pragma ( #x )
  49. #define IMC_UNROLL(x) DO_PRAGMA( clang loop unroll_count(x+1) )
  50. #define IMC_UNROLL_FULL() DO_PRAGMA( clang loop unroll(full) )
  51. #else
  52. #define IMC_UNROLL(x)
  53. #define IMC_UNROLL_FULL()
  54. #endif
  55. int __imc_get_loop_pass_count(int loop_id);
  56. void __imc_finish_loop_skipping();
  57. void imc_init_energy_estimation();
  58. void imc_recover_estimations();
  59. void imc_backup_estimations();
  60. void imc_print_estimations();
  61. #if (imcPRINT_STATS)
  62. extern int imc_is_passing_loops;
  63. extern int imc_checkpoint_triggered;
  64. extern int imc_checkpoint_executed;
  65. void imc_backup_stats();
  66. void imc_recover_stats();
  67. extern int first_checkpoint;
  68. extern int no_forward_progress;
  69. #endif
  70. #if (imcPRINT_LATENCY_OVERHEAD)
  71. extern unsigned int imc_ticks_init;
  72. extern unsigned int imc_ticks_getCSC;
  73. extern unsigned int imc_ticks_adjust;
  74. extern unsigned int imc_ticks_total;
  75. extern unsigned int imc_last_tick;
  76. void imc_backup_latency_overhead();
  77. void imc_recover_latency_overhead();
  78. #endif
  79. #ifndef imcLOOP_OPT_DEBUG
  80. #define imcLOOP_OPT_DEBUG 0
  81. #endif
  82. void ckptTask();
  83. #endif