📄 lib_wmp_fx.c
字号:
/*-------------------------------------------------------------------*/
/* INPUT ARGUMENTS : */
/* _ None (increment the counter by 1). */
/* or */
/* _ (Word16) nb: the number of test operations. */
/*-------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ None. */
/*===================================================================*/
void move16 (void)
{
counter_fx.DataMove16++;
}
void move32 (void)
{
counter_fx.DataMove32++;
}
void test (void)
{
counter_fx.Test++;
}
void logic16 (void)
{
counter_fx.Logic16++;
}
void logic32 (void)
{
counter_fx.Logic32++;
}
void Nmove16 (Word16 n)
{
#ifdef WRNG_WMOPS_FX
if( n> 160 || n < 0)
printf("DataMove16 %hd\n", n);
#endif
counter_fx.DataMove16+=n;
}
void Nmove32 (Word16 n)
{
#ifdef WRNG_WMOPS_FX
if( n> 160 || n < 0)
printf("DataMove32 %hd\n",n);
#endif
counter_fx.DataMove32+=n;
}
void Ntest (Word16 n)
{
#ifdef WRNG_WMOPS_FX
if( n> 160 || n < 0)
printf("Test %hd\n",n);
#endif
counter_fx.Test+=n;
}
void Nlogic16 (Word16 n)
{
#ifdef WRNG_WMOPS_FX
if( n> 160 || n < 0)
printf("Logic %hd\n",n);
#endif
counter_fx.Logic16+=n;
}
void Nlogic32 (Word16 n)
{
#ifdef WRNG_WMOPS_FX
if( n> 160 || n < 0)
printf("Logic32 %hd \n",n);
#endif
counter_fx.Logic32+=n;
}
/*----------------------------------------------------------------------------*/
/*===================================================================*/
/* FUNCTION : WMP_calcul_total_WMOPS_fx (). */
/*-------------------------------------------------------------------*/
/* PURPOSE : These functions calculate the total Number of */
/* Weighted Operations for fixed point code. */
/*-------------------------------------------------------------------*/
/* INPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ (Word32) wmops: the number of weighted operations. */
/*===================================================================*/
Word32 WMP_calcul_total_WMOPS_fx (void)
{
/*-------------------------------------------------------------------*/
Word16 i=0, k=0;
Word32 wmops=0.0, *ptr1, *ptr2;
/*-------------------------------------------------------------------*/
ptr1 = (Word32 *) &counter_fx;
ptr2 = (Word32 *) &op_weight_fx;
k = sizeof (counter_fx) / sizeof (Word32);
wmops = 0;
for (i = 0; i < k; i++)
wmops += ((*ptr1++) * (*ptr2++));
/*-------------------------------------------------------------------*/
return wmops;
/*-------------------------------------------------------------------*/
}
/*----------------------------------------------------------------------------*/
/*===================================================================*/
/* FUNCTION : WMP_reset_counter_WMOPS_fx (). */
/*-------------------------------------------------------------------*/
/* PURPOSE : These functions reset the code counter of WMOPS */
/* and it's for fixed point called at the beginning of */
/* the processing of each frame. */
/*-------------------------------------------------------------------*/
/* INPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ (Word32) wmops: the number of weighted operations. */
/*===================================================================*/
void WMP_reset_counter_WMOPS_fx (void)
{
/*-------------------------------------------------------------------*/
Word16 i, k;
Word32 *ptr1;
/*-------------------------------------------------------------------*/
/* Reset all the counters */
/*-------------------------------------------------------------------*/
ptr1 = (Word32 *) &counter_fx;
k = sizeof (counter_fx) / sizeof (Word32);
for (i = 0; i < k; i++)
*ptr1++ = 0;
/*-------------------------------------------------------------------*/
LastWOper_fx = 0;
/*-------------------------------------------------------------------*/
return;
/*-------------------------------------------------------------------*/
}
/*----------------------------------------------------------------------------*/
/*===================================================================*/
/* FUNCTION : WMP_calcul_delta_WMOPS_fx (). */
/*-------------------------------------------------------------------*/
/* PURPOSE : These functions calculate the partial Number of */
/* Weighted Operations between two WMP_fwc(). */
/*-------------------------------------------------------------------*/
/* INPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ (Word32) delta: the number of weighted operations. */
/*===================================================================*/
Word32 WMP_calcul_delta_WMOPS_fx (void)
{
/*-------------------------------------------------------------------*/
Word32 NewWOper, delta;
/*-------------------------------------------------------------------*/
NewWOper = WMP_calcul_total_WMOPS_fx ();
delta = NewWOper - LastWOper_fx;
/*-------------------------------------------------------------------*/
LastWOper_fx = NewWOper;
/*-------------------------------------------------------------------*/
return delta;
/*-------------------------------------------------------------------*/
}
/*----------------------------------------------------------------------------*/
/*===================================================================*/
/* FUNCTION : WMP_hash_fx (). */
/*-------------------------------------------------------------------*/
/* PURPOSE : These functions extract the pointer to a specific */
/* worst case function. */
/*-------------------------------------------------------------------*/
/* INPUT ARGUMENTS : */
/* _ (char []) func_name : the name of the fucntion under test. */
/*-------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* RETURN ARGUMENTS : */
/* _ (Word16) funcid: the function identifier. */
/*===================================================================*/
Word16 WMP_hash_fx (char func_name [])
{
/*-------------------------------------------------------------------*/
unsigned funcid;
Word16 k;
/*-------------------------------------------------------------------*/
funcid = 0;
k = 0;
while (func_name [k] != '\0')
{
funcid = func_name [k] + 31 * funcid;
k++;
}
/*-------------------------------------------------------------------*/
funcid = funcid % NB_FUNC_MAX;
/*-------------------------------------------------------------------*/
return funcid;
/*-------------------------------------------------------------------*/
}
/*----------------------------------------------------------------------------*/
/*===================================================================*/
/* FUNCTION : WMP_fwc_fx (). */
/*-------------------------------------------------------------------*/
/* PURPOSE : These functions extract the counter status for the */
/* fixed point WMOPS it must be called AFTER the call */
/* to the function to be evaluated. */
/*-------------------------------------------------------------------*/
/* INPUT ARGUMENTS : */
/* _ (char []) func_name : the name of the fucntion under test. */
/*-------------------------------------------------------------------*/
/* OUTPUT ARGUMENTS : */
/* _ None. */
/*-------------------------------------------------------------------*/
/* INPUT/OUTPUT ARGUMENTS : */
/* _ None. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -