Nanang Izzuddin | 57b8857 | 2009-04-01 12:05:34 +0000 | [diff] [blame^] | 1 | /* |
| 2 | =========================================================================== |
| 3 | COUNT.H |
| 4 | ~~~~~~~ |
| 5 | |
| 6 | Prototypes and definitions for counting operations |
| 7 | |
| 8 | These functions, and the ones in basop32.h, makes it possible to |
| 9 | measure the wMOPS of a codec. |
| 10 | |
| 11 | All functions in this file, and in basop32.h, updates a structure |
| 12 | so that it will be possible the see how many calls to add, mul mulAdd |
| 13 | ... that the code made, and estimate the wMOPS (and MIPS) for a |
| 14 | sertain part of code |
| 15 | |
| 16 | It is also possible to measure the wMOPS separatly for different |
| 17 | parts of the codec. |
| 18 | |
| 19 | This is done by creating a counter group (getCounterId) for each part |
| 20 | of the code that one wants a separte measure for. Before a part of |
| 21 | the code is executed a call to the "setCounter" function is needed to |
| 22 | identify which counter group to use. |
| 23 | |
| 24 | Currently there is a limit of 255 different counter groups. |
| 25 | |
| 26 | In the end of this file there is a pice of code illustration how the |
| 27 | functions can be used. |
| 28 | |
| 29 | History |
| 30 | ~~~~~~~ |
| 31 | 09.Aug.1999 V1.0.0 Input to UGST from ETSI AMR (count.h); |
| 32 | 26.Jan.2000 V1.1.0 Added counter entries for G.723.1's |
| 33 | L_mls(), div_l(), i_mult() [from basop32.c] |
| 34 | 05.Jul.2000 V1.2.0 Added counter entries for 32bit shiftless |
| 35 | operators L_mult0(), L_mac0(), L_msu0() |
| 36 | =========================================================================== |
| 37 | */ |
| 38 | #ifndef COUNT_H |
| 39 | #define COUNT_H "$Id $" |
| 40 | |
| 41 | #define MAXCOUNTERS 256 |
| 42 | |
| 43 | int getCounterId(char *objectName); |
| 44 | /* |
| 45 | * Create a counter group, the "objectname" will be used when printing |
| 46 | * statistics for this counter group. |
| 47 | * |
| 48 | * Returns 0 if no more counter groups are available. |
| 49 | */ |
| 50 | |
| 51 | void setCounter(int counterId); |
| 52 | /* |
| 53 | * Defines which counter group to use, default is zero. |
| 54 | */ |
| 55 | |
| 56 | void Init_WMOPS_counter (void); |
| 57 | /* |
| 58 | * Initiates the current counter group. |
| 59 | */ |
| 60 | |
| 61 | void Reset_WMOPS_counter (void); |
| 62 | /* |
| 63 | * Resets the current counter group. |
| 64 | */ |
| 65 | |
| 66 | void WMOPS_output (Word16 notPrintWorstWorstCase); |
| 67 | /* |
| 68 | * Prints the statistics to the screen, if the argument if non zero |
| 69 | * the statistics for worst worst case will not be printed. This is typically |
| 70 | * done for dtx frames. |
| 71 | * |
| 72 | */ |
| 73 | |
| 74 | Word32 fwc (void); |
| 75 | /* |
| 76 | * worst worst case counter. |
| 77 | * |
| 78 | * This function calculates the worst possible case that can be reached. |
| 79 | * |
| 80 | * This is done by calling this function for each subpart of the calculations |
| 81 | * for a frame. This function then stores the maximum wMOPS for each part. |
| 82 | * |
| 83 | * The WMOPS_output function add together all parts and presents the sum. |
| 84 | */ |
| 85 | |
| 86 | void move16 (void); |
| 87 | void move32 (void); |
| 88 | void logic16 (void); |
| 89 | void logic32 (void); |
| 90 | void test (void); |
| 91 | /* |
| 92 | * The functions above increases the corresponding operation counter for |
| 93 | * the current counter group. |
| 94 | */ |
| 95 | |
| 96 | typedef struct |
| 97 | { |
| 98 | Word32 add; /* Complexity Weight of 1 */ |
| 99 | Word32 sub; |
| 100 | Word32 abs_s; |
| 101 | Word32 shl; |
| 102 | Word32 shr; |
| 103 | Word32 extract_h; |
| 104 | Word32 extract_l; |
| 105 | Word32 mult; |
| 106 | Word32 L_mult; |
| 107 | Word32 negate; |
| 108 | Word32 round; |
| 109 | Word32 L_mac; |
| 110 | Word32 L_msu; |
| 111 | Word32 L_macNs; |
| 112 | Word32 L_msuNs; |
| 113 | Word32 L_add; /* Complexity Weight of 2 */ |
| 114 | Word32 L_sub; |
| 115 | Word32 L_add_c; |
| 116 | Word32 L_sub_c; |
| 117 | Word32 L_negate; |
| 118 | Word32 L_shl; |
| 119 | Word32 L_shr; |
| 120 | Word32 mult_r; |
| 121 | Word32 shr_r; |
| 122 | Word32 shift_r; |
| 123 | Word32 mac_r; |
| 124 | Word32 msu_r; |
| 125 | Word32 L_deposit_h; |
| 126 | Word32 L_deposit_l; |
| 127 | Word32 L_shr_r; /* Complexity Weight of 3 */ |
| 128 | Word32 L_shift_r; |
| 129 | Word32 L_abs; |
| 130 | Word32 L_sat; /* Complexity Weight of 4 */ |
| 131 | Word32 norm_s; /* Complexity Weight of 15 */ |
| 132 | Word32 div_s; /* Complexity Weight of 18 */ |
| 133 | Word32 norm_l; /* Complexity Weight of 30 */ |
| 134 | Word32 DataMove16; /* Complexity Weight of 1 */ |
| 135 | Word32 DataMove32; /* Complexity Weight of 2 */ |
| 136 | Word32 Logic16; /* Complexity Weight of 1 */ |
| 137 | Word32 Logic32; /* Complexity Weight of 2 */ |
| 138 | Word32 Test; /* Complexity Weight of 2 */ |
| 139 | /* Counters for G.723.1 basic operators*/ |
| 140 | Word32 L_mls; /* Complexity Weight of 1 */ |
| 141 | Word32 div_l; /* Complexity Weight of 1 */ |
| 142 | Word32 i_mult; /* Complexity Weight of 1 */ |
| 143 | Word32 L_mult0; /* Complexity Weight of 1 */ |
| 144 | Word32 L_mac0; /* Complexity Weight of 1 */ |
| 145 | Word32 L_msu0; /* Complexity Weight of 1 */ |
| 146 | /* Counters for G.722.1 basic operators*/ |
| 147 | Word32 LU_shl; /* Complexity Weight of 1 */ |
| 148 | Word32 LU_shr; /* Complexity Weight of 1 */ |
| 149 | } |
| 150 | BASIC_OP; |
| 151 | |
| 152 | #ifdef THISISANEXAMPLE_0123456789 |
| 153 | /* |
| 154 | ----------------------------------------------------------------------- |
| 155 | Example of how count.h could be used. |
| 156 | |
| 157 | In the example below it is assumed that the init_OBJECT functions |
| 158 | does not use any calls to counter.h or basic_op.h. If this is the |
| 159 | case a call to the function Reset_WMOPS_counter() must be done after |
| 160 | each call to init_OBJECT if these operations is not to be included |
| 161 | in the statistics. |
| 162 | ----------------------------------------------------------------------- |
| 163 | */ |
| 164 | |
| 165 | int main() |
| 166 | { |
| 167 | int spe1Id,spe2Id,cheId; |
| 168 | |
| 169 | /* initiate counters and objects */ |
| 170 | spe1Id=getCounterId("Spe 5k8"); |
| 171 | setCounter(spe1Id); |
| 172 | Init_WMOPS_counter (); |
| 173 | init_spe1(...); |
| 174 | |
| 175 | spe2Id=getCounterId("Spe 12k2"); |
| 176 | setCounter(spe2Id); |
| 177 | Init_WMOPS_counter (); |
| 178 | init_spe2(...); |
| 179 | |
| 180 | cheId=getCounterId("Channel encoder"); |
| 181 | setCounter(cheId); |
| 182 | Init_WMOPS_counter (); |
| 183 | init_che(...); |
| 184 | ... |
| 185 | |
| 186 | while(data) |
| 187 | { |
| 188 | test(); /* Note this call to test(); */ |
| 189 | if(useSpe1) |
| 190 | setCounter(spe1Id); |
| 191 | else |
| 192 | setCounter(spe2Id); |
| 193 | Reset_WMOPS_counter(); |
| 194 | speEncode(...); |
| 195 | WMOPS_output(0); /* Normal routine for displaying WMOPS info */ |
| 196 | |
| 197 | setCounter(cheId); |
| 198 | Reset_WMOPS_counter(); |
| 199 | preChannelInter(...); fwc(); /* Note the call to fwc() for each part */ |
| 200 | convolve(...); fwc(); /* of the channel encoder. */ |
| 201 | interleave(...); fwc(); |
| 202 | WMOPS_output(0); /* Normal routine for displaying WMOPS info */ |
| 203 | } |
| 204 | } |
| 205 | #endif /* Example */ |
| 206 | |
| 207 | #endif /* COUNT_H */ |