count.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /*
  2. * functions for counting operations
  3. *
  4. * These functions, and the ones in basic_op.h, makes it possible to measure
  5. * the wMOPS of a codec.
  6. *
  7. * All functions in this file, and in basic_op.h, uppdates a structure so that
  8. * it will be possible the see how many calls to add, mul mulAdd ... that the
  9. * code made, and estimate the wMOPS (and MIPS) for a sertain part of code
  10. *
  11. * It is also possible to measure the wMOPS separatly for different parts
  12. * of the codec.
  13. *
  14. * This is done by creating a counter group (getCounterId) for each part of the
  15. * code that one wants a separte measure for. Before a part of the code
  16. * is executed a call to the "setCounter" function is needed to identify
  17. * which counter group to use.
  18. *
  19. * Currently there is a limit of 255 different counter groups.
  20. *
  21. * In the end of this file there is a pice of code illustration how the
  22. * functions can be used.
  23. */
  24. #ifndef count_h
  25. #define count_h "$Id $"
  26. #define MAXCOUNTERS 256
  27. int getCounterId(char *objectName);
  28. /*
  29. * Create a counter group, the "objectname" will be used when printing
  30. * statistics for this counter group.
  31. *
  32. * Returns 0 if no more counter groups are available.
  33. */
  34. void setCounter(int counterId);
  35. /*
  36. * Defines which counter group to use, default is zero.
  37. */
  38. void Init_WMOPS_counter (void);
  39. /*
  40. * Initiates the current counter group.
  41. */
  42. void Reset_WMOPS_counter (void);
  43. /*
  44. * Resets the current counter group.
  45. */
  46. void WMOPS_output (Word16 notPrintWorstWorstCase);
  47. /*
  48. * Prints the statistics to the screen, if the argument if non zero
  49. * the statistics for worst worst case will not be printed. This is typically
  50. * done for dtx frames.
  51. *
  52. */
  53. Word32 fwc (void);
  54. /*
  55. * worst worst case counter.
  56. *
  57. * This function calculates the worst possible case that can be reached.
  58. *
  59. * This is done by calling this function for each subpart of the calculations
  60. * for a frame. This function then stores the maximum wMOPS for each part.
  61. *
  62. * The WMOPS_output function add together all parts and presents the sum.
  63. */
  64. void move16 (void);
  65. void move32 (void);
  66. void logic16 (void);
  67. void logic32 (void);
  68. void test (void);
  69. /*
  70. * The functions above increases the corresponding operation counter for
  71. * the current counter group.
  72. */
  73. typedef struct
  74. {
  75. Word32 add_ex; /* Complexity Weight of 1 */
  76. Word32 sub_ex;
  77. Word32 abs_s_ex;
  78. Word32 shl_ex;
  79. Word32 shr_ex;
  80. Word32 extract_h_ex;
  81. Word32 extract_l;
  82. Word32 mult_ex;
  83. Word32 L_mult_ex;
  84. Word32 negate_ex;
  85. Word32 round;
  86. Word32 L_mac_ex;
  87. Word32 L_msu_ex;
  88. Word32 L_macNs;
  89. Word32 L_msuNs;
  90. Word32 L_add_ex; /* Complexity Weight of 2 */
  91. Word32 L_sub_ex;
  92. Word32 L_add_c;
  93. Word32 L_sub_c;
  94. Word32 L_negate_ex;
  95. Word32 L_shl_ex;
  96. Word32 L_shr_ex;
  97. Word32 mult_r_ex;
  98. Word32 shr_r;
  99. Word32 shift_r;
  100. Word32 mac_r_ex;
  101. Word32 msu_r_ex;
  102. Word32 L_deposit_h_ex;
  103. Word32 L_deposit_l_ex;
  104. Word32 L_shr_r; /* Complexity Weight of 3 */
  105. Word32 L_shift_r;
  106. Word32 L_abs_ex;
  107. Word32 L_sat; /* Complexity Weight of 4 */
  108. Word32 norm_s_ex; /* Complexity Weight of 15 */
  109. Word32 div_s; /* Complexity Weight of 18 */
  110. Word32 norm_l_ex; /* Complexity Weight of 30 */
  111. Word32 DataMove16; /* Complexity Weight of 1 */
  112. Word32 DataMove32; /* Complexity Weight of 2 */
  113. Word32 Logic16; /* Complexity Weight of 1 */
  114. Word32 Logic32; /* Complexity Weight of 2 */
  115. Word32 Test; /* Complexity Weight of 2 */
  116. }
  117. BASIC_OP;
  118. /*
  119. * Example of how count.h could be used.
  120. *
  121. * In the example below it is assumed that the init_OBJECT functions
  122. * does not use any calls to counter.h or basic_op.h. If this is the case
  123. * a call to the function Reset_WMOPS_counter() must be done after each call
  124. * to init_OBJECT if these operations is not to be included in the statistics.
  125. int main(){
  126. int spe1Id,spe2Id,cheId;
  127. // initiate counters and objects
  128. spe1Id=getCounterId("Spe 5k8");
  129. setCounter(spe1Id);
  130. Init_WMOPS_counter ();
  131. init_spe1(...);
  132. spe2Id=getCounterId("Spe 12k2");
  133. setCounter(spe2Id);
  134. Init_WMOPS_counter ();
  135. init_spe2(...);
  136. cheId=getCounterId("Channel encoder");
  137. setCounter(cheId);
  138. Init_WMOPS_counter ();
  139. init_che(...);
  140. ...
  141. while(data){
  142. test(); // Note this call to test();
  143. if(useSpe1)
  144. setCounter(spe1Id);
  145. else
  146. setCounter(spe2Id);
  147. Reset_WMOPS_counter();
  148. speEncode(...);
  149. WMOPS_output(0); // Normal routine for displaying WMOPS info
  150. setCounter(cheId);
  151. Reset_WMOPS_counter();
  152. preChannelInter(...); fwc(); // Note the call to fwc() for each part
  153. convolve(...); fwc(); // of the channel encoder.
  154. interleave(...); fwc();
  155. WMOPS_output(0); // Normal routine for displaying WMOPS info
  156. }
  157. */
  158. #endif