Commit 22efb51f authored by vaillancour's avatar vaillancour
Browse files

Fix fix point complexity printing and make push_wmops() and pop_wmops() to...

Fix fix point complexity printing and make push_wmops() and pop_wmops() to point to their fixed point equivalent
parent 0e755f9e
Loading
Loading
Loading
Loading
+29 −51
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#include "rotation_file_reader.h"
#include "vector3_pair_file_reader.h"
#include "wmc_auto.h"
#include "stl.h"


#define WMC_TOOL_SKIP
@@ -76,12 +77,7 @@ static
/*------------------------------------------------------------------------------------------*
 * Local structure for storing cmdln arguments
 *------------------------------------------------------------------------------------------*/
#ifdef WMOPS
#include "stl.h"
extern int currCounter;
int idxG192;
int idxVOIP;
#endif

typedef struct
{
    char *inputBitstreamFilename;
@@ -170,9 +166,9 @@ int main(
    reset_mem( USE_BYTES );
#endif
#if ( WMOPS )
    Init_WMOPS_counter();
    Reset_WMOPS_counter();
    setFrameRate( 48000, 960 );
#ifndef DONT_COUNT
    BASOP_init
#endif
#endif
    /*------------------------------------------------------------------------------------------*
     * Parse command-line arguments
@@ -575,7 +571,6 @@ int main(
    /*-----------------------------------------------------------------*
     * Decoding
     *-----------------------------------------------------------------*/

    if ( arg.voipMode )
    {
        error = decodeVoIP( arg, hBsReader, headRotReader, externalOrientationFileReader, refRotReader, referenceVectorReader, hIvasDec );
@@ -610,7 +605,11 @@ int main(
    mainFailed = false; /* This will stay set to true if cleanup is reached via a goto due to an error */

cleanup:

#ifndef DONT_COUNT
    /* end of WMOPS counting */
    BASOP_end
    BASOP_end_noprint
#endif
    free( pcmBuf );

    if ( arg.hrtfReaderEnabled )
@@ -1513,14 +1512,8 @@ static ivas_error decodeG192(
    IsmFileWriter *ismWriters[IVAS_MAX_NUM_OBJECTS];
    IVAS_VECTOR3 Pos[IVAS_MAX_PARAM_SPATIAL_SUBFRAMES] = { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 } };
    int16_t vec_pos_update, vec_pos_len;
#ifdef WMOPS
    int GetId, GetTCId, cheId;
    /* initiate counters and objects */
    GetId = getCounterId( "IVAS_DEC_GetSamples" );
    GetTCId = getCounterId( "IVAS_DEC_GetTCSamples" );
    cheId = getCounterId( "ivas_jbm_dec_tc" );

#endif

    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; ++i )
    {
        ismWriters[i] = NULL;
@@ -1546,13 +1539,6 @@ static ivas_error decodeG192(
    reset_stack();
    reset_wmops();
#endif
#ifdef WMOPS
    //BASOP_end_noprint;
    //BASOP_init;
    Init_WMOPS_counter();
    Reset_WMOPS_counter();
    setFrameRate( 48000, 960 );
#endif

    nSamplesAvailableNext = 0;

@@ -1575,14 +1561,9 @@ static ivas_error decodeG192(
     * - Run the decoder
     * - Write the synthesized signal into output file
     *------------------------------------------------------------------------------------------*/

    while ( 1 )
    {
        /* Read next frame if not enough samples availble */
#if ( WMOPS )
        fwc();
        Reset_WMOPS_counter();
#endif
        /* reference vector */
        if ( arg.enableReferenceVectorTracking && vec_pos_update == 0 )
        {
@@ -1698,22 +1679,17 @@ static ivas_error decodeG192(
                    goto cleanup;
                }
            }
#ifdef WMOPS
SUB_WMOPS_INIT( "IVAS_DEC_GetSamples" );
#endif
            if ( ( error = IVAS_DEC_GetSamples( hIvasDec, nSamplesToRender, ( pcmBuf + nOutChannels * nSamplesRendered ), &nSamplesRendered_loop, &needNewFrame ) ) != IVAS_ERR_OK )

                {
                    fprintf( stderr, "\nError in IVAS_DEC_GetSamples: %s\n", IVAS_DEC_GetErrorMessage( error ) );
                    goto cleanup;
                }
#ifdef WMOPS
END_SUB_WMOPS;
#endif
                nSamplesRendered += nSamplesRendered_loop;
                nSamplesToRender -= nSamplesRendered_loop;
            if ( needNewFrame )
            {

                frame++;
                if ( !arg.quietModeEnabled )
                {
@@ -1723,6 +1699,7 @@ END_SUB_WMOPS;

        } while ( nSamplesRendered < nOutSamples && error == IVAS_ERR_OK );


        if ( error == IVAS_ERR_END_OF_FILE )
        {
            break;
@@ -1826,18 +1803,16 @@ END_SUB_WMOPS;
        }
#endif
#ifdef WMOPS
#ifndef DONT_COUNT
        if ( vec_pos_update == 0 )
        {
            /* update WMPOS counting (end of frame) */
            //BASOP_frame_update();
#if ( WMOPS )
            //WMOPS_output( 0 );
            fwc();
#endif
            BASOP_frame_update();
        }
        
#endif
#endif
    }

    /*------------------------------------------------------------------------------------------*
     * Flush what is still left in the VoIP Buffers....
     *------------------------------------------------------------------------------------------*/
@@ -1958,7 +1933,12 @@ END_SUB_WMOPS;
                }
            }
        }

#ifdef WMOPS
#ifndef DONT_COUNT
        /* update WMPOS counting (end of frame) */
        BASOP_frame_update();
#endif
#endif
        frame++;
        if ( !arg.quietModeEnabled )
        {
@@ -2018,13 +1998,6 @@ END_SUB_WMOPS;
    //BASOP_end
cleanup:
    /* free memory etc. */
#ifdef WMOPS
    WMOPS_output( 0 );
    fwc();
    printf( "\ndecoder complexity\n" );
    generic_WMOPS_output(    0, "dec_complx.txt" );
    printf( "\n" );
#endif
    AudioFileWriter_close( &afWriter );
    MasaFileWriter_close( &masaWriter );
    for ( i = 0; i < IVAS_MAX_NUM_OBJECTS; i++ )
@@ -2495,7 +2468,12 @@ static ivas_error decodeVoIP(
        vec_pos_update = ( vec_pos_update + 1 ) % vec_pos_len;
        frame++;
        systemTime_ms += systemTimeInc_ms;

#ifdef WMOPS
#ifndef DONT_COUNT
        /* update WMPOS counting (end of frame) */
        BASOP_frame_update();
#endif
#endif
#ifdef WMOPS_FLT
        update_mem();
        update_wmops();
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include "jbm_file_reader.h"
#include "masa_file_reader.h"
#include "wmc_auto.h"
#include "stl.h"


#define WMC_TOOL_SKIP
+65 −53
Original line number Diff line number Diff line
@@ -343,7 +343,7 @@ static long int nbTimeObjectIsCalled[MAXCOUNTERS + 1];
static Word16 funcid[MAXCOUNTERS], nbframe[MAXCOUNTERS];
static Word32 glob_wc[MAXCOUNTERS], wc[MAXCOUNTERS][NbFuncMax];
#else
#define NbFuncMax  (5000L*20L)
#define NbFuncMax  (4096)


/**
@@ -571,6 +571,10 @@ void Init_WMOPS_counter (void) {
  nbframe[currCounter] = 0;
  total_wmops[currCounter] = 0.0;
#ifdef FROM_EVS_DEV
  for (i = 0; i < NbFuncMax; i++)
  {
    bc[currCounter][i] = (Word32)MAX_32;
  }
  glob_bc[currCounter] = MAX_32;
  nbcalls[currCounter] = 0;
  total_sum[currCounter] = 0.0;
@@ -585,11 +589,6 @@ void Init_WMOPS_counter (void) {
  funcId_where_last_call_to_else_occurred = MAXCOUNTERS;

#ifdef FROM_EVS_DEV
  for (i = 0; i < NbFuncMax; i++)
  {
      bc[currCounter][i] = (Word32)MAX_32;
  }

  sum_bc[currCounter] = MAX_32;
  sum_wc[currCounter] = 0;
  sum_curr[currCounter] = 0;
@@ -617,12 +616,15 @@ void Reset_WMOPS_counter (void) {

  /* increase the frame counter --> a frame is counted WHEN IT BEGINS */
  nbframe[currCounter]++;
  
#ifndef FROM_EVS_DEV  
  /* add wmops used in last frame to count, then reset counter (in first frame, this is a no-op */
  total_wmops[currCounter] += (float) (tot * frameRate);
#endif
#ifdef FROM_EVS_DEV
  /* Call counter */
  nbcalls[currCounter] += funcid[currCounter];
  /* add wmops used in last frame to count, then reset counter (in first frame, this is a no-op */
  total_wmops[currCounter] += (float) (tot * frameRate);
  total_sum[currCounter] += (float)((glob_sum_curr[currCounter]) * frameRate);
#endif

@@ -1181,6 +1183,8 @@ void WMOPS_output_all(Word16 dtx_mode)
  fprintf (stderr, sfmt, "                  routine", " calls", "  min ", "  max ", "  avg ", "  min ", "  max ", "  avg ");
  fprintf (stderr, sfmt, " ------------------------", "  ------", "------", "------", "------", "------", "------", "------");
  for (i = 1; i <= maxCounter; i++)
    {
      if ( nbcalls[i] > 0 )
      {
          fprintf( stderr, dfmt,
                   objectName[i],
@@ -1194,18 +1198,20 @@ void WMOPS_output_all(Word16 dtx_mode)
          /* frameRate*(glob_bc[i]+wmops_children_bc[i]), */
          /* frameRate*(glob_wc[i]+wmops_children_wc[i]), */
          /* (nbframe[i] == 0) ? 0 : (float)((total_wmops[i] + total_wmops_children[i]) /(float)nbframe[i])); */

      }
      ops_cnt += total_wmops[i];
    }

  fprintf (stderr, sfmts, " -----------------", "  ------", "------", "------", "------");
    if ( nbframe[i] > 0 )
    {
        fprintf( stderr, dfmts,
                 "total",
                 (double) nbframe[0],
                 frameRate * glob_bc[0],
                 frameRate * glob_wc[0],
                 ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0] );

    }
#if 0
  {
    char *sfmtt =  "%20s %4s %15s\n";
@@ -1319,17 +1325,21 @@ void WMOPS_output_all_std(Word16 dtx_mode)
  fprintf (stdout, "\nProgram Memory Analysis: %12.0f words\n", (float)prom_cnt);
  /*fprintf (stdout, "\nInstruction Type Analysis (for worst case frame):\n\n");*/
  fprintf (stdout, "\nInstruction Type Analysis (for worst case frame number %ld):\n\n", (long int)nbframe[0]);   /* added -- JPA */
  if ( nbframe[0] > 0 )
  {
      for ( i = 0; i < (int) ( sizeof( BasicOperationList ) / sizeof( char * ) ); i++ )
      {
          fprintf( stdout, "\t%16s:          %12d\n", BasicOperationList[i], ( (UWord32 *) &glob_multiCounter )[i] );
      }

  }
  fprintf (stdout, "\n\nWeighted MOPS Analysis:\n");
  fprintf (stdout, "%74s  %23s\n", "|------  SELF  ------|"
                                  ,"|---  CUMULATIVE  ---|");
  fprintf (stdout, sfmt, "                  routine", " calls", "  min ", "  max ", "  avg ", "  min ", "  max ", "  avg ");
  fprintf (stdout, sfmt, "                  routine", "calls/fr", "  min ", "  max ", "  avg ", "  min ", "  max ", "  avg ");
  fprintf (stdout, sfmt, " ------------------------", "  ------", "------", "------", "------", "------", "------", "------");
  for (i = 1; i <= maxCounter; i++)
    {
      if ( nbcalls[i] > 0 )
      {
          fprintf( stdout, dfmt,
                   objectName[i],
@@ -1343,18 +1353,20 @@ void WMOPS_output_all_std(Word16 dtx_mode)
          /* frameRate*(glob_bc[i]+wmops_children_bc[i]), */
          /* frameRate*(glob_wc[i]+wmops_children_wc[i]), */
          /* (nbframe[i] == 0) ? 0 : (float)((total_sum[i]) /(float)nbframe[i])); */

      }
      ops_cnt += total_wmops[i];
    }

  fprintf (stdout, sfmts, " -----------------", "  ------", "------", "------", "------");
    if ( nbframe[0] > 0 )
    {
        fprintf( stdout, dfmts,
                 "total",
                 (double) nbframe[0],
                 frameRate * glob_bc[0],
                 frameRate * glob_wc[0],
                 ( nbframe[0] == 0 ) ? 0 : ops_cnt / nbframe[0] );

    }
#if 0
  {
    char *sfmtt =  "%20s %4s %15s\n";
+13 −0
Original line number Diff line number Diff line
@@ -579,6 +579,19 @@ void BASOP_get_total_wmops(double *min, double *max, double *avg);
#define SUB_WMOPS_INIT( label ) BASOP_sub_start( label )
#define END_SUB_WMOPS           BASOP_sub_end()


#ifndef WMOPS_FL
#include <assert.h>
#define reset_wmops() BASOP_init
//extern int cntr_push_pop;
#define push_wmops( x ) { BASOP_push_wmops(x); }
#define pop_wmops()     { BASOP_pop_wmops(); }
#define update_wmops() { BASOP_frame_update(); }
#define print_wmops()  { WMOPS_output_all_std(0); }
#define update_mem();
#endif


#endif /* _COUNT_H */


+2 −0
Original line number Diff line number Diff line
@@ -55,6 +55,8 @@

#define WMOPS  1                             /* Activate complexity and memory counters */
#define FROM_EVS_DEV                        /* Some enhancement written by gr and Markus during EVS time */
/*#define DONT_COUNT   */                       /* To prevent the complexity counting  */

/*#define WMOPS_PER_FRAME*/                     /* Output per-frame complexity (writes one float value per frame to the file "wmops_analysis") */
/*#define WMOPS_DETAIL*/                        /* Output detailed complexity printout for every function. Increases runtime overhead */
/*#define WMOPS_WC_FRAME_ANALYSIS*/             /* Output detailed complexity analysis for the worst-case frame */
Loading